DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Block Sponsored Links In Amazon.co.uk Search Results

06.20.2005
| 5186 views |
  • submit to reddit
        

// ==UserScript==
// @name          amazon-sponsored-links
// @namespace     chillihead
// @description   Remove sponsored links from Amazons search results
// @include       http://www.amazon.co.uk*
// ==/UserScript==


if(document.getElementsByTagName("span")!=null)
{
  var s = document.getElementsByTagName("span");
  
  for(var i = 0; i < s.length; i++)
  {
    if(s[i].getAttribute("class") != null)
    {
      var cls = s[i].getAttribute("class");
      if(cls == "h1")
      {
        if(s[i].innerHTML != null)
        {
          var txt = s[i].innerHTML;
          if(txt == "Sponsored Links:")
          {
            // great-grandparent of this span is the containing table.
            var theTable = s[i].parentNode.parentNode.parentNode;
            // get the tables parent
            var tableParent = theTable.parentNode;
            // remove the table of sponsored links.
            tableParent.removeChild(theTable);
          }
        }
      }
    }
  }
}