为什么我的扩展程序脚本继续在chrome:// extension中运行并给出此错误: “运行tabs.executeScript时未经检查的runtime.lastError:无法访问chrome:// URL”
我的background.js出错了
chrome.runtime.onInstalled.addListener(function(){
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostContains: 'facebook.com'},
})
],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
});
var BgSet = '';
var setting = 'document.body.style.backgroundSize = "100% auto"; document.body.style.backgroundPosition = "center top"; document.body.style.backgroundRepeat = "repeat-y";'; //default
chrome.tabs.onUpdated.addListener(function(tabID, changeInfo, tab){
if(tab["status"] == "complete" && tab["url"] ){
if(localStorage["BackgroundColor"] != null || localStorage["BackgroundColor"] != ''){
BgSet += 'document.body.style.backgroundColor = "' + localStorage["BackgroundColor"] + '"; ';
}
if(localStorage["BackgroundImage"] != null || localStorage["BackgroundImage"] != ''){
BgSet += 'document.body.style.backgroundImage = "url(' + localStorage["BackgroundImage"] + ')"; ';
}
if (localStorage["Setting"] == 'CenterNo') {
var setting = 'document.body.style.backgroundSize = "100% auto"; document.body.style.backgroundPosition = "center"; document.body.style.backgroundRepeat = "no-repeat"; document.body.style.backgroundAttachment = "fixed";';
}
else if (localStorage["Setting"] == 'CenterWith') {
var setting = 'document.body.style.backgroundSize = "100% auto"; document.body.style.backgroundPosition = "center top"; document.body.style.backgroundRepeat = "repeat-y"; document.body.style.backgroundAttachment = "";';
}
if(BgSet!=""){
chrome.tabs.query({active:true, currentWindow:true}, function(tabs){
chrome.tabs.executeScript(
tabs[0].id,
{code: BgSet+
'if(document.getElementById("contentCol")!=null)document.getElementById("contentCol").style.backgroundColor = "transparent";'+
'if(document.getElementById("pagelet_timeline_recent")!=null)document.getElementById("pagelet_timeline_recent").style.backgroundColor = "transparent";'+
setting});
});
}
}
});
我的清单。JSON
{
"name" : "Facebook Beauty",
"description" : "Editing Your Facebook",
"permissions" : [
"activeTab",
"declarativeContent",
"storage",
"unlimitedStorage",
"http://*.facebook.com/*",
"https://*.facebook.com/*"
],
"version" : "1.0",
"background":{
"scripts": ["background.js"],
"persistent": true
},
"page_action":{
"default_popup" : "popup.html",
"default_icon" :{
"16" : "images/get_started16.png",
"32" : "images/get_started32.png",
"48" : "images/get_started48.png",
"128" : "images/get_started128.png"
}
},
"content_scripts": [
{
"matches": [
"http://*.facebook.com/*",
"https://*.facebook.com/*"
],
"js": ["content.js"],
"run_at": "document_end"
}
],
"icons" :{
"16" : "images/get_started16.png",
"32" : "images/get_started32.png",
"48" : "images/get_started48.png",
"128" : "images/get_started128.png"
},
"manifest_version" : 2
}
为什么我的扩展程序继续将background.js注入chrome://我只在Facebook.com上使用了声明性内容?我有想念的东西吗?我的Background JS尚未运行到除facebook.com之外的其他网站,并且错误chrome://