问题
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