Greasy Fork 还支持 简体中文。

Hide Temu Local Listings

Hide Temu listings from local warehouses

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @license MIT
// @name         Hide Temu Local Listings
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Hide Temu listings from local warehouses
// @author       You
// @match        *://*.temu.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Text indicators that signify local listings
    const LOCAL_INDICATORS = [
        'Local',
        'local warehouse',
        'Ships from nearby'
    ];

    function hideLocalListings() {
        // Find the main container with the product listings
        const container = document.querySelector('.js-search-goodsList');
        if (!container) return;

        // Find the autoFitList container
        const autoFitList = container.querySelector('.autoFitList');
        if (!autoFitList) return;

        // Get all direct child divs of autoFitList (these are the product containers)
        const productContainers = autoFitList.children;

        for (const productContainer of productContainers) {
            // Skip non-div elements
            if (productContainer.tagName !== 'DIV') continue;

            // Get all text elements in this listing
            const textElements = productContainer.querySelectorAll('span, div');

            // Check if any text elements contain our local indicators
            let isLocalListing = false;
            for (const element of textElements) {
                const text = element.textContent.trim();

                // Check if text indicates a local listing
                if (LOCAL_INDICATORS.some(indicator => text.includes(indicator))) {
                    isLocalListing = true;
                    break;
                }

                // Also check for the green color styling
                if (element.getAttribute('style') &&
                    element.getAttribute('style').includes('color:#0A8800')) {
                    isLocalListing = true;
                    break;
                }
            }

            // Hide the product container if it's a local listing
            if (isLocalListing) {
                productContainer.style.display = 'none';
                console.log('Hidden local listing:', productContainer);
            }
        }
    }

    // Initial run
    function init() {
        hideLocalListings();

        // Run again after a short delay to catch any lazy-loaded content
        setTimeout(hideLocalListings, 1500);
    }

    // Run when DOM is ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init);
    } else {
        init();
    }

    // Set up an observer for dynamically loaded content
    const observer = new MutationObserver((mutations) => {
        clearTimeout(window.localListingsTimer);
        window.localListingsTimer = setTimeout(hideLocalListings, 300);
    });

    // Start observing changes to the body
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();