Мне нужно добавить Read and change all your data on the websites you visit
это разрешение в мое chrome расширение, чтобы я мог читать DOM
элементы страницы.
манифест. json
{
"name": "BBox Counter",
"version": "2.0",
"manifest_version": 2,
"content_scripts": [
{
"match_about_blank": 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"
],
"content_security_policy":"script-src 'self' https://www.gstatic.com/ https://*.firebaseio.com https://www.googleapis.com; object-src 'self'",
"background": {
"page": "background.html"
}
}
Обновление содержимого. js
console.log("context started...");
chrome.runtime.onMessage.addListener(gotMessage);
function gotMessage(message, sender, sendResponse) {
console.log("Message received");
const element_id = "event-capturer";
if (message == 'count') {
if (document.getElementById(element_id)) {
const cnt = document.getElementById(element_id).getElementsByTagName("rect").length;
alert("Count is: "+cnt);
} else {
alert("No element with '"+element_id+"' tag.");
}
}
}
на этом сайте есть div
с идентификатором event-capturer
, но я не Не знаю, почему это будет еще часть "No element with '"+element_id+"' tag."
.
, пожалуйста, помогите мне с этим. Спасибо