检测Chrome浏览器是否启用了扩展程序 [英] Detect if extension is enabled on Chrome browser

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

问题描述

我正在为Wordpress写一个小插件,我需要检测一个chrome扩展是否为已启用。



目前我能够检测到扩展名仅通过连接到其中一个资源来安装,但是,我需要检测安装是已启用还是已禁用。

这是可能的吗? ?



感谢您的宝贵时间。

解决方案

选项。


  1. 创建自己的扩展,声明管理权限,然后向您的插件报告获得 [getAll] [1] 的结果,然后检查启用/禁用的ExtensionInfo状态。

  2. 更改您感兴趣的扩展,以某种方式更改页面的DOM,以使插件可以检测到该扩展。例如,添加一个ID为yes-the-plugin-is-install的不可见div。

  3. 如果您无法控制扩展名并且不想自己写然后找出扩展如何改变页面的行为或结构,并在您的插件中编写代码来检测它。这种方法当然是脆弱的,但它不依赖于任何扩展代码。

如果你正在寻找对于任意网页如何检测任意扩展的一般答案,没有这样的方法。这有两个原因。首先,Chrome(与大多数其他网络浏览器一样)通常避免将此类专有扩展功能用于开放网络,而您要求的正是这种方式 - 正常网页询问Chrome扩展的一种特殊方法。其次,由于隐私原因,Chrome浏览器不会为扩展程序或网页提供非特权方法来查询用户安装了哪些扩展程序。你可能会在你的机器上安装尴尬的足部真菌预防扩展,如果随机的网页可以了解你的话,这将会令人不安。


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.

解决方案

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.

这篇关于检测Chrome浏览器是否启用了扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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