DOMContentLoadedã«å¼ã£æãã¦åæåãè¡ãå¤é¨ã¹ã¯ãªããããDOMãåºæ¥ã¦ããã¢ã¬ã¢ã¬ãã
ã ããã以ä¸ã®ãããªæãã§ãã¾ãããããããªããã¨æããã©ãã¡ããã¨ããæ¤è¨¼ã¯ãã¦ãªãã®ã§ãWebKitã§ããã¿ã¦ã¾ãããã
å¼æ°ã®targetã¯windowãdocument, scriptã¯srcãè¨å®ãããscript elementã ã¨æãããã
(â»ã¤ãã³ããã³ãã©å ã§evt.targetã¨ããåç §ãããããªã¤ãã¯ããã ã¨ãã¡ã§ã)
function hijackDOMLoaded(target, script) { var orig = target.addEventListener, callbacks = []; target.addEventListener = function(type, cb, useCapture) { if ( type === "DOMContentLoaded" ) { callbacks.push(cb); } else { orig.call(target, type, cb, useCapture); } }; script.onload = function() { target.addEventListener = orig; callbacks.forEach(function(cb) { cb(); }); }; document.body.appendChild(script); }