meetDeveloper / JavaScript-Switcher

A Mozilla Firefox extension to toggle JavaScript on Individual Domain.
GNU General Public License v3.0
26 stars 3 forks source link

<input> still hidden if inside <noscript> #6

Open goozak opened 3 years ago

goozak commented 3 years ago

Given this HTML:

<html>
  <head>
    <title>Working...</title>
  </head>
  <body>
    <form method="POST" name="hiddenform" action="http://dummy">
      <input type="hidden" name="Data" value="SomeData"/>
      <input type="hidden" name="OtherData" value="Coffee"/>
      <noscript>
        <p>Script is disabled. Click Submit to continue.</p>
        <input type="submit" value="Submit"/>
      </noscript>
    </form>
    <script language="javascript">window.setTimeout(alert('Submited via JS'), 0);</script>
  </body>
</html>

When JavaScript is disabled via the Switcher, the <p> tag is shown as expected, but not the <input>. If JavaScript is disabled via javascript.enabled, the entire <noscript> is shown (but only if the Switcher is green).

phil294 commented 2 years ago

This bug is also prevalent with <style> elements which can break entire websites: Try opening a Startpage search with JS disabled by this addon: The results are invisible (!) because of missing noscript styles.

I normally never recommend copying code, but in this case, I think it's best to just use 100% of uBlocks code for this logic, so replace background/content.js with https://github.com/gorhill/uBlock/blob/2b9aba27489274a42bcc03ae7ac1da3bb33305a9/src/js/scriptlets/noscript-spoof.js and it works fine. This uBlock version also considers xml files and meta refresh inside