如何从 chrome 扩展监听 javascript 中的卸载事件?
当用户从 Chrome 浏览器卸载我的扩展程序时,我试图清理一些首选项文件。
在 Google 网站上,http://code.google.com/chrome/extensions/external_extensions.html
他们说,“要卸载您的扩展(例如,如果您的软件被卸载),请从首选项文件或注册表中删除元数据。”
我真的很想这样做,但是如何我的扩展是否监听“卸载事件”(如果存在)。我在任何地方都没有找到这个活动。
请帮忙。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用“setUninstallURL”方法。卸载扩展程序后,它将打开指定的 URL,以便您可以在服务器上执行某些操作。
https://developer.chrome.com/extensions/runtime#method-setUninstallURL
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
该段落的意思是,如果您要卸载与扩展程序捆绑在一起的软件,则还应该通过删除注册表项来手动卸载扩展程序。
有一个卸载事件:
它可以用于监听到正在卸载的其他扩展,但很可能无法捕获您自己的卸载。
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:
It would work for listening to other extensions being uninstalled, but catching your own uninstall with it most likely would not be possible.