回避策としてinsertCSSを使用するため、これはChromeの既知のバグです。
元:
次のコードbackground.js
は、と同じ仕事をしますmanifest.json
//Use chrome.tabs.onUpdated.addListener(function(integer tabId, object changeInfo, Tab tab) {...}); as applicable to ensure it works on every page
chrome.browserAction.onClicked.addListener(function (tab) {
chrome.tabs.insertCSS(null, {
code: "document.body.bgColor='red'",
"all_frames": true
});
});
また
//Use chrome.tabs.onUpdated.addListener(function(integer tabId, object changeInfo, Tab tab) {...}); as applicable to ensure it works on every page
chrome.browserAction.onClicked.addListener(function (tab) {
chrome.tabs.insertCSS(null, {
file: {file:"content.css"},
"all_frames": true
});
});
マニフェストに十分な権限があることを確認してください
/* in manifest.json */
"permissions": [
"tabs", "http://*/*"
],
参考文献
a) CSSを挿入
b)プログラムによるインジェクション
お役に立てれば。