Monday, 12 August 2013

Use chrome.storage in script loaded by webrequest blocking

Use chrome.storage in script loaded by webrequest blocking



Hello, I have a problem with an extension. I block an script with
webRequest.onBeforeRequest but when I trying to use chrome.storage console
return this error Uncaught TypeError: Cannot read property 'local' of
undefined
My code:
background.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"]);
load.js
chrome.storage.local.get('test', function (h){
console.log(h.test);
});
manifest.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
}
}
btw, the script (load.js) load perfect, sorry for my BADDD english.

No comments:

Post a Comment