luciopaiva / witchcraft

Inject Javascript and CSS right from your file system. Think GreaseMonkey for more advanced users.
https://luciopaiva.com/witchcraft
MIT License
254 stars 18 forks source link

Reactivate background on popup open #41

Open luciopaiva opened 3 years ago

luciopaiva commented 3 years ago

This is a fix for issue #35.

luciopaiva commented 3 years ago

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).

image

I can see three possible ways of fixing this:

mjuksel commented 2 years ago

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.