Ben Cantrick (mackys) wrote,
Ben Cantrick

  • Mood:
  • Music:

Dear Lazyweb: Help me kill misused "noscript" tags.

So here's the deal: A lot of web designers assume that a JavaScript enabled browser is a given, and their only concession to us who don't play that, is a line in the master HTML page template for the site that reads something like:

<noscript><META HTTP-EQUIV="refresh" content="0;URL="></noscript>

The amusing irony is that most of the time, the pages do degrade reasonably and could be viewed with a JS disabled browser. But thanks to the noscript tag, you don't get to see even the degraded page. The browser automatically takes you to the error page when you try and load any page on the site.

So what I want is, a way to tell my browser to temporarily NOT honor noscript tags. Or to re-write them so they're not noscript tags any more. Or anything else that would allow me to ignore noscript tags and see the contents of the page. And decide for myself if I need to have JavaScript or not.

Anyone know how to do it? Preferably for Firefox if that's possible.

Tried several Google searches with different terms, but didn't find anything that looked useful. Maybe I'm just using the wrong terms. I swear someone must have made a GreaseMonkey script to do this, but I can't find it...

Edit: Here's an easy GreaseMonkey script to comment out <noscript> tags:

var tags = document.getElementsByTagName("noscript");

for(var i=0; i<tags.length; i++) {
tags[i].outerHTML = "<!-- " + tags[i].innerText + "//-->";

It doesn't work. Know why? Because you have to enable JavaScript for THE WHOLE PAGE in order to get a GreaseMonkey script on the page to run! Talk about "unclear on the concept" - in order to run a GreaseMonkey script, to kill <noscript> tags, I have to enable JavaScript, which automatically kills <noscript> tags! AHHHHHHHHHH!!! (Shoots self in head!)

The only real way around this is to make my script into an extension. Firefox Extensions are written in JavaScript, but they run in a different way than JavaScript on a HTML page does. An extension will allow me to run this code without running afoul of NoScript's (very correct, and desired) ability to kill all JavaScript on a page. Yup, gonna be making another one of them-there EXTENSION thingies. At least I know about the GreaseMonkey Script -> Firefox Extension Complier this time...

Now all I need to do, to complete the stupidity cycle, is create an extension that will run user scripts (in spite of NoScript) when GreaseMonkey requests it. Eesh! Quoth jwz: "This is only "free" if your time has no value."

Adding an event listener will work, but it's a very bad idea from a security perspective:

This also would be terribly insecure, because of the extra APIs that GM scripts get access to, and the fact that this would expose them to content pages.

-GMDev mailing list

GreaseMonkey version after 0.5 use some special FF API calls ( to apply GM scripts to a web page with relative safely:

The new methods used in GM post-0.5 to increase security take advantage of new methods that FF 1.5 provide, (to the best of my knowledge) and it really won't work on FF 1.0.

-GMDev mailing list

So basically, you have to upgrade to FF 1.5 or later, and then upgrade to GreaseMonkey 0.5+, and then things will work despite normal scripts on the page being disabled by NoScript.

Not the solution I was hoping for, but at least it's a solution.
  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.