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

<p>I'm using FireFox 2.0.0.16 / GreaseMonkey 0.8.20080609</p>

<p><a href="https://stackoverflow.com/questions/59205/enhancing-stackoverflow-user-experience">This</a> is the full script that I'm trying to modify, changing:</p>

<pre><code>window.addEventListener ("load", doStuff, false);
</code></pre>

<p>to</p>

<pre><code>window.addEventListener ("DOMContentLoaded", doStuff, false);
</code></pre>

[{'answer_id': 72245, 'author': 'Sam Hasler', 'author_id': 2541, 'author_profile': 'https://Stackoverflow.com/users/2541', 'pm_score': 6, 'selected': True, 'text': '<p>So I googled <a href="http://www.google.com/search?q=greasemonkey%20dom%20ready" rel="noreferrer">greasemonkey dom ready</a> and the <a href="http://www.sitepoint.com/article/beat-website-greasemonkey/" rel="noreferrer">first result</a> 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.</p>\n\n<p>I removed the  <em><code>window.addEventListener ("load", function() {</code></em> and <em><code>}, false);</code></em> wrapping and it worked perfectly. It\'s <strong>much</strong> 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.</p>\n'}, {'answer_id': 72295, 'author': 'Jonny Buchanan', 'author_id': 6760, 'author_profile': 'https://Stackoverflow.com/users/6760', 'pm_score': 4, 'selected': False, 'text': '<p>GreaseMonkey scripts are themselves executed on DOMContentLoaded, so it\'s unnecessary to add a load event handler - just have your script do whatever it needs to to immediately.</p>\n\n<p><a href="http://wiki.greasespot.net/DOMContentLoaded" rel="noreferrer">http://wiki.greasespot.net/DOMContentLoaded</a></p>\n'}, {'answer_id': 72314, 'author': 'PabloG', 'author_id': 394, 'author_profile': 'https://Stackoverflow.com/users/394', 'pm_score': 1, 'selected': False, 'text': '<p>@Sam: yeah, I was trying the same:</p>\n\n<pre><code>// ==UserScript==\n// @name           Stack Overflow highlight viewed questions\n// @namespace      *\n// @include        http://stackoverflow.com/questions\n// @include        http://stackoverflow.com/questions?*\n// @include        http://stackoverflow.com/questions\n// @include        http://stackoverflow.com/questions?*\n// @version        0.55 (DOM-Ready instead of onload)\n// ==/UserScript==\n\n(function() {\n\n    // Customizable items\n    // var fav_tags = ["python", "database", "mysql"];          // Your favorite tags\n    const UNSEEN_BACK_COLOR = "rgb(225,210,210)";     // Backcolor for the question already seen\n    const FAV_TAG_BACK_COLOR = "rgb(210,210,225)";  // Backcolor for the favorite tags\n\n    // Internal to the DOM\n    // const QUESTION_URL = "http:\\/\\/stackoverflow.com\\/questions\\/([0-9]+)\\/";\n    const QUESTION_URL = "http:\\/\\/stackoverflow.com\\/questions\\/([0-9]+)\\/";\n    const TAG_PREFIX = "show questions tagged ";\n\n    const SEEN_MARK = "x";\n    //\n\n    var seen_q = [];\n    var seen_q_str = "";\n\n    var seen_q_str = GM_getValue ("seen_q", "");\n    var seen_q = seen_q_str.split("|");\n\n    var fav_tags_str = GM_getValue ("fav_tags", "")\n    var fav_tags = fav_tags_str.split(" ")\n\n    var already_run = false;\n\n    GM_registerMenuCommand ("Set favorite tags", askTags);\n\n    // window.addEventListener ("DOMContentLoaded", doStuff, false);\n    if (! doStuff()) {\n        window.addEventListener ("load", doStuff, false);\n    }\n\n    function doStuff() {\n\n        var elements = window.document.getElementsByTagName(\'A\');\n\n        if (! elements || already_run) {\n            return false;\n        } else {\n            already_run = true;\n        }\n\n        GM_log ("here");\n\n        for (elem = 0; elem &lt; elements.length; elem++) {\n            if (elements[elem].href.match (QUESTION_URL)) {\n                curr_q = RegExp.$1;\n\n                // Already seen?\n                if ((seen_q.length &lt; curr_q) || (seen_q [curr_q] != SEEN_MARK)) {\n                    elements[elem].style.backgroundColor = UNSEEN_BACK_COLOR;\n                    seen_q [curr_q] = SEEN_MARK;\n                }\n\n                // Is a favorite tag?\n                node = elements[elem].parentNode.parentNode;\n                for (tag = 0; tag &lt;= fav_tags.length; tag++) {\n                    if (node.innerHTML.match ("\'" + fav_tags[tag] + "\'")) {\n                        node.style.backgroundColor = FAV_TAG_BACK_COLOR;\n                        break;\n                    }\n                }\n\n                // return (0);\n            }\n        }\n\n        seen_q_str = seen_q.join("|");\n        GM_setValue ("seen_q", seen_q_str);\n\n        return true;\n    }\n\n\n    function askTags() {\n        fav_tags_str = prompt("Favorite tags (separated by spaces)", fav_tags_str);\n        GM_setValue ("fav_tags", fav_tags_str)\n    }\n\n})();\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/72090', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/394/']