My Firefox add-on won't show when I install it

时间:2015-09-30 23:21:50

标签: firefox-addon

So, I'm utterly and completely new to making Firefox add-ons. I have been trying to make a really, really simple one which will run some JavaScript on the page when I click it. That's literally all I want it to do -_-
However, it will install when I drag it into FF/Nightly, but then not show up in the customise menu. It will say it's installed, but that's it. (I also can't open its preferences, but, I'm really not complaining - I just want a really basic add-on).

If you need the code/entire XPI itself, I'm happy to supply. Thank you :)

I am using the following directories and files:

.
├── chrome
│   ├── chrome.manifest
│   ├── content
│   │   ├── boustrophedonise.js
│   │   ├── browser.xul
│   │   └── prefrences.xul
│   ├── locale
│   │   └── en-UK
│   │       └── translations.dtd
│   └── skin
│       ├── icon.png
│       └── skin.css
├── defaults
│   └── preferences
│       └── pref.js
└── install.rdf

1 个答案:

答案 0 :(得分:0)

虽然可能存在其他问题,但您的chrome.manifest文件位于错误的目录中。它需要位于根目录(与 install.rdf 文件相同的目录)中。 MDN上Setting Up the Development Environment教程的“Create a Chrome Manifest”和“Building an extension”部分都介绍了这一点。第一部分解释了您应该从一个看起来像这样的目录结构开始:

.
├── chrome
│   └── content
│       └── sample.xul (Much of your content in this directory)
├── chrome.manifest
└── install.rdf

chrome.manifest 文件是Firefox附加组件所需的文件之一。它定义了chome://myExtension/content/*指向的URL。在您的情况下,如果 chrome.manifest 文件位于根目录中,则chrome://boustrophedonise/content/options.xul install.rdf 中的网址无效,可能会抱怨在安装扩展程序时在Firefox Browser Console中(或者在显示加载项管理器时,或者单击附加选项的链接时)。 Firefox可能还抱怨缺少 chrome.manifest 文件。显然,由于Firefox无法找到 chrome.manifest 文件,因此它不会将overlay应用于chrome://browser/content/browser.xul,也不应用skin,两者都已定义在该文件中,这些内容将您的加载项挂钩到Firefox中。

因此,在您的情况下,您需要移动 chrome.manifest 文件,使其位于:

.
├── chrome
│   ├── content
│   │   ├── boustrophedonise.js
│   │   ├── browser.xul
│   │   └── prefrences.xul
│   ├── locale
│   │   └── en-UK
│   │       └── translations.dtd
│   └── skin
│       ├── icon.png
│       └── skin.css
├── chrome.manifest
├── defaults
│   └── preferences
│       └── pref.js
└── install.rdf