简体   繁体   中英

Google.com and DOMContentLoaded

I did test my google chrome extension with below code in content_scripts:

function test()
{
    alert("test");
}


document.addEventListener("DOMContentLoaded", test, false);

Manifest:

{
    "name": "Test",
    "version": "1.0",
    "manifest_version": 2,
    "permissions": ["contextMenus", "tabs", "http://*/*", "https://*/*"],
    "content_scripts": [{
        "all_frames": true,
        "js": [ "jquery-1.8.1.min.js","test.js"],
        "matches": [ "http://*/*" ],
        "run_at": "document_start"
    }]
}

It's okay with all webpages such as facebook or microsoft..... after page loaded, a alertbox will popup, except "Google.com" => I accessed into Google.com but there is NO alertbox. I wonder why almost pages are okay except Google.com? So, I need which DOM event to catch after Google.com loaded?

Thank you

Google is always in https , your script is not injected to any https websites since you target only http websites (in your manifest you have: "matches": [ "http://*/*" ], ).

Change your manifest to "matches": [ "http://*/*", "https://*/*" ], or "matches": [ "<all_urls>" ], .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM