dpacassi / disable-javascript

Adds the ability to disable JavaScript on specific sites.
MIT License
275 stars 36 forks source link

Preserving live DOM tree at pause toggle time #64

Closed Dboingue closed 4 years ago

Dboingue commented 4 years ago

Rare are the extensions to pause javascript that work on per-tab basis. I was trying your extension of a minimalist web site page. My intent was to block any refreshing of the DOM tree data (CSS and html nodes) as I leave the tab inactive to activate other tabs, and then come back later to that tab. Besides what i read about reloading at toggling back on (which may be a problem as well), before that, it seems that the live DOM CSS properties and many nodes that are the expected target of web site JS are lost upon toggling the JS off for that tab, losing all user data that may have been stored in such resources. Is there something i forgot to change in your extension setting that would preserve that data? leaving the other problem of reloading aside first, and then is the reloading post re-enabling part of your future features. (2 problems, first one more important).

dpacassi commented 4 years ago

Hi @Dboingue!

Thanks for your questions. To clarify, the web extensions blocks JavaScript by adding a Content-Security-Policy header with a script-src 'none'; value to the request. This behaviour can be found here: https://github.com/dpacassi/disable-javascript/blob/master/background/background.js#L348

That means every time you toggle the JS state for a tab or domain, the page has to be reloaded again. Any JS state before the reload would obviously get lost.

Now, as for your question, I don't think this extension will ever support live pausing/continuing of JavaScript. Mainly because it would be difficult (but not impossible) to implement and only a few people would really use it. As for today, you can already use your browser console to pause and resume JavaScript execution for a given tab (simply google for this, e.g. https://superuser.com/questions/1302029/how-to-halt-javascript-execution-after-page-load-firefox ).

That being said, I'm always open for contributors to add new features to the extension. So if someone has the time & motivation to implement, I'm happy to merge any pull requests.

I hope I could answer your questions! Otherwise please let me know.