【发布时间】:2014-11-03 09:37:37
【问题描述】:
我有一个 Firefox 附加组件,它是一个基于覆盖的扩展,可在 Firefox 版本高达 31 中运行。但它不适用于 32 及更高版本。我通常使用Userscript Compiler 工具来构建我的扩展。我在扩展程序的控制台中看不到任何内容(错误/输出)。
虽然当我使用 Greasemonkey 插件运行我的脚本时,它工作正常。问题是在将扩展构建为 XPI 文件后运行扩展。
下面是我的扩展结构:
myextension
|-->skin
|-->classic
|-->content
|-->myscript.user.js
|-->myscriptPrefman.js
|-->myscriptScript-compiler.js
|-->myscriptXmlhttprequester.js
|-->script-compiler-overlay.xul
|-->chrome
|-->install.rdf
|-->icon.png
|-->chrome.manifest
下面是install.rdf文件内容:
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>{9ef9b86c-03da-4e10-9552-e97a6d258af5}</em:id>
<em:name>Sample Extension</em:name>
<em:version>2.6</em:version>
<em:description>A sample extension - Firefox</em:description>
<em:creator>Mozdev</em:creator>
<em:contributor>Greasemonkey Compiler by Anthony Lieuallen;</em:contributor>
<em:contributor>http://arantius.com/</em:contributor>
<em:homepageURL>www.example.com</em:homepageURL>
<em:targetApplication><Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>2.0</em:minVersion>
<em:maxVersion>35.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>
chrome.manifest内容:
content myextension content/
overlay chrome://browser/content/browser.xul chrome://myextension/content/script-compiler-overlay.xul
skin myextension classic/1.0 skin/classic/
我是否需要更改扩展中的任何内容或将其转换为 Bootstrap 扩展或使用附加 SDK 来构建 XPI 文件?
更新:
我已关注the Add-on SDK method suggested by Wladimir 并创建了一个 XPI 安装程序文件。但是用户脚本没有在页面内运行。
代码仍然从 Greasemonkey 插件运行。
This is the Greasemonkey script 在 Greasemonkey 中运行良好,但在通过编译器和 SDK 进行扩展时就不行了。
我在我的本地机器上使用了 steps to install 附加 SDK。我使用cfx 命令构建XPI 文件。我在 Firefox 最新版本(ver.33.0.2)中安装它并访问 openuserjs.org 我什么也看不到。这是为什么呢?
【问题讨论】:
-
@BrockAdams 我不希望我的扩展程序发布在 AMO 或 userscripts.org 上……而且 userscrits.org 已经关闭……所以我无法尝试在您的答案中找到解决方案您标记为重复的其他问题..
-
然后使用第二个答案(Wladimir's),它显示了使用 addon-SDK 将您的 GM 脚本转换为扩展的关键部分。
-
@BrockAdams 我已经通过使用 Addon-SDK 构建插件尝试了另一种解决方案,但它不起作用..我使用
pageModapi 来修改准备好的页面..你可以看看有什么问题。并重新提出问题? -
好的,问题现在已经足够不同了。除非您可以让 Arantius 对其进行更新,否则编译器是无用的。要使用 SDK 方法,您还需要为您使用的
GM_函数提供填充程序。
标签: firefox-addon greasemonkey xpi