Trying to figure out a way to handle settings in the extension.
I assume chrome.storage.local is the way to do it, yet it is not available to the content script. Is this correct?
To side-step this, I send a message to background script (chrome.runtime.sendMessage()), where it is possible to call chrome.storage.local.get() for the specified key. Yet it seems that handling of “return true” is not properly implemented (yet? https://bugzilla.mozilla.org/show_bug.cgi?id=1202481 mentions it, but it seems stuck for over a week now), so I cannot call sendResponse() from inside the .get() callback.
Please let me know if there is a working way to get keys from local storage to content script, or if I just need to wait till this part of the functionality is complete.
Same obstacle with making AJAX calls—the site I need to use the extension on (GitHub) doesn’t allow scripts to load data from outside sources, yet a call from background script works (which is great!). But I can’t pass the response to that call back to content script, since sendResponse() doesn’t work from an asynchronous callback.
OK, found one possible workaround—in the callback in the background script, instead of calling sendResponse() (which doesn’t work), I can send a message to the tab that called bg.js in the first place.
Sooo… it is possible to implement, but takes “Callback Hell” to a new level. I really hope there is a better solution, or that handling of “return true” will be implemented soon.