Firefox addon - icon not showing

那年仲夏 提交于 2019-12-24 00:57:14

问题


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


回答1:


According to MDN, the icon path has to be relative to the data folder:

  • as a resource:// URL pointing at an icon file in your add-on's "data" directory, typically constructed using self.data.url(iconfile)

  • as a relative path: a string in the form "./iconfile", where "iconfile" is a relative path to the icon file beginning in your add-on's "data" directory

Example:

  icon:
  {
    "16": "./images/icon16.png",
    "32": "./images/icon32.png",
    "64": "./images/icon64.png"
  }


来源:https://stackoverflow.com/questions/34768273/firefox-addon-icon-not-showing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!