Opera extension
To put it simple: What's the fastest way to get the head element in an injected opera extension script ? (faster than waiting for DOMContentLoaded)
I insert a bunch of styles into loaded pages, and I'm not waiting for DOMContentLoaded (because the user wants to see the rendered css when the page loads, just like an usercss).
So I just get the head eleme开发者_StackOverflow社区nt (document.getElementsByTagName("head")[0] or document.head) and insert style elements into it; this works on most websites but I recently found out that it doesn't work on wikipedia because I can't get the head element without waiting for DOMContentLoaded.
PS: I know that Opera extensions are inserted before any other script so does that mean that the head element isn't loaded when the script is inserted ? So why does it work on some sites ??
AFAIK, you can just do document.documentElement.appendChild() right away in your extension's script. The browser should sort things out just fine.
精彩评论