Page 1 of 1

Blocking ads by matching on 'HREF' attribute

Posted: Fri Aug 12, 2011 1:51 am
by peruvianllama
I recently did a double-take when a bunch of strange, gaudy images appeared on a website I frequent. It took a moment for the brain to get into gear, but I eventually remembered these things are called "ads" by the masses.. Strange that ABP wasn't picking them up.

The basic format was a script embedded with the page:

Code: Select all

		<script type="text/javascript">
		function drjdEFHl(type) {
			<set some cookies and variables>

			if(type==1){
				ret = '<a href="http://adserver.adtechus.com/adlink/...<snip>..." target="_blank"><img src =/eksjEbR/ehWja/eksjEbR /></a>'; 
			} else if(type==2){
				... <same idea> ...
			}

			return ret;
		}
		</script>
Then later on, when they wanted to insert an ad it looked something like this:

Code: Select all

		<div id="IMrxfTQz">
			<script type="text/javascript">
			if(adblock) { // FF_Chrome
				document.write(drjdEFHl(1));
			}
			</script><a href="http://adserver.adtechus.com/adlink/...<snip>..." target="_blank"><img src="/eksjEbR/ehWja/eksjEbR"></a>
		</div>
The gobbledegook in the IMG SRC attribute and the name of the script's function were both apparently randomized with each refresh, as were various document elements. So not possible to match on IDs, etc. I'm completely uninitiated with writing ABP rules, but after some fiddling I found I could hide the ads using the rule:

Code: Select all

##a[href*="adserver"]
But this got me to thinking: why isn't this a more standard approach? The regular set of blockable rules could be applied to anything that's contained with an <A> tag with a nasty looking HREF value. Or is this a standard approach by some subscribe-able filter list already?

Re: Blocking ads by matching on 'HREF' attribute

Posted: Fri Aug 12, 2011 5:22 am
by BNP
adblock used to have this ability. it was removed for performance reasons I think.

you can use an element hiding rule to block them partially now but I think the image may still be downloaded in the background.

ad muncher can remove them completely.

Re: Blocking ads by matching on 'HREF' attribute

Posted: Fri Aug 12, 2011 7:26 pm
by Michael
Peruvianllama, if you would provide a link to the page on which these functions are present we should be able to suggest alternative filters for the domain.

BNP, yes, images are still downloaded even if the element in which they are located is hidden.