有没有办法以编程方式卸载Firefox扩展程序。如果是 - 是否可以从其他扩展程序执行此脚本?
答案 0 :(得分:4)
AddonManager.getAddonByID
PERM_CAN_UNINSTALL
标志,检查是否可以卸载加载项(例如,用户无法正常卸载系统范围的加载项,但可以禁用该加载项)。Addon.uninstall()
。示例代码(您可能希望添加正确的错误处理,等等):
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("some@id", function(addon) {
if (!addon) {
// Add-on not present
return;
}
if (!(addon.permissions & AddonManager.PERM_CAN_UNINSTALL)) {
// Add-on cannot be uninstalled
return;
}
addon.uninstall();
if (addon.pendingOperations & AddonManager.PENDING_UNINSTALL) {
// Need to restart to finish the uninstall.
// Might ask the user to do just that. Or not ask and just do.
// Or just wait until the browser is restarted by the user.
}
});
答案 1 :(得分:0)
还有另一种以编程方式删除扩展名的方法:您可以remove the xpi files from the firefox profile folder:
'%appdata%\ Mozilla \ Firefox \ Profiles \ * \ extensions \ extension@name.xpi
/ home / * /。mozilla/firefox/extensions/extension@name.xpi