JavaScript检查浏览器扩展是否安装了Chrome,Firefox和Opera [英] JavaScript check if browser extension is installed for Chrome, Firefox and Opera
问题描述
我想在我们的网站上显示自定义栏(通知如:安装我们的插件)如果未安装扩展程序,Chrome,Firefox和Opera。如果安装了扩展程序,则不会显示任何内容。
这个想法是:
1.用户访问我们的网站出现消息栏 - 安装我们的扩展。
2.用户点击安装和扩展安装。无需用户打开它。
3.用户再次访问我们的网站,酒吧不会再出现,因为扩展安装。
我们谈仅用于安装检查,而不是Cookie 。
到目前为止,我只能找到Chrome的解决方案: http://blog.kotowicz.net/2012/02/intro-to-chrome-addons-hacking。 html 有没有办法做到这一点歌剧,基于检查本地资源是扩展的一部分的想法: 或其他: (或其中的任何变化) 扩展名可以做 然后你可以检测到扩展名 扩展名可以是 然后您可以通过 或者,您可以 和扩展名将会做 或者您可以做 以及扩展名将会做 The idea is: So far I was able to find solutions only for Chrome: http://blog.kotowicz.net/2012/02/intro-to-chrome-addons-hacking.html Is there a way to do it for Opera, based on the idea of checking for a local resource which is part of the extension: Or else:
Is there a simple way to check if extension is installed for Chrome, Firefox and Opera? If the extension is willing to cooperate, it could advertise its presence to the document easily. For example: Then you can detect the extension by (or any variation thereof)
Obtaining the page The extension could do Then you could detect the extension by
The extension could do then you could detect the extension by
alternatively, you could do and the extension would do
or you could do and the extension would do
这篇关于JavaScript检查浏览器扩展是否安装了Chrome,Firefox和Opera的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
和Firefox: http:// webdevwonders。
Opera从未被提及。
chrome-extension:// - 扩展名ID - / blank.gif
Firefox Firefox://firebug/content/blank.gif
是否有一个简单的方法来检查扩展名是安装如果扩展程序愿意合作,它可以宣传它的存在,如Chrome浏览器,Firefox和Opera?到文件很容易。例如:
扩展名可以是
window。$$ myExt = ...
<那么你可以通过检测扩展名
pre $ if(typeOf $$ myExt!=='undefined'){...
$ b
$ b $ pre $ $ $ $ $ document.body.classList.add(myExt-visited)
if(document.body.classList.contains(myExt-visited)){...
document.body.innerHTML + =< div ID ='MYEX t-toolbar'> ...
//或$('body')。append(< div id ='myExt-toolbar'> ...);
<$如果(document.getElementByID(myExt-toolbar)){...
//或if($(#myExt-toolbar)。 ..
< div id =myExt-replacement>
...
var replacement = document.getElementByID(myExt-replacement);
替换&& replacement.remove();
function onMyExtExists(){
...
}
$ b $ pre $ onMyExtExists&& onMyExtExists();
I want to show custom bar ( notification like: Install our plugin. ) on our site if extension is not installed for Chrome, Firefox and Opera. None will be displayed if extension is installed.
1. User visits our site and a bar with message appears - "Hey, install our extensions".
2. User clicks on install and extension is installed. No need for the user to open it.
3. User visit our site again and the bar does not appear again as the extension is installed.
We talk only for installation check, not cookies.
and Firefox: http://webdevwonders.com/detecting-firefox-add-ons/
Opera is never mentioned.
chrome-extension://--Extension ID--/blank.gif
Firefox chrome://firebug/content/blank.gif
The extension could dowindow.$$myExt = ...
if(typeOf $$myExt !== 'undefined'){...
window
is somewhat tricky at least
document.body.classList.add("myExt-visited")
if(document.body.classList.contains("myExt-visited")){...
document.body.innerHTML += "<div id='myExt-toolbar'>..."
// or $('body').append("<div id='myExt-toolbar'>...");
if(document.getElementByID("myExt-toolbar")){...
// or if($("#myExt-toolbar").length){...
<div id="myExt-replacement">
...
var replacement = document.getElementByID("myExt-replacement");
replacement && replacement.remove();
function onMyExtExists(){
...
}
onMyExtExists && onMyExtExists();