Exit Full View

Ebay Thumbnail Fix

Ebay is very broken. I use the middle mouse button to open links in a new tabs, and I use that feature a lot in ebay. However, if you try this on a thumbnail image, you will find that it doesn't work!

Greasemonkey to the rescue! I've replaced the broken links, so that they work correctly (just as the item's description do).

// ==UserScript==
// @name           ebay thumbnail fix
// @namespace      nickthecoder
// @description    Allows the images in search results to be middle clicked. Man, ebay is shite!
// @include        http://shop.ebay.co.uk/*
// @include        http://ebay.co.uk/*
// ==/UserScript==


// Please change the version before every modification
var version = 1.0;

// Add stubs for logging if firebug isn't enabled on this browser
if ( ! console ) {
  console = new Object();
  var doNothing = function() {};
  console.debug = console.info = console.log = doNothing;
}
console.debug( "begin greasemonkey script ebay_thumbnail_fix" );


function ntc_fixThumbnails()
{
  doc = window.document;

  var aTags = doc.getElementsByTagName( "a" );
	
  for ( var i = 0; i < aTags.length; i ++ ) {
    aTag = aTags[ i ];
    if (aTag.className == "pic") {
      var parent = aTag.parentNode.parentNode;
      var otherATags = parent.getElementsByTagName( "a" );

      for ( var j = 0; j < otherATags.length; j ++ ) {
        var otherATag = otherATags[j];
        if ( otherATag.className == "v4lnk" ) {
          aTag.href = otherATag.href;
        }
      }
    }
  }   

}

ntc_fixThumbnails();

console.debug( "end greasemonkey script ebay_thumbnail_fix" );