Greasy Fork 还支持 简体中文。

Amazon Sponsored Products remover

Removes the terrible sponsored products from Amazon.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Amazon Sponsored Products remover
// @namespace   https://greasyfork.org/en/users/2755-robotoilinc
// @author      RobotOilInc
// @version     0.4.0
// @license     MIT
// @description Removes the terrible sponsored products from Amazon.
// @include     http*://www.amazon.*/*
// @icon        https://i.imgur.com/LGHKHEs.png
// @run-at      document-body
// @grant       GM_registerMenuCommand
// @grant       GM_getValue
// @grant       GM_setValue
// ==/UserScript==

// ------------------------------------------------------------
// Persistent Settings
// ------------------------------------------------------------
const SETTINGS = {
    logging: GM_getValue("logging", false),
    showStats: GM_getValue("showStats", false)
};

// ------------------------------------------------------------
// Menu System
// ------------------------------------------------------------
const registerMenu = () => {
    GM_registerMenuCommand(`Logging: ${SETTINGS.logging ? "✔" : "✘"}`, () => {
        SETTINGS.logging = !SETTINGS.logging;
        GM_setValue("logging", SETTINGS.logging);
        location.reload();
    });

    GM_registerMenuCommand(`Stats: ${SETTINGS.showStats ? "✔" : "✘"}`, () => {
        SETTINGS.showStats = !SETTINGS.showStats;
        GM_setValue("showStats", SETTINGS.showStats);
        updateStatsVisibility();
        location.reload();
    });
};

// ------------------------------------------------------------
// Stats Counter UI
// ------------------------------------------------------------
let stats = {
    total: 0,
    rules: {}
};

const createStatsBox = () => {
    if (document.getElementById("amazon-remover-stats")) return;

    const box = document.createElement("div");
    box.id = "amazon-remover-stats";
    box.innerHTML = `
        <strong>Amazon Remover</strong><br>
        Removed: <span id="ars-total">0</span>
        <hr id="ars-divider" style="margin:6px 0; border:0; border-top:1px solid rgba(255,255,255,0.25); display:none;">
        <div id="ars-breakdown"></div>
    `;

    // Add some CSS
    Object.assign(box.style, { position: "fixed", bottom: "10px", right: "10px", background: "rgba(0,0,0,0.75)", color: "white", padding: "10px 14px", fontSize: "12px", borderRadius: "6px", zIndex: "999999", maxWidth: "220px", lineHeight: "1.4", display: "none" });

    document.body.appendChild(box);
};


const updateStatsVisibility = () => {
    const box = document.getElementById("amazon-remover-stats");
    if (box) box.style.display = SETTINGS.showStats ? "block" : "none";
};

const updateStats = reason => {
    stats.total++;
    stats.rules[reason] = (stats.rules[reason] || 0) + 1;

    document.getElementById("ars-total").textContent = stats.total;

    // Show divider only after first removal
    if (stats.total === 1) {
        document.getElementById("ars-divider").style.display = "block";
    }

    const breakdown = Object.entries(stats.rules)
    .map(([k, v]) => `${k}: ${v}`)
    .join("<br>");

    document.getElementById("ars-breakdown").innerHTML = breakdown;
};

// ------------------------------------------------------------
// Logging Helper
// ------------------------------------------------------------
const log = (reason, el) => {
    if (SETTINGS.logging) {
        console.log(`[AmazonRemover] ${reason}`, el);
    }
};

// ------------------------------------------------------------
// Rule Engine
// ------------------------------------------------------------
const RULES = [
    { selector: '[data-component-type="sp-sponsored-result"]', reason: 'Sponsored search result', parent: '[data-asin]' },
    { selector: '.sp_desktop_sponsored_label', reason: 'Sponsored carousel ad', parent: '.a-carousel-container' },

    { selector: '[class*="_adPlacements"]', reason: 'Skyscraper ad' },
    { selector: '[data-cel-widget*="adplacements"]', reason: 'Skyscraper ad' },

    { selector: '#discovery-and-inspiration_feature_div', reason: 'Product page ad' },
    { selector: '#sponsoredProducts2_feature_div', reason: 'Product page ad' },
    { selector: '#sims-themis-sponsored-products-2_feature_div', reason: 'Product page ad' },
    { selector: '#dp-ads-center-promo-dramabot_feature_div', reason: 'Product page ad' },
    { selector: '[data-cel-widget="dp-ads-center-promo_feature_div"]', reason: 'Product page ad' },
    { selector: '[data-cel-widget*="desktop-dp-atf_ad-placements"]', reason: 'Product page ad' },
    { selector: '[data-cel-widget="p13n-desktop-carousel_desktop-rhf_1"]', reason: 'Product page ad' },
    { selector: '#percolate-ui-ilm_div', reason: 'Product page ad' },
    { selector: '#rhf-shoveler', reason: 'Product page ad' },

    { selector: '.AdHolder', reason: 'Sponsored product block' },

    { selector: '[data-feature-name="sims-discoveryAndInspiration"]', reason: 'Brand promotion block' },
    { selector: '[data-feature-name="sims-simsContainer"]', reason: 'Brand promotion block' },
    { selector: '[data-feature-name="sims-productBundle"]', reason: 'Brand promotion block' },

    { selector: '[data-csa-c-owner="CustomerReviews"]', reason: 'AI review insights' },

    { selector: '[class*="spSponsored"]', reason: 'Tracking page ad', parent: '#recsWidget' },
    { selector: '[class*="dynamic-sponsored-behaviour-container"]', reason: 'Tracking page carousel ad', parent: '.a-carousel-container' },

    { selector: '[data-id*="AmazonLiveDram"]', reason: 'Amazon Live' },

    { selector: '[data-feature-name="desktop-dp-ilm"]', reason: 'Inspiration / ILM promo' },
];

const applyRule = rule => {
    document.querySelectorAll(rule.selector).forEach(el => {
        const target = rule.parent ? el.closest(rule.parent) : el;
        if (target) {
            log(rule.reason, target);
            target.remove();
            updateStats(rule.reason);
        }
    });
};

// ------------------------------------------------------------
// Mutation Observer
// ------------------------------------------------------------
new MutationObserver(() => {
    // Apply all rules
    RULES.forEach(applyRule);

    // Special case: search clutter
    document.querySelectorAll(        '#search .s-result-list.s-search-results > div:not([data-component-type="s-search-result"])'    ).forEach(el => {
        if (el.querySelector('.s-pagination-strip')) {
            return;
        }

        log('Search clutter', el);
        el.remove();
        updateStats('Search clutter');
    });
}).observe(document.body, { childList: true, subtree: true });

// Initialize everything else
registerMenu();
createStatsBox();
updateStatsVisibility();