0

I have a chrome extension,

I am trying to catch webRequest for example onBeforeRequest, but it doesn't fire on some web requests. Is it even possible to not have a onBeforeRequest fired on some http or https website? or I am confusing the url patterns somewhere?

This is the code in background.js. beforeRequest is never executed on some websites. Not if I try on this website for example: https://discourse.mozilla.org/t/onbeforerequest-event-not-fired-firefox-is-started-with-command-line-options/33557

Is it possible that url patterns

"<all_urls>" or "*://*/*" don't match with the URL?

chrome.webRequest.onBeforeRequest.addListener(
function(details){
    beforeRequest(details.tabId);
  }, {urls: ["<all_urls>"],types: ["main_frame"]}, [ "blocking" ]);

This is the manifest.json

{
"name": "Example",
"version": "1.0",
"manifest_version": 2,
"description": "Prototype",
"browser_action": {
  "default_icon": "img/grey-16.png",
  "default_popup": "popup/index.html"
},
"permissions": [
  "tabs", 
  "background", 
  "<all_urls>", 
  "activeTab",
  "webRequest",
  "webRequestBlocking",
  "storage",
  "downloads",
  "webNavigation"
],
"content_scripts" : [
 {
   "js": ["content_scr.js"],
   "run_at": "document_start",
   "all_frames" : true,
   "matches": ["*://*/*"]
 }
],
"background": {
  "scripts" : ["background.js"],
  "persistent": true
},
"content_security_policy": "script-src 'self' 'unsafe-eval';  object-src 'self'"
}
iesiyok
  • 79
  • 2
  • 10
  • 1
    The site was using a fake navigation via history.pushState, see [Is there a JavaScript / jQuery DOM change listener?](https://stackoverflow.com/a/39508954) – wOxxOm Feb 25 '21 at 06:00
  • It's very interesting, thank you – iesiyok Feb 25 '21 at 20:42

0 Answers0