witchcraft
witchcraft copied to clipboard
Reactivate background on popup open
This is a fix for issue #35.
The main issue is fixed, but there's one small outstanding problem: the list of currently loaded scripts per tab id is lost when the background script is unloaded by Chrome. Even when the new popup logic reloads the background script, it doesn't remember the scripts it has loaded for the current tab (or for any other tab, for that matter).
I can see three possible ways of fixing this:
- save the map of script names by tab ids in the local storage
- save the map in the curren tab page itself (not sure if viable)
- lookup the scripts all over again, but just the names so we can fill in the popup window
I'd probably go with adding <script>
element into the page, with an id:witchcraftscripts
to check. (could use a shorter value I guess, but w/e)
Maybe use JSON.stringify(), or just CSV style (script1,script2,css1,etc2) and set it as the textContent.
/edit: maybe a template
element with the popup's inside workings might be a good idea?
This way you can just retrieve that completely instead of having to create it in the popup.