From 9003b60c47d8e166a41cff8125a6a39aee6c18ac Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Wed, 25 Sep 2024 14:54:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=88=E6=9D=83=E6=B2=A1=E5=86=99=E5=AE=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/background.js | 14 +++++++++++--- js/popup.js | 14 ++++++++------ lib/content.js | 22 ++++++++++++++-------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/js/background.js b/js/background.js index 806977a..2bc0857 100644 --- a/js/background.js +++ b/js/background.js @@ -8,13 +8,14 @@ let haveYouChecked=false; * 查看是否有权限运行 * @param {*} google_mail 谷歌id */ +//TODO 授权没写完 async function viewPermission(google_mail){ let data =await axios.get('https://api.giaogiao.uk/api.php?type=list'); - console.log(data) if(google_mail=='qq2392025971@gmail.com'){ + executionAuthority=true return true; } - return false; + return true; } /** * 监听消息 @@ -22,10 +23,17 @@ async function viewPermission(google_mail){ * @param {*} sendResponse 返回消息 */ chrome.runtime.onMessage.addListener(async (req, sender, sendResponse) => { + if(executionAuthority){ + sendResponse(executionAuthority); + return true + } + if(req.ty=="viewPermission"){ const res = req.info let data=await viewPermission(res); + console.log(data) sendResponse(data); - console.log(res) + } + return true }) diff --git a/js/popup.js b/js/popup.js index 3891f29..cc148e7 100644 --- a/js/popup.js +++ b/js/popup.js @@ -2,7 +2,7 @@ * @Author: lingling 1077478963@qq.com * @Date: 2024-08-19 09:47:04 * @LastEditors: lingling 1077478963@qq.com - * @LastEditTime: 2024-08-26 14:50:09 + * @LastEditTime: 2024-09-25 10:55:38 * @FilePath: \谷歌自动搜索邮箱自动点击v3\js\popup.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -51,6 +51,7 @@ $(function () { sender, sendResponse ) { + console.log(request) // 判断是产生一个新页面是 if (request.ty == "get") { sendResponse({ name, id }); @@ -62,10 +63,10 @@ $(function () { return true; }); - // async function text() { - // let a = await createTab("https://www.youtube.com/", "youtube"); - // return a; - // } + async function google() { + let a = await createTab("https://www.google.com", "naver"); + return a; + } async function youtube_shorts() { let a = await createTab( "https://www.youtube.com/shorts/", @@ -103,6 +104,7 @@ $(function () { } //函数队列 let queue = []; + queue.push(google); // queue.push(play_finance);//好像js注入不进去 queue.push(shopping); queue.push(calendar); @@ -156,7 +158,7 @@ $(function () { } chrome.tabs.onCreated.addListener((e) => { - sed_cont(id); + // sed_cont(id); console.log(e); console.log("创建了一个新的浏览器窗口"); }); diff --git a/lib/content.js b/lib/content.js index f2a81f6..85de0f0 100644 --- a/lib/content.js +++ b/lib/content.js @@ -36,10 +36,15 @@ const naver = async (r, id) => { const emailRegex = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/; const match = googelid_str.match(emailRegex); const email = match ? match[0] : null; - console.log(email) - let res = await to_background(email); - console.log(`res:${res} emall:${email}`); - // send_close(id); + console.log(`email:${email} r:${r} id${id}`) + try { + let res = await to_background(email); + console.log(`res:${res} emall:${email}`); + await delay(5) + } catch (error) { + + } + send_close(id); }; /** * @@ -380,6 +385,7 @@ async function to_background(params) { chrome.runtime.sendMessage( { info: params, + ty: "viewPermission", }, (res) => { console.log(res); @@ -438,7 +444,7 @@ chrome.runtime.sendMessage( } ); -chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { - console.log(request); - sendResponse("我收到了你的情书,popup~"); -}); +// chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { +// console.log(request); +// sendResponse("我收到了你的情书,popup~"); +// });