是否可以让 Greasemonkey 脚本在页面上的其他任何内容之前运行?
我知道 @run-at document-start
, 但这似乎在 <HTML>
之后立即运行标签。通常这不是问题,但如果页面格式错误,如下例所示,我似乎无能为力。
如果有任何建议或想法,我将不胜感激。 谢谢!
<script>alert('This is an annoying message.');</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
...etc...
最佳答案
实际上,@run-at document-start
确实在页面中的任何内容之前几乎运行了 GM 脚本。
在您的情况下,以下代码将与 @run-at document-start
结合使用:
_oldAlert = alert;
unsafeWindow.alert = function () {};
/*-- Optionally, wait for the DOM, then set an onload handler to restore
alert().
*/
关于javascript - 如何让 Greasemonkey 在页面中*任何其他*之前运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/708136/