Is it possible to have Greasemonkey scripts run before anything else on the page?
I'm aware of @run-at document-start
, but this appears to run immediately after the <HTML>
tag. Normally this isn't a problem, but if the page is misformatted as in the example below, there doesn't seem to be anything I can do.
I'd appreciate any suggestions or ideas. Thanks!
<script>alert('This is an annoying message.');</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
...etc...
Actually, @run-at document-start
does pretty much run the GM script before anything from the page.
In your case, the following code will work in conjunction with @run-at document-start
:
_oldAlert = alert;
unsafeWindow.alert = function () {};
/*-- Optionally, wait for the DOM, then set an onload handler to restore
alert().
*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With