Amazon - hide sponsored items/ads in search result and product detail page

I'm cheap and don't like ads affecting my purchase decisions!

目前为 2022-11-30 提交的版本。查看 最新版本

// ==UserScript==
// @name         Amazon - hide sponsored items/ads in search result and product detail page
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  I'm cheap and don't like ads affecting my purchase decisions!
// @author       You
// @license      MIT
// @match        https://*.amazon.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=amazon.com
// @grant        none
// @require http://code.jquery.com/jquery-3.5.1.min.js
// ==/UserScript==
/* globals jQuery, $, waitForKeyElements */


(function() {
    'use strict';
    setInterval(function () {
        console.clear();

        const sponsoredContents = $('div.AdHolder.s-result-item.s-asin'); // in search result
        if(sponsoredContents.length > 0) {
            $.each(sponsoredContents, function(index, item){
                if($(this).text().indexOf('Sponsored') > -1) {
                    const color = $(this).css('background-color');
                    const s = $(this).find('span.a-color-secondary');
                    const sHover = $(this).find('span.s-label-popover-hover');
                    if(s && color !== 'rgb(128, 128, 128)') {
                        s.removeClass('a-color-secondary');
                        s.css({ 'color': 'red', 'font-size': '200%' });
                    }
                    if(sHover && color !== 'rgb(128, 128, 128)') {
                        sHover.removeClass('a-color-base');
                        sHover.css({ 'color': 'red', 'font-size': '120%' });
                    }

                    if(s || sHover){
                        // $(this).parent().parent().parent().css({ 'background-color': 'grey'});
                        $(this).css({ 'background-color': 'grey'});
                    }

                }
            });
        }


        // on product detail page, the sponsored ad under "Customer ratings by feature"
        // above the "frequently bought together" list
        const ad1 = $("div#hero-quick-promo-grid_feature_div");
        const sponsoredTextSpan1 = $('div#hero-quick-promo-grid_feature_div span#ad-feedback-text-hero-quick-promo');

        if(sponsoredTextSpan1.length > 0 && sponsoredTextSpan1.text().indexOf('Sponsored') > -1) {
            ad1.css({'opacity': 0.1});
        }

        // on product detail page, the sponsored ad under "add to cart"
        // to the right of the ad1 above
        const ad2 = $("div#amsDetailRight_feature_div");
        const sponsoredTextSpan2 = $('div#amsDetailRight_feature_div span#ad-feedback-text-ams-detail-right-v2');
        if(sponsoredTextSpan2.length > 0 && sponsoredTextSpan2.text().indexOf('Sponsored') > -1) {
            ad2.css({'opacity': 0.1});
        }

        // on product detail page, the sponsored ad to the left of the customer reviews
        const ad3 = $("div#cr-ADPlaceholder");
        const sponsoredTextSpan3 = $('div#cr-ADPlaceholder span#ad-feedback-text-customer-reviews-top');
        if(sponsoredTextSpan3.length > 0 && sponsoredTextSpan3.text().indexOf('Sponsored') > -1) {
            ad3.css({'opacity': 0.1});
        }

        // on product detail page, the right below the "Products related to this item" list
        // but above the "Customer questions & answers" list
        const ad4 = $("div#dp-ads-center-promo_feature_div");
        const sponsoredTextSpan4 = $('div#dp-ads-center-promo_feature_div span#ad-feedback-text-dp-ads-center-promo');
        if(sponsoredTextSpan4.length > 0 && sponsoredTextSpan4.text().indexOf('Sponsored') > -1) {
            ad4.css({'opacity': 0.6});
        }


        // on product detail page, the sponsored ad below the customer reviews, the "Based on your recent views" list
        // but above "Recommended based on your shopping trends" list
        const ad5 = $("div#ad-endcap-1_feature_div");
        const sponsoredTextSpan5 = $('div#ad-endcap-1_feature_div span#ad-feedback-text-ad-endcap-1');
        if(sponsoredTextSpan5.length > 0 && sponsoredTextSpan5.text().indexOf('Sponsored') > -1) {
            ad5.css({'opacity': 0.1});
        }

    }, 2000);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址