【发布时间】:2016-08-11 18:37:37
【问题描述】:
我制作了一个未打包的可用 Chrome 扩展程序,它只是我计算机上的一个目录。我发现我should be able to port this to Firefox rather easily。
我按照 MDN 上的“Porting a Google Chrome extension”指南,发现我的清单文件是完美的。
然后我按照说明如何执行扩展的“Temporary Installation in Firefox”。
但是,当我单击目录中的任何文件时,什么都没有发生。扩展不加载。有什么建议吗?我知道该扩展程序在 Chrome 中运行良好,并且加载时不会出错。
manifest.json:
{
"manifest_version": 2,
"name": "ER",
"description": "P",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"background": {
"scripts": [ "background.js" ]
},
"content_scripts": [
{
"matches": [ "SiteIwant" ],
"js": [ "ChromeFormFill.js" ],
"run_at": "document_idle"
}
],
"permissions": [
"*://*/*",
"cookies",
"activeTab",
"tabs",
"https://ajax.googleapis.com/"
],
"externally_connectable": {
"matches": ["SiteIwant"]
}
}
ChromeFormFill.js:
// JavaScript source c
console.log("inside content");
console.log(chrome.runtime.id);
document.getElementById("ID").value = chrome.runtime.id.toString();
Background.js
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
if (request.data === "info") {
console.log("Recieving Info");
return true;
}
});
chrome.tabs.create(
{
url: 'myUrl'
active: true
}, function (tab) {
chrome.tabs.executeScript(tab.id, { file: 'Run.js', runAt: "document_idle" });
});
Run.js 将只是 alert('hi')。
当我尝试在 Firefox 上加载它时它不会做任何事情;什么都不会发生。
【问题讨论】:
-
如果没有 manifest.json 中的 "applications" key,它将无法在 48 岁之前的 Firefox 中运行。
-
我在 Firefox 上完全更新了。 @wOxxOm
-
清单声明了
background.js,但在随后的引用中它被命名为Background.js。虽然 Chrome 在 Windows 上不区分大小写,但 Firefox 可能会更严格。 -
什么也没试过。我什至制作了一个只有基本清单的目录并尝试移植,没有加载。没有任何迹象表明清单已被读取
标签: javascript google-chrome firefox google-chrome-extension firefox-addon-webextensions