eBay Remove Listings with Price Range

Removes eBay listings that show a price range from search results

目前為 2025-07-18 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         eBay Remove Listings with Price Range
// @namespace    ebay_remove_price_range_listings
// @version      2025.07.18
// @description  Removes eBay listings that show a price range from search results
// @author       bwhurd
// @match        https://www.ebay.com/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // --- CONFIG ---
    // Optionally, set a whitelist of search terms to skip script
    const whitelist = ['gameboy color', 'amiga 1200'];
    const searchParams = new URLSearchParams(location.search);
    if (whitelist.includes((searchParams.get('_nkw') || '').toLowerCase())) return;

    let removed = 0;

    // Helper function to remove price range listings
    function removePriceRangeListings() {
        // All price spans in search results
        let priceSpans = document.querySelectorAll('span.s-item__price');
        priceSpans.forEach(span => {
            let text = span.textContent.replace(/\s+/g, ' ').trim();
            // Match "$X.XX to $Y.YY" (or similar, e.g. "AU $1.50 to AU $9.99")
            if (/to/i.test(text)) {
                // Remove the top li.s-item ancestor
                let li = span.closest('li.s-item');
                if (li && li.parentNode) {
                    li.parentNode.removeChild(li);
                    removed++;
                }
            }
        });
    }

    // Initial removal
    removePriceRangeListings();

    // eBay uses dynamic/infinite loading, so listen for DOM changes
    const observer = new MutationObserver(() => {
        removePriceRangeListings();
    });

    observer.observe(document.body, {childList: true, subtree: true});

    // Show a message if anything was removed
    function showInfo() {
        if (removed > 0 && !document.getElementById('tm-ebay-pricerange-info')) {
            const infoMsg = document.createElement("div");
            infoMsg.id = 'tm-ebay-pricerange-info';
            infoMsg.textContent = `${removed} price range listings were removed.`;
            infoMsg.style.position = "fixed";
            infoMsg.style.top = "40px";
            infoMsg.style.left = "10px";
            infoMsg.style.zIndex = 9999;
            infoMsg.style.padding = "10px";
            infoMsg.style.backgroundColor = "#ffc";
            infoMsg.style.border = "1px solid #aaa";
            infoMsg.style.fontSize = "16px";
            infoMsg.style.color = "#333";
            document.body.appendChild(infoMsg);
            setTimeout(() => infoMsg.remove(), 6000);
        }
    }

    // Show message after initial run and after DOM changes
    setInterval(showInfo, 1500);

})();