2
我想運行chrome.tabs.executeScript來運行存儲在遠程服務器上的文件(出於測試目的,該服務器是本地主機)。這裏是我到目前爲止的代碼:chome.tabs.executeScript從外部文件?我需要在manifest.json中更改哪些權限?
chrome.tabs.executeScript(tabId, {file: 'http://localhost/js/myTestFile.js'}, function() {
//Do some stuff on completion
});
我知道,在默認情況下,程序注入的內容腳本不能從遠程位置源,但可以通過「白名單」的清單某些來源改變這種狀況。這是我目前的清單:
//Extensions Permissions
"permissions": [
"activeTab",
"notifications",
],
//External access permissions
"externally_connectable": {
"matches": [
"http://localhost/*",
]
}
//Directories available to the extension
"web_accessible_resources": [
"js/*",
"html/*",
"img/*"
],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["js/lib/require-2.1.8.min.js", "js/extension/contentManager.js"],
"all_frames": true
}
],
以什麼方式可以修改清單以允許將遠程JS文件作爲內容腳本注入?