views:

32

answers:

1

A page has the following in the html:

<script type="text/javascript">
  // some code
</script>

My greasemonkey script needs to prevent that script from running. How can I do this?


Update: I understand that in the general case this is impossible. However, in my specific case, I may have a loophole?

<script type="text/javascript">
  if (!window.devicePixelRatio) {
    // some code that I -don't- want to be run, regardless of the browser
  }
</script>

Is there some way I can define window.devicePixelRatio before the embedded script runs?

+2  A: 

User scripts run after the page is loaded, so you aren't able to.

Unless, the code uses the "onload" event.

User scripts are executed after the DOM is fully loaded, but before onload occurs. This means that your scripts can begin immediately and don't need to wait for onload.

Aaron Harun
Thanks. I guess I'll do my best to try and undo what the script does. I've updated the question with something that -may- make it possible... or is it the case that by the time my GM script runs, it's too late anyway?
Mala
Not with a user script. The embedded JavaScript runs as soon as it is loaded by the browser. User scripts run after the entire page is loaded.
Aaron Harun