0

(I looked at various posts on this, but could not find a workable / recent information)

My content script needs to load some settings (that were set by the user from the default_popup) before page construction starts.

If I do:

chrome.storage.sync.get(null, storage => { 
  if (chrome.runtime.lastError) return;
  debugger; 

When the debugger breaks there are already quite a few DOM elements constructed (visible in the 'Elements' tab) to which I could obviously not apply the settings.

Is there a way for the content script to get data from the popup synchronously before any page loading starts?

Makyen
  • 31,849
  • 12
  • 86
  • 121
kofifus
  • 17,260
  • 17
  • 99
  • 173
  • that question injects two content script and as far as I could follow it is not the same so I cannot get any answer from it – kofifus Sep 12 '17 at 05:23
  • It shows how to pass a dynamic value to your content script that runs on document_start. – wOxxOm Sep 12 '17 at 06:41
  • it shows untested code that doesn't work :( – kofifus Sep 12 '17 at 08:29
  • 1
    It works, actually, and it's already used in some extensions like Tampermonkey. Make sure you've reloaded the extension. – wOxxOm Sep 12 '17 at 08:35

0 Answers0