Friday, August 14, 2009

remove bing links from content sites

Lately, I have seen numerous "bing" links appearing in certain content sites I frequent. A case in point is

It is somewhat insidious as unless I happen to note it is a search link, I pursue it imagining it will take me to some good content.

So I wrote a GreaseMonkey script to disable those links. Here goes:

// ==UserScript==
// @name test
// @namespace
// @include*
// ==/UserScript==
var allLinks, thisLink;
allLinks = document.evaluate(
for (var i = 0; i < allLinks.snapshotLength; i++) {
thisLink = allLinks.snapshotItem(i);
// do something with thisLink
if (thisLink.href.substring(0,19)=="") {

I'm not too familiar with XPath, but I believe it is possible to specify "" inside the XPath query itself, so that there is no need to iterate through all the links finding the search links. I couldn't get the syntax right for this. Please post if you find a way around this.