ballerburg9005 / AliExpress - Remove Combo Blast Items

// ==UserScript==
// @name         AliExpress - Remove Combo Blast Items
// @namespace    https://openuserjs.org/users/grok
// @version      1.0.0
// @description  Automatically removes all "Combo Blast" items from AliExpress
// @author       Grok (built by xAI)
// @match        https://*.aliexpress.com/*
// @grant        none
// @license      GPL-3.0-only
// ==/UserScript==

(function () {
    'use strict';

    /**
     * Removes all Combo Blast cards.
     * Looks for the exact text inside .lw_j9 > .lw_an and removes the whole product card wrapper.
     */
    function removeComboBlastItems() {
        // Find every "Combo Blast" label
        document.querySelectorAll('span.lw_an').forEach(span => {
            if (span.textContent.trim() === 'Combo Blast') {
                // Go up to the .lw_j9 container
                const j9 = span.closest('.lw_j9');
                if (!j9) return;

                // Go up to the main search card wrapper
                // (class "hm_b3 search-item-card-wrapper-gallery" or just .hm_b3 in some renders)
                const card = j9.closest('.hm_b3') ||
                             j9.closest('.search-item-card-wrapper-gallery') ||
                             j9.closest('div[data-tticheck="true"]');

                if (card) {
                    card.remove();
                }
            }
        });
    }

    // Run immediately when the script loads
    removeComboBlastItems();

    // Watch for dynamically loaded content (infinite scroll, AJAX results, etc.)
    const observer = new MutationObserver(() => {
        // Throttle a bit so we don't run on every tiny DOM change
        if (!window.__comboBlastTimeout) {
            window.__comboBlastTimeout = setTimeout(() => {
                removeComboBlastItems();
                window.__comboBlastTimeout = null;
            }, 300);
        }
    });

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

    // Extra safety: run every 2 seconds in case of heavy SPA updates
    setInterval(removeComboBlastItems, 2000);

    // Also re-run after page visibility changes (tab switching, etc.)
    document.addEventListener('visibilitychange', () => {
        if (!document.hidden) removeComboBlastItems();
    });
})();