Skip to content

Instantly share code, notes, and snippets.

@heavyLobster2
Last active May 19, 2018 20:11
Show Gist options
  • Save heavyLobster2/49b1f7bab7d4e5d51826 to your computer and use it in GitHub Desktop.
Save heavyLobster2/49b1f7bab7d4e5d51826 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Block Amazon Sponsored Ads
// @description Blocks sponsored product results from showing up in Amazon searches
// @version 1.0.3
// @author heavyLobster2
// @namespace github.com/heavyLobster2
// @downloadURL https://gist.github.com/heavyLobster2/49b1f7bab7d4e5d51826/raw/BlockAmazonSponsoredAds.user.js
// @match *://www.amazon.com/s/*
// @grant none
// @noframes
// ==/UserScript==
(function () {
"use strict";
var removeAds = function () {
var resultList = document.getElementById("s-results-list-atf");
if (resultList) {
var sponsorBadges = resultList.querySelectorAll("img.s-sponsored-info-icon");
for (var i = 0; i < sponsorBadges.length; i++) {
var resultItem = sponsorBadges[i].closest("li.s-result-item");
if (resultItem) resultItem.remove();
}
}
};
removeAds();
var mainDiv = document.getElementById("main");
if (mainDiv) (new MutationObserver(removeAds)).observe(mainDiv, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment