views:

173

answers:

1

A website I wish to tweak is using window.location in order to redirect specific users to a blocking page. That website is doing it in plain <script> tag, so it is impossible to bypass it by overriding the onload event using document.body.setAttribute('onload','');.

Is there another way to inject my code to the page without using Firefox extensions such as NoScript?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
  <title></title>
  <script type="text/javascript">
    if (1)  window.location="http://example.net"
  </script>
</head>
<body></body>
</html>
+1  A: 

This question is tagged "Greasemonkey", but GM cannot/will-not run your script before the redirect script fires. You'd have to write a firefox add-on to do that. Might poke around https://addons.mozilla.org/en-US/firefox/ first.

Sometimes you can use adblock to stop the load of the offending script.

NoScript might be the most cost-effective way, if the site's usable without javascript (although GM javascript will still run -- so you could replace lost functionality with GM code, maybe).

This question appears to be related to this one.

Brock Adams