Friday, July 9, 2010

Custom AdBlock Plus filters

EasyList generally gets the job done, but there are some sites where it's either overzealous or just plain doesn't do anything.  Fortunately, you can add your own custom filters.  These can be exceptions to allow overzealously blocked content, element hiding rules to get rid of more complex things you'd rather not see, and of course regular URL filters.

On ScrewAttack, EasyList basically prevents their video player from working properly.  I went in and figured out what to add exception filters for in AdBlock Plus so the videos would work, but the ads wouldn't.  Simply add the following exception rules, then refresh the page and enjoy.
@@|http://v.giantrealm.com/saf/*$domain=screwattack.com,third-party @@|http://v.giantrealm.com/sax/*$domain=screwattack.com,third-party @@|http://play.giantrealm.com/video/*$domain=screwattack.com,third-party @@|http://vcdn.giantrealm.com/giantrealm/screwattack/*$domain=screwattack.com,third-party
Others, like Sankaku Complex, have recently merged their ad scripts in with scripts that provide core functionality for the page, resulting in all the core functionality breaking in addition to the ads being gone.  They even have the nerve to put a red bar at the bottom of the window bitching at you for blocking ads.  The best solution for this would be a NoScript script surrogate, but it's remediable within AdBlock Plus as well.  Basically, you need four exception rules to let their scripts run:
@@|http://data.sankakucomplex.com/img/www/d/* @@|http://*.sankakustatic.com/wp-content/themes/* @@|http://www.sankakucomplex.com/wp-content/themes/* @@|http://208.100.24.244/javascripts/*
And then you need the following shitton of element hiding rules:
sankakucomplex.com##div.spacer iframe sankakucomplex.com##div#sp1 iframe sankakucomplex.com##div#sp2 iframe sankakucomplex.com###sidetop sankakucomplex.com##div[align="center"] script+a sankakucomplex.com##div[align="center"] a+div sankakucomplex.com##.sidebartopa sankakucomplex.com##.sidebartopb sankakucomplex.com##.sidebartopc sankakucomplex.com##.side120a sankakucomplex.com##.side120b sankakucomplex.com##.side120c sankakucomplex.com##.side120xmla sankakucomplex.com##.side120xmlb sankakucomplex.com##.side120xmlc sankakucomplex.com##.side300xmla sankakucomplex.com##.side300xmlb sankakucomplex.com##.side300xmlc
Also, if you run NoScript (and you should be), you'll need to allow 208.100.24.244 to run scripts.

Want to clean up Twitter a bit? These element hiding rules will hide promoted trends and that stupid promotion thing towards the top of the right column.
twitter.com##a.promoted-trend twitter.com##div.user-rec-inner twitter.com##div.user-rec-inner+hr.component-spacer twitter.com##div.definition twitter.com##div.definition+hr.component-spacer
Hate those hover cards?  All the information they show is redundant and they get in the way when all you want to do is click someone's name and go to their profile.  Add this ad blocking rule to get rid of them.
http://a*.twimg.com/a/*/javascripts/hover_cards.js*
That's pretty much all I've done with custom filters right there.

Edit: Sankaku just made yet another change to the site, moving their merged ad/site functionality script to a different subdomain.  The relevant exception filter above has been changed to reflect this.  This really makes a script surrogate more desirable, since Artefact knows that moving that script around messes with everyone who blocks ads.  Unfortunately, there's no way for a user to add their own script surrogates to NoScript, so I'll have to play around with removing my exception filters and using GreaseMonkey to add the missing features back in.

Edit 2 (August 1): Yet another change.  Javascript relevant to the popular articles box and the recent images browser was moved to an IP address.  The relevant filter and instructions have been added above.

Edit 3 (Also August 1): For Sankaku Complex, I have a much better solution in place now.

Edit 4 (August 4): Twitter moved p.promotion.round and added a "recommended users to follow" "feature" so your home page can be cluttered with shit you don't care about.  Twitter rules updated.  Also fixed an omission in the Sankaku exception filters.

Edit 5 (August 5): I can't believe I neglected to include the filter to block Twitter's hover cards.

Edit 6 (August 19, 2011): Updated Twitter filters for the shitty-ass new layout they're so proud of.  Just go use TweetDeck already.  Spoiler: Since I use TweetDeck, this will be the last update to the Twitter rules in this post.

Edit 7 (Also August 19, 2011): Blogger ate all the <br /> tags and carriage returns in the post.

Edit 8: (April 23, 2023): Blogger thinks this post contains "sensitive content", but doesn't tell me what was objected to.  I read the policy, it doesn't forbid the language I used, or links to external sites.

Because some people don't seem to think this is obvious: I am not responsible for the content of any external site I link to.  Sankaku Complex regularly contains adult content, or at least it did ~12 years ago when I last looked at the site.  If you have a problem with their content, maybe don't look at their website?  I have no control over their content, don't be ridiculous.

No comments:

Post a Comment

I moderate comments because when Blogger originally implemented a spam filter it wouldn't work without comment moderation enabled. So if your comment doesn't show up right away, that would be why.