Chrome扩展程序:如何从浏览器处理禁用和启用事件 [英] Chrome Extension : How to handle disable and enable event from browser

查看:929
本文介绍了Chrome扩展程序:如何从浏览器处理禁用和启用事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Chrome浏览器管理API(

>

Chrome浏览器管理API )的





通知扩展程序启用和禁用的更改。



确保你有

 permissions:[
management
],
code>

在您的 manifest.json中



示例演示



  chrome.management.onDisabled.addListener(function(ExtensionInfo){
conso le.log(JSON.stringify(ExtensionInfo));
});

P.S:自身的扩展无法监控何时被禁用。你需要第二个扩展来监控这个。从扩展和用户的角度来看,禁用扩展与关闭浏览器具有完全相同的效果。



有关更多信息,请参阅文档


Is there a way to run a callback after extension is disabled/enabled from chrome browser.

解决方案

Chrome management API()'s

notifies changes of enable and disable of extensions.

Ensure you have

"permissions": [
    "management"
  ],

in your manifest.json

Sample Demonstration

chrome.management.onDisabled.addListener(function(ExtensionInfo) {
    console.log(JSON.stringify(ExtensionInfo));
});

P.S : An extension on its own can't monitor when it gets disabled. You'd need a second extension to monitor this. From extension's and user's perspectives, disabling extension has exactly the same effect as closing a browser.

For more information refer documentation.

这篇关于Chrome扩展程序:如何从浏览器处理禁用和启用事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆