/* * @Author: lingling 1077478963@qq.com * @Date: 2024-08-19 09:47:04 * @LastEditors: lingling 1077478963@qq.com * @LastEditTime: 2024-09-27 15:57:31 * @FilePath: \谷歌自动搜索邮箱自动点击v3\js\background.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ //记录谷歌账户 let Ggoogle_mail = ""; //记录是否有运行权限 let executionAuthority = false; //是否查询过 let haveYouChecked = false; /** * 查看是否有权限运行 * @param {*} google_mail 谷歌id */ //TODO 授权没写完 async function viewPermission(google_mail) { let tmp = await axios.post( "http://149.129.107.38:8787/index/queryauthorization", { google_account: google_mail } ); if (tmp.data.code == 200) { executionAuthority = true; Ggoogle_mail = google_mail; return true; } haveYouChecked = true; return false; } /** * 监听消息 * @param {*} req 发送过来的消息 * @param {*} sendResponse 返回消息 */ chrome.runtime.onMessage.addListener(async (req, sender, sendResponse) => { if (haveYouChecked) { sendResponse(executionAuthority); return true; } if (req.ty == "viewPermission") { const res = req.info; if (res&&!haveYouChecked) { let data = await viewPermission(res); console.log(data); sendResponse(data); } } return true; }); setTimeout(function () { chrome.tabs.create({ url: "popup.html" }, function () {}); }, 3500);