淘宝广告屏蔽助手

尝试去除淘宝搜索结果中的动态加载广告以及掌柜热卖。

目前為 2024-06-03 提交的版本,檢視 最新版本

// ==UserScript==
// @name         淘宝广告屏蔽助手
// @namespace    http://tampermonkey.net/
// @version      1.2.1
// @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';
            }
        });

        // 移除右侧掌柜热卖的广告
        document.querySelectorAll('.RightLay--rightWrap--OxNNeu6').forEach(el => {
            el.style.display = 'none';
        });

        // 移除下方掌柜热卖的广告
        document.querySelectorAll('.BottomLay--bottomWrap--YBah2VM').forEach(el => {
            el.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);

    // 初始调用以立即移除广告
    removeAdElements();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址