簡體   English   中英

Google.com和DOMContentLoaded

[英]Google.com and DOMContentLoaded

我使用content_scripts中的以下代碼測試了我的Google Chrome擴展程序:

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


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

表現:

{
    "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"
    }]
}

所有的網頁,如Facebook或微軟都可以。加載頁面后,會彈出一個警告框,除了“Google.com”=>我訪問了Google.com但沒有警告框。 我想知道為什么除了Google.com之外幾乎沒有頁面好嗎? 那么,我需要在Google.com加載后捕獲哪個DOM事件?

謝謝

Google始終使用https ,您的腳本不會注入任何https網站,因為您只定位http網站(在您的清單中,您有: "matches": [ "http://*/*" ], )。

將您的清單更改為"matches": [ "http://*/*", "https://*/*" ],"matches": [ "<all_urls>" ], .

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM