我制作了一个未打包的可用 Chrome 扩展程序,它只是我计算机上的一个目录。我发现我应该能够很容易地将它移植到 Firefox。
我按照 MDN 上的“移植 Google Chrome 扩展”指南,发现我的清单文件非常完美。
然后我按照有关如何执行扩展的“在 Firefox 中的临时安装”的说明进行操作。
但是,当我单击目录中的任何文件时,什么也没有发生。扩展不加载。有什么建议吗?我知道该扩展程序在 Chrome 中运行良好,并且加载时不会出错。
清单.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();
背景.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 上加载它时,它不会做任何事情;什么都不会发生。