Use chrome.storage in script loaded by webrequest blocking -



hello, have problem extension. block script webrequest.onbeforerequest when trying use chrome.storage console return 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, script (load.js) load perfect, sorry baddd english.

you're redirecting script loaded in normal web page load.js in extension. although load.js extenison, it's loaded , executed in web page's context, has no access chrome.storage api.

i'd recommend cancel request , inject load.js content script.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -