How to implement “DOM Ready” event in a GreaseMonkey script?

后端 未结 3 1260
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-12 14:01

I\'m trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but this event never fires.

I\'m using FireFox 2.0.0.16 / GreaseMon

3条回答
  •  忘了有多久
    2021-02-12 14:37

    So I googled greasemonkey dom ready and the first result seemed to say that the greasemonkey script is actually running at "DOM ready" so you just need to remove the onload call and run the script straight away.

    I removed the window.addEventListener ("load", function() { and }, false); wrapping and it worked perfectly. It's much more responsive this way, the page appears straight away with your script applied to it and all the unseen questions highlighted, no flicker at all. And there was much rejoicing.... yea.

提交回复
热议问题