你好,我的扩展有问题。我阻止了一个脚本,webRequest.onBeforeRequest
但是当我尝试使用chrome.storage
控制台时返回此错误Uncaught TypeError: Cannot read property 'local' of undefined
我的代码:
背景.js
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
if( details.url == "http://o1.t26.net/js/application.js?2.0.4" )
return {redirectUrl: chrome.extension.getURL("load.js") };
},
{urls: ["http://o1.t26.net/*.js?2.0.4"]}, ["blocking"]);
加载.js
chrome.storage.local.get('test', function (h){
console.log(h.test);
});
清单.json
{
"content_scripts": [{
"matches": [ "http://www.agust.in/*", "http://agust.in/*" ],
"js": ["test.js"],
"run_at": "document_start",
"all_frames": true
}
],
"description": "TEST",
"icons": {
"16": "icon_one.png",
"48": "icon_two.png",
"128": "icon_three.png"
},
"name": "Test",
"permissions": ["storage", "webRequest", "webRequestBlocking", "http://www.agust.in/*", "http://agust.in/*", "http://o1.t26.net/*", "http://t26.net/*"],
"version": "1.4",
"manifest_version": 2,
"web_accessible_resources": [ "load.js"],
"background": {
"scripts": ["background.js"],
"persistent": true
}
}
顺便说一句,脚本(load.js)加载完美,对不起我的 BADDD 英语。