My Chrome plugin requires the user to be logged in to a server to send back information for generating reports. I'd like to give the user the option to either log in or disable the plugin so that it will stop asking them to log in. How can I disable the a plugin via its own Javascript?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
chrome.management.setEnabled(chrome.i18n.getMessage("@@extension_id"), false);
You can't programmatically enable it after this, of course.
回答2:
Such action should be in the decision logic. Not so much disabling the script as just not doing anything. You could have a global flag or whatnot, but completely disabling the script is not the way to go, because it can't re-enable itself at that point.