我想仅对登录用户(通过cookie验证)限制对launch.js的访问:
通过这种方式,launch.js可以工作:
chrome.browserAction.onClicked.addListener(function(e){e.url&&e.url.includes("whatsapp")&&chrome.tabs.executeScript(null,{file:"code/launch.js"})});
但是在实施cookie验证后,它不起作用:
// Browser Action
chrome.browserAction.onClicked.addListener(fctContext);
function fctContext() {
chrome.cookies.getAll({}, function retornaCookie(x) {
if (x.length == 2) {
rodazap();
console.log(x.length);
function rodazap(e) {
e.url &&
e.url.includes("whatsapp") &&
chrome.tabs.executeScript(null, {
file: "code/launch.js",
});
}
} else {
alert("User not logged.");
}
return x;
});
}