如何实现一个命令,所以当firefox-addon被卸载时执行? [英] How to implement a command, so it is executed when the firefox-addon is uninstalled?
问题描述
我使用附加SDK创建了一个Firefox插件。
我的脚本增加了一些东西给firefox,这在这里没关系。如何实现在卸载和禁用时调用的函数的步骤?
我读了此代码示例文章,这个, 和本手册和,但没有管理它,似乎并没有工作,或者我缺乏信息在哪里添加这个,还有什么我必须围绕它编程。
另外手册似乎已经过时了,原因当我从那里添加代码并编译它时:
cfx xpi
我得到警告,我应该使用 const {Cu} = require(chrome);
代替组件
Object - ,但仍然无法执行卸载命令。
我是否需要将它全部写入main.js文件?或者我需要一个额外的unistall文件被称为?
你可以给一个运行的例子来说明如何实现这个?
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屋!