Over a million developers have joined DZone.

Block Sponsored Links In Amazon.co.uk Search Results

·


// ==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);
          }
        }
      }
    }
  }
}

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}