0

Basically, I have a content-script which runs on all webpages. I want to listen to the errors of these pages. So I wrote a code like this

window.addEventListener('error', function(e) {
    console.log("error here")
});

But for some reason, I am unable to get the errors of that particular page I am on. Lets say I am on certain website X and if X throws an error, I am unable to capture them. Any Idea why this is happening. Please note, I am able to handle events like click.

Here is my manifest

{
"name": "xtension",
"version": "1.0.0",
"description": "extenstion",
"manifest_version": 3,
"author": "Abhi",
"action":{
    "default_popup": "index.html",
    "default_title": "xtension"
},
"content_scripts":[
    {
      "matches":[
        "<all_urls>"
      ],
      "js": ["content.js"]
    }
  ]

}

Abhijith
  • 69
  • 4
  • What exactly are you expecting? (e.g. Are the errors caught by other code? If an error is caught, it doesn't dispatch an event on `window`.) – jsejcksn Aug 13 '22 at 18:58
  • Content scripts run in an isolated JS environment. You need to insert the listener in [page context](/a/9517879). – wOxxOm Aug 13 '22 at 21:04

0 Answers0