chrome_extensions/js/background.js

45 lines
1022 B
JavaScript
Raw Normal View History

2024-09-24 17:52:21 +08:00
//记录谷歌账户
let google_mail='';
//记录是否有运行权限
let executionAuthority=false;
//是否查询过
let haveYouChecked=false;
/**
* 查看是否有权限运行
* @param {*} google_mail 谷歌id
*/
2024-09-25 14:54:52 +08:00
//TODO 授权没写完
2024-09-24 17:52:21 +08:00
async function viewPermission(google_mail){
let data =await axios.get('https://api.giaogiao.uk/api.php?type=list');
if(google_mail=='qq2392025971@gmail.com'){
2024-09-25 14:54:52 +08:00
executionAuthority=true
2024-09-24 17:52:21 +08:00
return true;
}
2024-09-25 14:54:52 +08:00
return true;
2024-09-24 17:52:21 +08:00
}
/**
* 监听消息
* @param {*} req 发送过来的消息
* @param {*} sendResponse 返回消息
*/
chrome.runtime.onMessage.addListener(async (req, sender, sendResponse) => {
2024-09-25 14:54:52 +08:00
if(executionAuthority){
sendResponse(executionAuthority);
return true
}
if(req.ty=="viewPermission"){
2024-09-24 17:52:21 +08:00
const res = req.info
let data=await viewPermission(res);
2024-09-25 14:54:52 +08:00
console.log(data)
2024-09-24 17:52:21 +08:00
sendResponse(data);
2024-09-25 14:54:52 +08:00
}
return true
2024-09-24 17:52:21 +08:00
})
2024-08-19 09:59:57 +08:00
setTimeout(function(){
chrome.tabs.create({ url: "popup.html" }, function () {
})
2024-08-22 14:06:42 +08:00
},3500);
2024-09-24 17:52:21 +08:00