检查是否安装了chrome扩展程序 [英] Check is chrome extensions installed
问题描述
我在Chrome网上应用店中发布了Chrome扩展程序.
I have Chrome extension published on Chrome web store.
现在,我想从我网站上的页面实施内联安装.
Now I want to implement Inline installation from page on my website.
我一直在关注 Chrome教程.
所以我将我的网站添加为我的Chrome扩展程序的经过验证的网站,并且内联安装工作正常.
So I added my website as verified site for my Chrome extension and inline installation is working fine.
我要解决的问题是如何检查用户是否已经安装了我的扩展程序.
The issue which I have is how to check does user already have my extension installed.
我要首先检查用户是否安装了扩展程序,如果没有安装,请不要显示安装按钮,否则请显示它.
I want to first check does user have extension installed and if so don't show installation button and otherwise to show it.
在用于内联安装的chrome教程中,有说明如何检查扩展名通过检查chrome.app.isInstalled
In chrome tutorial for inline installation there is explanation how to check is extension already installed by checking chrome.app.isInstalled
但是,即使安装了扩展程序,它始终返回 false .
我找不到使用此属性的任何详细说明.我想知道它如何得出我正在检查的扩展名?它是从head
中的chrome <link>
得出结论的吗?
But this is always returning false, even if extension is installed.
I cannot find any detail explanation of using this property. I am wondering how it even conclude which extension I am checking? Does it conclude from chrome <link>
in head
:
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/itemID">
任何帮助,如何正确检查用户是否安装了我的扩展程序?
Any help, how properly to check does user have my extension installed or not?
推荐答案
我在YouTube上看到了一个安全视频,我现在没有链接了,但是我认为这是DefCon的演讲,或者类似的东西……它显示如果 manifest.json
中.这可能不是一件好事...
I saw a security video on YouTube, I don't have a link anymore, but I think it was a DefCon talk, or something... it shows how Chrome allows access to extension resources from a browser URL if the resource is included in the extension list of web_accessible_resources
in the manifest.json
. This probably isn't a good thing...
因此,您可以:
- 创建一个图像,上面写着该扩展名已安装且处于活动状态.
- 将此图像添加到您的扩展程序中,并将其包括在
web_accessible_resources
列表下的manifest.json
中. -
然后在您的网页上链接到它.只有在安装扩展程序并启用后,该图像才可见.
- Create an image that says something like the extension is installed and active.
- Add this image to your extension, and include it in the
manifest.json
under theweb_accessible_resources
list. Then link to it on your webpage. The image will only be visible if the extension is installed and enabled.
<img src="chrome-extension://{extension-id}/extension-enabled.png">
使用javascript检查并查看图像是否已加载.如果没有,请用显示扩展名已禁用或未安装的URL替换.
Use javascript to check and see if the image loaded. If it didn't, replace it with a url showing that the extension is disabled or not-installed.
这篇关于检查是否安装了chrome扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!