js被adblock plus chrome拦截怎么办

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.
After searching Google and Stackoverflow for a few hours I could not find a solution.
What I'm trying to do is detect Adblock plus and display a simple message for now.
What I want to do is detect Adblock plus without using a JavaScript file or jQuery.
Most of the adblock plus detect scripts they use a file, example "show_ads.js" that is hosted on there own domain with a line it in to set it "adblock ="
The problem with using a JavaScript file, users can white list that JavaScript file and it will no longer detect it. What I'm looking for is a JavaScript that loads directly into the HTML that would detect if someone is using ad blocker without the use of a file.
Example Below:
&script type="text/javascript"&
// line of code that detects if using ad blocker
if so display message
The reason behind doing it this way no ad blocker can white list the JavaScript file on your server. Yes I know there are other methods of getting around this with NoScript addons but I already have a solution for that. I have a great idea that has never been tried and ad blockers cannot block this once I get done with it.
Any suggestions and Examples will be greatly appreciated.
You don't need to
have a plugin to detect adblock, simply use this:
&script type="text/javascript"&
var adblock =
&script type="text/javascript" src="adframe.js"&&/script&
&script type="text/javascript"&
if(adblock) {
//adblock is installed and enabled on this site :-D
Content of adframe.js:
P.S: I saw this on a website that is using this method!
5,46832150
Did you find this question interesting? Try our newsletter
Sign up for our newsletter and get our top new questions delivered to your inbox ().
Subscribed!
Success! Please click the link in the confirmation email to activate your subscription.
Use my plugin "FuckAdBlock", it can very easily detcter AdBlock:
fuckAdBlock.add(true, function() {
alert('AdBlock detected !');
}).add(false, function() {
alert('AdBlock is not detected =)');
Exemple online :
7,71842343
If you want to ads to be showing, even when AdBlock is active, you'll have to understand what AdBlock is capable to do.
AdBlock can block resources from loading
AdBlock can hide specific elements in the DOM.
Although it is said that AdBlock can also modify CSS, I can't find any documentation on that other than hiding and collapsing elements.
So what exactly could you do to be 'smarter' than AdBlock?
You could disguise your request in a way that it will never be 'matchable' (e.g. /ae9a70e0a.png, where the image name will be random every time and without a common prefix). As far as I am aware, a rule in AdBlock cannot contain a regex. A rule would either match no ads, or too many resources. It would be possible to rewrite such an url on the server to point to your ad.
However, while AdBlock might not be able to block your ad from loading, it might still be able to hide it. There is no real way of going around this. There will always be a smart CSS selector that will -just- select your element. You could however add a background-image with content. This is not useful for an ad (not clickable), but might help you display an other message. Downside is that if someone decides to block that annoying background image, it will hide your content too.
As far as a script goes, you might be able to load the ad with an ajax request. I suppose (but cannot test) that it will give an error if the resource could not be loaded (because it was blocked). ($.ajax( request ).error( function() { ... } ); in jQuery or some equivalent in regular javascript). You could use that to do something else. You could include that in the document itself, instead of an external resource, to ensure it will always run (if javascript is enabled). Even then, you cannot be sure that 'whatever else you do' will ever be visibly displayed. As last resort you can make a window.alert( ... ). Assume that within 3 pages, your visitors will never come back if you use that.
An other way I can think of, is making a websocket to the server (afaik this cannot be blocked by AdBlock). On the server side you'll need to examine if the ad pages are not loaded when a certain page is loaded. This information can be sent through the socket, which can be used in your script to do 'something'. This, however, sounds crazy complicated and is a significant overhead for 'just' a script that detects AdBlock.
8,39161638
What I've seen in the field is using a background image behind the ad. If adblock isn't active, the ad will be displayed over the background-image (which makes the background-image not viewable). If adblock is active, the ad is blocked, and the user will instead see the background-image.
&div id="ad-container"&
&img src="../ad/ad.png" id="ad"&
#ad-container {
background-image: url( /pleasedonotuseadblocker.png );
heigth: 200
width: 200
height: 200
width: 200
8,39161638
Here is the code to detect adblock. You can learn how the code works
function detect()
//create a iframe. Append the iframe to the body. And then after 100ms check if their offsetHeight, display or visibility is set such a way that user cannot see them.
//In the URL use the words specific to advertising so that Adblock can do string matching.
var iframe = document.createElement("iframe");
iframe.height = "1px";
iframe.width = "1px";
iframe.id = "ads-text-iframe";
iframe.src = "/ads.html";
document.body.appendChild(iframe);
setTimeout(function()
var iframe = document.getElementById("ads-text-iframe");
if(iframe.style.display == "none" || iframe.style.display == "hidden" || iframe.style.visibility == "hidden" || iframe.offsetHeight == 0)
alert("Adblock is blocking ads on this page");
iframe.remove();
alert("Adblock is not detecting ads on this page");
iframe.remove();
It's an arms race, for sure, and I support anyone's right to block ads, but I also support websites that depend on ad revenue trying to convince users otherwise, or perhaps persuade them to subscribe or make a donation to make up for lost ad revenue.
I don't approve of sites trying to force users to see ads, but a polite message is fine.
Anyway, right now it's worth noting that there are many adblocking extensions/plugins, and they can all have different ways of doing it, and it sometimes is different between OSes and browsers too.
I've found that for my purposes right now, this jQuery selector is enough to at least see whether AdBlock or AdBlockplus is being used, cross-platform, across at least Chrome and Firefox:
if($("div[id^=google_ads_iframe_] iframe:visible").length == 0)
// pop up a message or whatever
I have found one of the best scripts if you use third party ads.
Disclaimer I'm not affiliated with this site in anyway.
It will work for most sites and if they want to bypass it they will have to add their own filters (complicated for normal users) or contact adblock filters and have one added but they quit doing that cause the list is getting over loaded and slowing down ad block users.
protected by ♦
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10
on this site.
Would you like to answer one of these
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled互联网广告过滤的小历史 | 环球科技观光团小组 | 果壳网 科技有意思
107810人加入此小组
以下内容转载自 月光博客 原文链接摘要:Adblock Plus的历史几乎就是从网景公司将Netscape的大部分源代码以Firefox之名开源后,互联网的广告过滤史。目前,Adblock plus不仅是Firefox上用户最多的扩展(活跃用户万,是排名第二的的两倍)。  Adblock系列扩展程序的最重大的贡献:  1,通过浏览器扩展实现广告过滤  2,同时提供了黑白名单  3,提供了订阅系统  Adblock Plus的后续影响:  1,别人纷纷模仿,推出了类似产品。国内各种简单易用的XXXX卫士,附带了可以订阅的广告过滤,就更不用说了  2,向世人展示了浏览器内核的内容策略有多么重要:Google Chrome 从17开始,专门提供一个叫WebRequest的扩展API,使扩展程序可以清楚地控制网页上的元素  3,在国内,优酷甚至打出了"黑屏"这种惩罚屏蔽广告的用户的手段  4,这一行为的最终目的可能是让互联网广告进化,达到一种新的,大多数人都能接受的平衡。最近发布的Adblock Plus 2宣布会放行非骚扰性广告,就是一个例子。  正文:  本文主要是在说一个叫Adblock Plus的Firefox扩展,实在没办法,在地球上所有的浏览器扩展程序中,唯有它的活跃用户能超出一千万,爱好者谓之神器也不为过。Google Chrome倒是有几个被称作"Apps"的快捷方式(Gmail,Youtube,Angry Bird)的数量能接近它。  是不是发现这两年恼人的弹出式广告少了很多?早期,浏览器纷纷加入“阻止弹出广告”的功能,还记不记得那时候的3721导航条,google/MSN工具栏,都标榜自己能阻止弹出窗口式的广告?但,不够~~~~有人打算把浏览器中所有的广告除掉。  一个叫Wladimir Palant的德国人,他的贡献直接让至少2000万互联网用户轻松地将自己不喜欢的广告排除于视线之外。而在他的作品Adblock Plus所体现的想法(显然不是原创的),则让远远多于2000万的人,成功的表达了自己反对广告的意愿:------This is Adblock  现在,随地捡起一个"****卫士",也能轻易地除去网页上的大多广告,当然愿意用专业的浏览器扩展效果更好;甚至靠广告吃饭的优酷为此举起了“反--反广告”的大旗:(小样,不肯看广告是吧?小黑屋禁闭30秒!)------优酷的小黑屋  这张照片里是2010年CeBIT(德国信息及通信技术博览会)的Linux New Media Award奖获得者(目测左边仨哥们是1.9M级的)  Wladimir Palant是右边数过来第二个:  到目前为止至少没有adblock plus的中文传记,英文的,也只有Adblock plus作者的自叙,以及维基百科,所以笔者想给它做一个中文的小传:  1,最初,有一个叫Henrik Aasted Sorensen的人,在2002年发布了第一个Adblock 0.1。这个版本无非是提供了一个Firefox自带的图片过滤功能的外部接口而已,它只能按网址屏蔽图片。------Adblock 0.1(Doubleclick居然那时就已经有了!)  2,Henrik Aasted Sorensen发布的最后一个Adblock是0.3版,就像早期的Chrome上的广告过滤扩展一样,Adblock 0.3是在网页加载完成后,才将广告隐藏的  3,2003年初,Adblock的版本号进入0.4,项目改由一个叫"rue"的账户负责维护,但这个"rue"的真名谁也不知道。Adblock 0.4使用了一种叫"XBL"的技术,虽然不能阻止广告的下载,能更好地隐藏,广告在加载网页过程中不会显示出来。此时的Adblock开始支持过滤Flash、Java广告(注:不是视频网站flash播放器内的广告),似乎烙下了不稳定的坏名声  4,2004年,Wladimir Palant发现可以用Firefox的Content Policy(注:内容策略系统)来达到真正阻止广告被下载(这就是为什么目前Chrome上两个广告过滤扩展如此渴求WebRequest API的原因,有了它,扩展才能在广告下载前便阻止它)。这时的Adblock还可以阻止背景图片,javascript脚本以及样式表(注:估计是指css样式表隐藏?) 。Adblock也进入了0.5版。  5,2005年初,一个叫Michael McDonald的人向Firefox的扩展库提交了"Adblock Plus 0.5"(注:就是现在的Adblock Plus)。它提供了两个历史性的创意:白名单(Exception Rules)与订阅系统。同时,用户界面和本地化(提供了16种语言的翻译)也得到了改善。  6,与此同时,Adblock的开发趋于停止,甚至当Firefox 1.5刚发布的时候根本找不到一个兼容的Adblock。结果是Michael McDonald给Adblock写了个补丁,让它能运行在Firefox 1.5上。  7,于是,Wladimir Palant重写了Adblock0.5的代码(注:我估计也加入了当时Adblock plus提供的新功能),并希望将其提交给Adblock的代码库,但与其它的Adblock代码贡献者发生了矛盾。Adblock的作者不愿意全盘接受Wladimir Palant的代码,并把精力放在了令人迷惑(注:作者原话'mysterious Adblock 0.6')的Adblock 0.6中  8,接下来Wladimir Palant联系了Michael McDonald以讨论合作事宜,而Michael McDonald表示他无意继续开发Adblock Plus,于是Michael McDonald便把Adblock Plus项目转交给了Wladimir Palant。到了2006年初,Wladimir Palant重写的Adblock 0.5成为了"Adblock Plus 0.6",而真正的Adblock项目却已完全停滞,Mozilla甚至不得不专门为Michael McDonald开放了上传权限,以便他修补一个出现在Adblock上的漏洞。------Adblock Plus 0.6.1,白名单的语法是"@@"  9,从此,Firefox上的广告过滤扩展几乎完全被Wladimir Palant维护的Adblock Plus垄断。期间他改进了Adblock Plus的比较算法(从trivial算法更换为Boyer-Moore算法),意味着可以给Adblock Plus添加上万个(快速)条目,却几乎不会减慢运行速度。  注:  a,在目前的算法中,快速条目大致上指"3个不包括星号的连续字符"的条目。  b,2006年Wladimir Palant在一篇博文中表示,规则条目数量的增加几乎不会对速度产生影响,在当时的电脑与当时的Firefox上,3000条规则需要30毫秒。  ------Adblock Plus 0.7.2(蓝色)比0.7(绿色)快了一倍以上  c,Adblock Plus使用JavaScript(JS)写的,而JS的执行效率和浏览器的JS引擎有很大关系。和2006年不同的是,现在的JS引擎都能把JS预先动态编译(JIT)成机器码,极大提高了执行效率。------Firefox 9(2011年12月)的JS性能几乎是与Firefox 3.6(2010年1月)的5倍------而Firefox 3.5(2009年6月,JS引擎与Firefox 3.6相同)的JS性能是Firefox 3(2008年6月)的两倍  10,2010年,蓬勃发展的Google Chrome浏览器迎来了它的两大广告过滤扩展---Adblock for Chrome(由美国人Michael Gundlach开发)和Adthwart(作者不详)。Adblock for Chrome是一个专门为Google Chrome开发的广告过滤扩展,后来Michael Gundlach又把它移植到了Apple Safari上。Adthwart则是移植了Adblock Plus的比较算法,后来其作者把项目移交给了Wladimir Palant,同时Adthwart归属于Adblock Plus的大旗下。  (注:广大Chrome用户纷纷用脚投票表示他们更喜欢Adblock for Chrome,其用户数量接近三倍于Adblock Plus的Chrome版)------Adblock for Chrome
Chrome Web Store  11,Google Chrome的用户量(注:我倾向于认为这个'用户量'是活跃用户)上,Adblock(300万+)比Adblock Plus(100万+)多一倍以上。而Firefox的Adblock Plus日均活跃用户最高有1500万。光是这些活跃用户加起来就有万(考虑可能的重复)人。因为"活跃用户"总是远远少于实际用户数量,所以实际受益于Adblock Plus系列及相似产品的用户保守估计至少2000万。------Adblock Plus(Firefox版)的用户情况:总共1.45亿下载次数,近一年来平均1280万活跃用户  12,而国内的特殊情况(不到5%的用户使用了新式的浏览器:Google Chrome(及衍生产品,或使用webkit引擎的浏览器),Firefox),使用Adblock Plus等扩展的大约只有50万的级别(注:由AMO和CNZZ的数据推测)。然而,国内有大量的软件、其它浏览器扩展使用了Adblock Plus的创意:高效的比较算法,黑白名单,订阅系统,使得国人能更轻易地对付广告(效果差一点没问题)------国内常见的某"XXXX卫士"提供的广告过滤功能  13,今年(2011)年底,Wladimir Palant将Adblock Plus作为一个公司运营,同时Adblock Plus进入2.0分支,默认放行了被定义为"非侵犯性的"广告。12月底,Adblock Plus有了第一位雇员Andrey Novikov,他目前主要负责Adblock Plus的Google Chrome版本------Adblock Plus 2,默认允许"非骚扰性型广告"Adblock for Chrome从一开始就没打算使用Adblock Plus语法以外的语法。最出名的配置文件是由adblock plus团队负责维护的Easylist,至少12个非常流行的地方性列表(包括Chinalist)是在Easylist的基础上添加的。一个典型的适合大中华地区的过滤列表(Chinalist-Lazy,包含了Chinalist,部分Easylist和EasyPrivacy)有将近13000个条目,正是Adblock Plus高效的比较算法,用户才能不影响使用地过滤广告几乎每个允许附加组件的浏览器都有了自己的广告过滤扩展。Adblock for Chrome与Adblock Plus的Chrome版可以很容易移植,甚至直接运行于到那些使用Chromium内核的第三方浏览器(注,文中有误,傲游是直接基于Webkit)。国内盛行的各种"XXXX卫士"软件,以及某些杀毒软件也提供了不依靠浏览器的广告过滤功能,它们通常不兼容Adblock语法,且过滤功能也有限,但胜在使用极其方便少数广告过滤软件能在提供不依靠浏览器的过滤同时,也能保证各种高级过滤功能IE9提供了一个追踪保护列表(Tracking Protect List)功能,本意是自动阻挡不请自来的互联网用户追踪商,但配合特制的列表(有好事者把Chinalist翻译成了TPL语法的版本),也可以用来过滤广告  在这之后反对的是什么呢?  用户追踪:  我们在上网的时候,总是(通常)不知情地把我们的各项信息提交给第三方,打一个不恰当的比喻:"它"知道你何时,何地,和谁,在哪里开房,当然,"它"通常不知道你的真实姓名,也绝不会偷看你们在房间里具体做什么。被你访问的所有网站都使用了同一个“第三方信息公司”服务,这是怎么一个情况?对于外国人,这个“第三方信息公司”就可以说是Google了,全球来说,大部分的网站都使用了Google Analytics。  来源:fcerebel投稿。
+ 加入我的果篮
非常讨厌没水平的垃圾广告。
的回应:非常讨厌没水平的垃圾广告。喜欢果壳的广告
(C)2015果壳网&京ICP备号-2&京公网安备Adblock Plus for Chrome – 广告屏蔽扩展
Adblock Plus for Chrome – 广告屏蔽扩展
4.50 / 5 5
对于普通用户,安装 Adblock Plus for Chrome 后就已经屏蔽了互联网上的主流广告,点击地址栏右侧的 ABP 图标,取消 “对该网站启用过滤” 就可以排除该网站的过滤,意思是显示广告。
对于某些特定广告,还可以进行定制过滤,点击 “轻松建立过滤规则” 可以对页面的任何页面进行过滤,以后也不会出现了。对于各类变态广告尤其管用。
好吧,都去隐藏广告吧
喜欢这篇文章?
按分类查看文章:
大家都在讨论些什么
: 其实用iphone真的没什么装逼作用,用Android真的不会让机主显得比用IOS的LOW。何必这么恼羞成怒呢。。: @icemould
这才是真相啊。: 只能复制文本内容。: 我搞了个注册表命令版的。
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINESOFTWAREClasses*shell复制内容.reg]
@="复制内容(&4) ^_^"
[HKEY_LOCAL_MACHINESOFTWAREClasses*shell复制内容.regcommand]
@="cmd /c "clip & &%1&&&: @起名烦呀
感觉中国的谷粉尤其是骨灰级谷粉特别多,可能是国外用Google很平常,没感觉什么;国内用谷歌产品需要特别的技巧,所以用Google的时候往往都加上了自己感情色彩。: 补两个下载连接:
http://download.csdn.net/detail/alexhex/572762
http://download.csdn.net/download/trobbie/3187133: 哈哈,美观固然重要,但是重点还是能不能顺利迁移数据啊。
最热门标签
传说中的小众软件 这里分享免费、小巧、实用、有趣、绿色的软件。
个人 blog 转载时请遵循 “署名-非商业性使用-相同方式共享” 的创作共用协议;
商业网站或未授权媒体不得复制本站内容。

我要回帖

更多关于 adblock plus拦截设置 的文章

 

随机推荐