Changing Firefox addon install icon

喜欢而已 提交于 2019-12-22 04:55:15

问题


I'm working on developing a Firefox add-on using the Add-on SDK. I changed my package.json file to include entries for a 32x32 icon and a 64x64 icon.

{
    ...
    "icon": "icons/icon-32.png",
    "icon64": "icons/icon-64.png",
    ...
}

Furthermore, I placed icon-32.png and icon-64.png in the directory icons inside my package directory before running cfx xpi inside the package directory.

The icons correctly display in the addon manager from Tools > Add-ons, but the installation dialog still uses a puzzle piece icon.

I am self-hosting the Firefox add-on.

At first, I thought it might be because I wasn't yet signing the xpi file, but I noticed that there are many other add-ons that are not signed but still have the correct icon in the installation dialog.

I also thought that it might be because the icon wasn't located in the right place within the xpi file or perhaps that the install.rdf wasn't correctly generated by the add-on SDK, but I unzipped the xpi and found that cfx had put the icons in the root directory and renamed them to the default names (icon.png and icon64.png) and had omitted the filenames in the install.rdf (pointing them to the default icons).

How can I change the installation icon?

Can installation icons only be changed when hosting with Firefox?


回答1:


The installation dialog doesn't take the icon from the package, it uses the information supplied by the web page. Your web page needs to use InstallTrigger to start the installation, along these lines:

function install(link)
{
  params = {};
  params[link.getAttribute("addonName")] = {
    URL: link.href,
    IconURL: link.getAttribute("iconURL")
  };
  InstallTrigger.install(params);
}

And your link would look like this:

<a href="foo.xpi" addonName="Foo" iconURL="foo.png"
   onclick="install(this); return false;">
  Install
</a>

Note that it still has to be a link - if the user has JavaScript disabled your install() function will not be called. The user will simply follow the link instead and installation will start regardless.



来源:https://stackoverflow.com/questions/9207033/changing-firefox-addon-install-icon

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