我正在开发一个chrome扩展,并使用内容脚本在页面上执行此代码
chrome.browserAction.onClicked.addListener(function(tab) {
try{
$('input[type="submit"]').click();
}
catch(err){
($('input[type="button"]').attr('onclick'))(event);
}
});我得到了这个错误
“由于Content-Security-Policy,拒绝应用内联样式。”
manifest.json代码:
{
"name": "sites faxana ads clicking exception",
"version": "1.0",
"background_page": "background.html",
"permissions": [
"tabs", "<all_urls>"
],
"browser_action": {
"default_icon": "icon.png",
"name": "Make this page red"
},
"content_security_policy": "default-src 'none'; script-src 'self'"
}发布于 2011-12-26 01:56:37
您可能正在使用头脑中的内联<style>.selector { ... }</style>。您的CSP会阻止您这样做。相反,请使用<link rel...>。
有关更多信息,请参阅该主题的这篇不错的文章:https://mikewest.org/2011/10/secure-chrome-extensions-content-security-policy
发布于 2012-01-19 00:31:21
这是因为您包含了jQuery。从你的background.html页面中删除除jQuery include (我试过jQuery 1.7.1)之外的所有内容,你会在Chrome18.0.1003.1的控制台中看到5个错误。
我已经通过他们的论坛向jQuery提交了一个bug。
https://stackoverflow.com/questions/8630689
复制相似问题