2021年3月19日星期五

Chrome dev tools doesn't show the event listener added via extension content script

I added an onclick event listener to an element from the page DOM from a extension content script.

When I trigger the element event listener I can see that it logs to the console, perfect. But I wanted to know why the event doesn't appear on the dev tools element event listeners tab. Or does it show somewhere else?
Tried this on chrome and firefox.

manifest.json

{      "manifest_version": 2,      "name": "Test Extension",      "version": "0.0",      "background": {          "persistent": false,          "scripts": [              "background.js"          ]      },      "content_scripts": [          {              "matches": [                  "<all_urls>"              ],              "js": [                  "content.js"              ]          }      ]  }  

content.js

const div = document.getElementById("id")    div.addEventListener("click", function () {     console.log("extension click")  })  

Chrome dev tools: in this case no click event here
enter image description here

https://stackoverflow.com/questions/66717347/chrome-dev-tools-doesnt-show-the-event-listener-added-via-extension-content-scr March 20, 2021 at 09:05AM

没有评论:

发表评论