2

I'm trying to write an Addon for Firefox. For this I'm using the Mozilla "Addon-SDK".

When i use the "jpm run" function all works well. But as soon as i package it to an xpi and install it, the icon wont show up in the toolbar. This seems to be a bug in the SDK.
I have tried various workaround solutions from other blog posts.

  • Editing package.json
  • renaming to "icon"
  • moving to data
  • Moving the icon to root
  • Absolute paths
  • editing the firefox version in rdf
  • debuging Index.js...

Here the most useful:

Firefox add-on : extension icon not showing
https://github.com/mozilla-jetpack/jpm/issues/197

Since Firefox 43 addons must be verifyed. I did this. I also disabled the function in about:config so i could try new versions faster. Still no luck.

Here is my code in index.js: Edited according to answer but still not working

    var button = buttons.ActionButton(
    {
      id: "MorastLink",
      label: "In den Morast",
      icon:
      {
        "16": "./images/icon16.png",
        "32": "./images/icon32.png",
        "64": "./images/icon64.png"
      },
    onClick: CopyToMorast
    });  

Here I also tried, moving the path, changing names, using absolute path...

And this is my package.json

    {
      "title": "Morast",
      "name": "morastaddon",
      "version": "0.1.4",
      "description": "An Addon to insert a \"Add to Morast\" button on distributer sites.",
      "main": "index.js",
      "author": "Lisa Austen",
      "icon": "ressource://@morastaddon/data/images/icon16.png",
      "icon64": "ressource://@morastaddon/data/images/icon64.png",
      "engines": {
      "firefox": ">=38.0a1",
      "fennec": ">=38.0a1" },
      "license": "MIT",
      "keywords": [
      "jetpack"
    ]
    }

https://github.com/LAusten/MorastAddon.git

4

1 回答 1

1

根据MDN,图标路径必须相对于data文件夹:

  • 作为资源:// URL 指向附加组件的“数据”目录中的图标文件,通常使用 self.data.url(iconfile) 构建

  • 作为相对路径:格式为“./iconfile”的字符串,其中“iconfile”是图标文件的相对路径,起始于插件的“data”目录

例子:

  icon:
  {
    "16": "./images/icon16.png",
    "32": "./images/icon32.png",
    "64": "./images/icon64.png"
  }
于 2016-01-14T00:41:17.327 回答