How to listen to uninstallation event in javascript from a chrome extension?

倾然丶 夕夏残阳落幕 提交于 2019-12-02 04:38:10

问题


I'm trying to clean some preferences files when a user uninstall my extension from chrome browser.

On google website, http://code.google.com/chrome/extensions/external_extensions.html

They say, "To uninstall your extension (for example, if your software is uninstalled), remove the metadata from the preferences file or registry. "

I would really like to do that but how do my extension listens to the 'uninstall event', if it exists. I didn't find this event anywhere.

Please help.


回答1:


What they mean by that paragraph is if you are uninstalling your software that was bundled with the extension, you should manually uninstall the extension as well by removing registry entries.

There is an uninstall event:

chrome.management.onUninstalled.addListener(function(string id) {...});

It would work for listening to other extensions being uninstalled, but catching your own uninstall with it most likely would not be possible.




回答2:


You may use "setUninstallURL" method. Once your extension is being uninstalled, it will open specified URL so that you can do something on your server.

https://developer.chrome.com/extensions/runtime#method-setUninstallURL



来源:https://stackoverflow.com/questions/5888760/how-to-listen-to-uninstallation-event-in-javascript-from-a-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!