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

问题描述

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

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



我读了,,和和。



所以,在 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被卸载时执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 20:47