简体   繁体   English

Google Chrome扩展程序如何退出自己的后台进程?

[英]How can a Google Chrome extension exit its own background process?

My goal is very simple: when the user installs the extension, open the options page. 我的目标很简单:当用户安装扩展程序时,打开选项页面。

The only way I know how to do that is to create a background page, and on that page check for localStorage.setup. 我知道如何做的唯一方法是创建一个后台页面,并在该页面上检查localStorage.setup。 If it is not present, set it to true and open the options page. 如果不存在,请将其设置为true并打开选项页面。 This approach works, but, besides being convoluted, it's inefficient. 这种方法有效,但除了令人费解之外,效率也很低。 Not only will the background page load every time the user opens the browser, but it will constantly be running in the background. 每次用户打开浏览器时,后台页面不仅会加载,而且会在后台持续运行。

Is there any way to tell chrome the background page is finished, and should be exited? 有没有办法告诉chrome后台页面已经完成,应该退出? Or is there any way for an extension's background page to prevent itself from being loaded in the future? 或者,扩展程序的后台页面是否有任何方法可以防止将来加载? Or, is there a better way to solve my problem? 或者,有没有更好的方法来解决我的问题?

With transient background pages , the background page will exit automatically once all code that it's running finishes. 使用瞬态背景页面 ,一旦所有运行的代码完成,后台页面将自动退出。 This feature will be in a future Chrome release, but since it's still under active development, there isn't documentation for it yet. 此功能将在未来的Chrome版本中发布,但由于它仍在积极开发中,因此还没有相关文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM