dpacassi / disable-javascript

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

does not work for file: urls #44

Open bughit opened 6 years ago

bughit commented 6 years ago

DJ 2.3.1 Fx 62.0.3

javascript is not disabled, in either domain or tab mode

dpacassi commented 6 years ago

Hi @bughit

Thanks for your report! The web extension indeed doesn't work for local files opened directly from the file system. And unfortunately it won't be possible to disable JS for them.

The web extension API is quite strict about what's possible and not (compared to the legacy XUL based extensions) meaning that there's no API for disabling/enabling JS at this time. My web extension uses Content-Security-Policy headers to enable/disable JavaScript - while this works for normal sites, it won't work for local files.

However, I see some room for improvement here:

  1. Clearly state in the web extension description that local files are not supported
  2. Disable the toggle switch if a local file was opened

If you want to disable JavaScript for local files, I'm afraid you'll have to install a local web server and access them through localhost.

I hope you understand!

gildas-lormeau commented 5 years ago

Alternatively, you could use the meta tag for this, cf. https://developers.google.com/web/fundamentals/security/csp/#the_meta_tag.