Vì vậy, tôi đang cố gắng thực thi tập lệnh từ nguồn bên ngoài như www.script.google.com trong background.js. Nhưng tôi nhận được lỗi này -lỗi chrome.tabs.executeScript lỗi "Không được kiểm tra runtime.lastError khi chạy tabs.executeScript: Không thể truy cập nội dung của url ..."
Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url "chrome-devtools://devtools/bundled/devtools.html?&remoteBase=https://chrome…&dockSide=undocked&toolbarColor=rgba(223,223,223,1)&textColor=rgba(0,0,0,1)". Extension manifest must request permission to access this host.
gì tôi đang làm là gửi tin nhắn từ popup.js để background.js Trong popup.js -
chrome.runtime.sendMessage({type:"addtask"});
Trong background.js -
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
if(request.type == "addtask")
{
chrome.tabs.executeScript(null,
{file:"https://script.google.com/url of script....."});
}
});
My manifest.json-
{
"name": "Extension",
"version": "0.0.1",
"manifest_version": 2,
"browser_action": {
"default_popup": "popup.html"
},
"background": {
"scripts": ["background.js"],
"persistent": false
},
"content_scripts": [{
"js": ["jquery.min.js","contentscript.js"],
"matches": ["http://*/*","https://*/*"],
"css" : ["feedback.css"]
}],
"permissions": [
"storage","tabs","https://script.google.com"
],
"web_accessible_resources": ["feedback.js","html2canvas.js","event.js"],
"content_security_policy": "script-src 'self' https://script.google.com/*; object-src 'self'"
}
Bao gồm mã có liên quan mà gây ra lỗi này. – Xan
@Xan tôi đã thêm mã. – Sid
Ý định của bạn không rõ ràng 100%. Bạn đang cố gắng thực thi tập lệnh bên ngoài dưới dạng tập lệnh nội dung hay là tập lệnh nền? – Xan