Some websites like to use javascript links instead of regular HTML links, making it impossible to open such links in new browser tabs, for example "javascript:OpenLink(908)", instead of "site.com/links/908".

Is there a way to re-write these sites on the go, using a FireFox plug-in, or a GreaseMonkey script?


  • You don´t know what the javascript will do when it responds to an onclick event, the new page might just be a generated html-element. – tovare Jul 26 '15 at 20:02

Not in general.

If they execute JavaScript, then they aren't strictly links. They cause browser to evaluate some code that does something and then requests browser to redirect you.

In theory you could make an extension that will:

  1. Wait until page is loaded.
  2. For every "JS link" pretend that it's clicked
  3. Intercept redirection
  4. Rewrite original "JS link" to a real link based on the target of redirection

There are some issues with this approach, though:

  • As far as I know browser extension APIs (especially userscript API) won't let you intercept redirections
  • Clicking links may have unwanted side effects on the page you're viewing, eg. it can disable some form buttons
  • There is no easy way to distinguish "JS links" from links that are meant to do something on the website, but don't redirect you anywhere (typical for Single Page Apps)
  • This procedure may partially depend on the halting problem which, in general, is unsolvable.

There are extensions that do this for specific sites (for example FB Purity can "fix" links on Facebook), but there is no general approach that would work everywhere

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.