In Firefox and Safari i managed to register the DOMContentLoaded event with window.addEventListener(\'DOMContentLoaded\', PageShowHandler, false); by insert
If you add "run_at":"document_start"
flag to content scripts in the manifest they will be injected before DOM is constructed, so DOMContentLoaded
should be triggered every time:
"content_scripts": [
{
"matches": ["*://*.google.mail.com/*", "https://*.google.mail.com/*" ,"http://mail.google.com/*" ,"https://mail.google.com/*", "https://www.google.com/*", "http://www.google.com/*", "file:///*"],
"css": ["toggle.css"],
"js": ["jquery-1.4.4.min.js", "inject.js"],
"run_at": "document_start"
}
],
(more about execution order here)
I managed to get things working by using the DOMFocusIn event in my injected script. This event correctly mimics the trigger behavior that DOMContentLoaded achieves in Firefox and Safari.
window.addEventListener('DOMFocusIn', PageShowHandler, false);
This doesn't work properly if i don't set to true the "all_frames" field in "contents_scripts":
{
"name" : "gMail Adder ",
"version" : "1.0",
"description" : "Google Chrome Gmail Adder",
"options_page": "options.html",
"background_page": "background.html",
"run_at": "document_start",
"permissions": [
"tabs",
"history",
"http://*/*",
"https://*/*"
],
"content_scripts": [
{
"matches": ["*://*.google.mail.com/*", "https://*.google.mail.com/*" ,"http://mail.google.com/*" ,"https://mail.google.com/*", "https://www.google.com/*", "http://www.google.com/*", "file:///*"],
"css": ["toggle.css"],
"js": ["jquery-1.4.4.min.js", "inject.js"],
"all_frames" : true
}
],
"browser_action" : {
"default_icon" : "Quest Icon 11.png",
"default_popup": "dialog.html"
}
}