在一个网页中,我怎样才能检测到一个特定的扩展在浏览器中加载? [英] In a webpage, how can I detect that a particular extension is loaded in a browser?

查看:422
本文介绍了在一个网页中,我怎样才能检测到一个特定的扩展在浏览器中加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

扩展名是: adblock plus adBlock 断开连接等等...



我不熟悉所有扩展及其对DOM的影响(除了 adblock plus ),所以我正在寻找一个函数这将检查扩展名是否存在于浏览器?



我试过:

  var detect = function(base,if_installed,if_not_installed){
var s = document.createElement('script');
s.onerror = if_not_installed;
s.onload = if_installed;
document.body.appendChild(s);
s.src = base +'/manifest.json';

detect('chrome-extension://'+'gcbommkclmclpchllfjekcdonpmejbdp',function(){alert('boom!');});

我从哪得到: http://blog.kotowicz.net/2012/02/intro-to-chrome-addons-hacking.html ,他说,它的工作,但我得到这个错误:


资源必须列在web_accessible_resources清单键
中被加载的扩展名以外的页面。


解决方案

该扩展可能会更改HTML标头或者至少是DOM中的东西。所以找出可能的变化,并检测使用JS。

如果这样做不好,请看这里。

检查用户是否安装了Chrome扩展程序


I was asked to display a pop-up to the user if he has at least 1 out of 5 extensions.

The extensions are: adblock plus,adBlock,Disconnect and etc...

I am not familiar with all the extensions and their affect on the DOM (except for adblock plus) so I am looking for a function that will check by the extension id if it exist in the browser?

I tried:

var detect = function(base, if_installed, if_not_installed) {
    var s = document.createElement('script');
    s.onerror = if_not_installed;
    s.onload = if_installed;
    document.body.appendChild(s);
    s.src = base + '/manifest.json';
}
detect('chrome-extension://' + 'gcbommkclmclpchllfjekcdonpmejbdp', function() {alert('boom!');});

Which I got from:http://blog.kotowicz.net/2012/02/intro-to-chrome-addons-hacking.html, He says it works, but I got this error:

Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

解决方案

That extension probably makes changes to the HTML headers or at least something in the DOM. So figure out what that change might be and detect that using JS.

If that is no good, take a look here.
Check whether user has a Chrome extension installed

这篇关于在一个网页中,我怎样才能检测到一个特定的扩展在浏览器中加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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