gpt4 book ai didi

firefox-addon - 卸载firefox插件时如何在浏览器中打开页面

转载 作者:行者123 更新时间:2023-12-02 05:10:03 24 4
gpt4 key购买 nike

我想在用户卸载插件时打开链接,因此为此我必须编写代码以及在哪个事件下。

如果有人知道这件事,请帮助我。

目前这就是我在卸载时正在做的事情。但是 gBrowser.addTab(Website + 'uninstalled=true&token=' + uniqueguid); 在这里不起作用。

var UninstallObserver = {
_uninstall : false,
observe : function(subject, topic, data) {

//===Write Code here for Delete File Uninsatll Time
//alert("Uninstall Time Delete File");
var Filename = "webmail";
// Delete all template file.

try{
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var finished = "";
pref.setBoolPref("myextension.install.just_installed", false);
}
catch(e) {}


gBrowser.addTab(Website + 'uninstalled=true&token=' + uniqueguid);
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);

file.initWithPath(Components.classes["@mozilla.org/file/directory_service;1"].getService( Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile).path+"\\DefaultTemplate.txt");
if ( file.exists() == true )
{
var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance();
if (aFile instanceof Components.interfaces.nsILocalFile)
{
aFile.initWithPath(Components.classes["@mozilla.org/file/directory_service;1"].getService( Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile).path + "\\DefaultTemplate.txt");
aFile.remove(false);
}
}
//=======
if (topic == "em-action-requested") {
subject.QueryInterface(Components.interfaces.nsIUpdateItem);

if (subject.id == MY_EXTENSION_UUID)
{

if (data == "item-uninstalled")
{
//==Delete File Whenever Uninstall
//alert("When Uninatall");
//===========
data = "item-cancel-action";
this._uninstall = true;
}

if (data == "disabled")
{
// alert("You are not allow to disable SysLocker.");
this._uninstall = true;
}

else if (data == "item-cancel-action")
{
this._uninstall = false;
}
}
}
else if (topic == "quit-application-granted")
{

data = "item-cancel-action";
if (this._uninstall)
{
//Code here to delete registry
}
this.unregister();
}
},

register : function() {

var observerService =
Components.classes["@mozilla.org/observer-service;1"].
getService(Components.interfaces.nsIObserverService);

observerService.addObserver(this, "em-action-requested", false);
observerService.addObserver(this, "quit-application-granted", false);

},

unregister : function() {

var observerService =
Components.classes["@mozilla.org/observer-service;1"].
getService(Components.interfaces.nsIObserverService);

observerService.removeObserver(this,"em-action-requested");
observerService.removeObserver(this,"quit-application-granted");
}

}

谢谢

最佳答案

0) 这是什么类型的扩展?我认为这是需要重新启动的常规扩展; bootstrapped (restartless) extensions have their own uninstall notification .

1) 根据 MDC docsem-action-requested 通知在 Firefox 4+ 中被替换为不同的通知,您是使用 Firefox 4 还是 3.6 进行测试?

2) gBrowser.addTab 到底是怎么“不在这里工作”的?代码是否达到了这一点?您在 Error Console 中收到任何消息吗? (请参阅该页面以获取设置提示)?如果将代码放在 XPCOM 组件中(这是正确的),则首先必须获得对浏览器窗口的引用。参见 Working with windows in chrome code .

关于firefox-addon - 卸载firefox插件时如何在浏览器中打开页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6678423/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com