Last active
May 19, 2018 20:11
-
-
Save heavyLobster2/49b1f7bab7d4e5d51826 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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