2014-04-18 58 views
0

我正在創建一個Chrome擴展,我必須操縱從服務器發送的原始HTML DOM,而不是生成的DOM。如何讓我的content_scripts在從服務器接收到的其他JavaScript文件運行之前運行。直到現在,我沒有發現任何有用的東西。使用Chrome擴展從服務器操作原始HTML DOM

這裏是我的清單

{ 
"manifest_version": 2, 
"name": "DOMMAN", 
"description": "DOM manip", 
"version": "0.1", 
"browser_action": { 
    "default_icon": "icon.png", 
    "default_popup": "popup.html" 
}, 
"permissions": [ 
    "tabs", 
    "http://*/", 
    "https://*/" 
], 
"content_scripts": [ { 
    "js":["jquery.min.js","back_call.js"], 
    "matches":["http://*/*","https://*/*"] 
}], 
"background": { 
    "scripts": ["background.js"] 
} 
} 

我想content_scripts其他任何事情之前運行。怎麼做?

+0

檢查content_script /清單中的 「run_at」 屬性。 –

回答

2

添加到您的manifest.json

{ 
    // other stuff 
    "content_scripts": [{ 
    "matches": ["http://*/*"], 
    "js": ["content.js"], 
    "run_at": "document_start" 
    }], 
    // other stuff 
} 

(從how can i use a chrome extension content script to inject html into a page at startup

您的代碼應該是這樣的:

"content_scripts": [ { 
    "js":["jquery.min.js","back_call.js"], 
    "matches":["http://*/*","https://*/*"], 
    "run_at": "document_start" 
}],