如何实现一个命令,所以当firefox-addon被卸载时执行? [英] How to implement a command, so it is executed when the firefox-addon is uninstalled?

查看:105
本文介绍了如何实现一个命令,所以当firefox-addon被卸载时执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用附加SDK创建了一个Firefox插件。

我的脚本增加了一些东西给firefox,这在这里没关系。如何实现在卸载和禁用时调用的函数的步骤?



我读了此代码示例文章这个 本手册,但没有管理它,似乎并没有工作,或者我缺乏信息在哪里添加这个,还有什么我必须围绕它编程。



另外手册似乎已经过时了,原因当我从那里添加代码并编译它时:

  cfx xpi 

我得到警告,我应该使用 const {Cu} = require(chrome); 代替组件 Object - ,但仍然无法执行卸载命令。



我是否需要将它全部写入main.js文件?或者我需要一个额外的unistall文件被称为?



你可以给一个运行的例子来说明如何实现这个?

main.js 中,使用 exports.onUnload



所以,在 main.js ;

  exports.onUnload = function(reason){
//在附加元件被调用时调用
//卸载
//禁用
//关闭
//升级
//降级
};


I created a Firefox add-on with the Add-on SDK.

My script adds something to firefox, which doesn't matter here. How are the steps to implement a function that is called on uninstall and on disabling?

I read this Code Samples article, this, this and this manual and this Answer, but didn't manage it, it doesn't seem to work or I am lacking of information where to add this and what else I have to program around it.

Also the manual seems to be outdated, cause When I add code from there and compile it with:

cfx xpi

I get warnings, that I should use const {Cu} = require("chrome"); instead of the Components Object - Which i did then and compiled without error, but still, I couldnt get a command to be executed on uninstall yet.

Do I need to write it all in the main.js file? Or do I need an extra unistall file that is called?

Can you give a running example on how to implement this?

解决方案

In main.js, use exports.onUnload.

So, in main.js;

exports.onUnload = function(reason) {
    //called when add-on is 
    //    uninstalled
    //    disabled
    //    shutdown
    //    upgraded
    //    downgraded
};

这篇关于如何实现一个命令,所以当firefox-addon被卸载时执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆