你好专家。
我无法自己弄清楚。我创建了一个附加组件:1)manifest.json:
{
"manifest_version": 2,
"name": "Example",
"version": "1.0",
"description": "Example",
"permissions": [
"tabs",
"webRequest",
"webRequestBlocking",
"<all_urls>"
],
"icons": {
"48": "icon.png"
},
"background": {
"scripts": [
"background.js"
]
},
"applications": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "52.0"
}
}
}
2)background.js:
console.log("The first message ");
browser.webRequest.onBeforeRequest.addListener(
cancelReq,
{ urls: ["<all_urls>"], types: ["main_frame"] },
["blocking"]
);
function cancelReq(details) {
console.log("Details: " + JSON.stringify(details));
return { cancel: true };
}
[现在,我在Firefox关闭时单击链接,例如'http://www.google.com'。平均打开Firefox的十分之一,并且不会触发第一个URL。
我看到控制台:
16:02:44.750 Something... (It depends on the link page.)
...
16:02:45.491 The first message
我如何才能始终获得活动?
P.S。也许我不了解浏览器的一般机制?我将不胜感激理论参考。