45 lines
1022 B
JavaScript
45 lines
1022 B
JavaScript
//记录谷歌账户
|
|
let google_mail='';
|
|
//记录是否有运行权限
|
|
let executionAuthority=false;
|
|
//是否查询过
|
|
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');
|
|
if(google_mail=='qq2392025971@gmail.com'){
|
|
executionAuthority=true
|
|
return true;
|
|
}
|
|
return true;
|
|
}
|
|
/**
|
|
* 监听消息
|
|
* @param {*} req 发送过来的消息
|
|
* @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);
|
|
}
|
|
return true
|
|
})
|
|
|
|
|
|
setTimeout(function(){
|
|
chrome.tabs.create({ url: "popup.html" }, function () {
|
|
})
|
|
},3500);
|
|
|