oldip / 淘宝广告屏蔽助手

// ==UserScript==
// @name         淘宝广告屏蔽助手
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  尝试去除淘宝搜索结果中的动态加载广告。
// @author       oldip
// @match        https://s.taobao.com/search*
// @grant        none
// @license      MIT
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    const removeAdElements = () => {
        document.querySelectorAll('img.SalesPoint--iconPic--cVEOTPF').forEach(el => {
            let parent = el.closest('.Card--doubleCardWrapper--L2XFE73').parentNode;
            if (parent && parent.tagName === 'DIV') {
                parent.style.display = 'none';
            }
        });
    };

    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            if (mutation.addedNodes.length) removeAdElements();
        });
    });

    const config = { childList: true, subtree: true };

    observer.observe(document.body, config);
})();