How do I run code on DOM ready in Greasemonkey 4?
问题 With the update to Firefox 57 and Greasemonkey 4 a number of my userscripts broke. In some scripts I used: document.addEventListener('DOMContentLoaded', doStuff, false); This no longer works in Greasemonkey. What is the proper way to add an DOMContentLoaded event now? P.S. I checked that at the time of registering the event, DOM is still not ready. 回答1: I ran into a similar problem after GreaseMonkey upgraded to version 4, but I used addEventListener("DOMContentLoaded", function(){ // … });