How to put chrome extension under the task context?

一世执手 提交于 2020-05-17 06:23:26

问题


My extension is BBox Counter, i want to put BBox Counter under the task context like AdGuard AdBlocker.

manifest.json

{
    "name": "BBox Counter",
    "version": "2.0",
    "manifest_version": 2,
    "content_scripts": [
        {

            "match_about_blank": true,
            "all_frames": true,
            "matches": ["<all_urls>"],
            "js": ["content.js"]
        }
    ],
    "browser_action": {
        "default_icon": "16.png",
        "default_popup": "popup.html",
        "default_title": "BBox Counter"
    },
    "permissions": [
      "activeTab",
      "contextMenus",
      "storage",
      "identity"
    ],
    "content_security_policy":"script-src 'self' https://www.gstatic.com/ https://*.firebaseio.com https://www.googleapis.com; object-src 'self'",
    "background": {
        "page": "background.html"
    }
}

I want to do so because i am getting Error in event handler: TypeError: Cannot read property 'getElementsByTagName' of null this error while executing document.getElementById(element_id).getElementsByTagName("rect").length; code using BBox Counter extension but when i am execute this code in console if the javaScritp context is in top then it's shows same error message but when i am set it to task then it's execute successfully.

Please help me with that. Thank you.

来源:https://stackoverflow.com/questions/61608815/how-to-put-chrome-extension-under-the-task-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!