Detect if extension is enabled on Chrome browser

为君一笑 提交于 2019-12-12 01:52:53

问题


I am writing a small plugin for Wordpress and I need to detect whether a chrome extension is "Enabled".

At the moment I am able to detect if an extension is "Installed" only by connecting to one of its resources, However, I need to detect if the installation is "Enabled" or "Disabled"

Is this possible guys?

Thanks for your time.


回答1:


You have a few options.

  1. Make an extension of your own that declares the management permission and then reports the results of get or [getAll][1] to your plugin, then examines ExtensionInfo for the enabled/disabled state.
  2. Change the extension you're interested in to alter the page's DOM in some way that the plugin can detect. E.g., add an invisible div with ID "yes-the-plugin-is-installed."
  3. If you don't have control over the extension and don't want to write your own extension, then figure out how the extension changes the behavior or structure of the page, and write code in your plugin to detect it. This method is fragile, of course, but it doesn't rely on any extension code whatsoever to work.

If you're looking for a general answer of how an arbitrary web page can detect an arbitrary extension, there is no such method. There are two reasons this is true. First, Chrome (like most other web browsers) generally avoids making proprietary extensions of this sort to the open web, and what you're asking for is exactly that -- a special method for normal web pages to ask about Chrome extensions. Second, for privacy reasons Chrome wouldn't provide a non-privileged method for an extension or webpage to query which extensions the user has installed. You might have the Embarrassing Foot Fungus Prevention Extension installed on your machine, and it would be upsetting if random web pages could learn that about you.



来源:https://stackoverflow.com/questions/17752508/detect-if-extension-is-enabled-on-chrome-browser

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