1

I've this page and in my background page I'm blocking a url which defines stationName variable.

As explained in Insert code into the page context using a content script I'm able to inject stationName variable( using first technique) but unfortunately it gets injected too late, after execution of all downloaded javascript code from website which don't find stationName variable.

How to define this variable before the javascript execution of page starts?

Community
  • 1
  • 1
user5858
  • 1,082
  • 4
  • 39
  • 79
  • How is your content script invoked? With an entry in the manifest or programmatically? Did you use the `run_at: document_start` option? – rsanchez Jan 31 '16 at 02:27
  • @rsanchez the content script is declared in the manifest. I've not used run_at – user5858 Jan 31 '16 at 08:50

1 Answers1

0

I've placed this file at resources/irctc containing stationName variable and in chrome.webRequest.onBeforeRequest.addListener I'm redirecting it :

return   {redirectUrl: chrome.extension.getURL('resources/irctc/stationnames.js')
};

And it's working but I'm still looking for the right way.

user5858
  • 1,082
  • 4
  • 39
  • 79