Greasy Fork

Etsy - Sponsored Products remover

Removes the terrible sponsored products/banners/suggested searches/etc from Etsy.

目前为 2024-01-29 提交的版本。查看 最新版本

// ==UserScript==
// @name        Etsy - Sponsored Products remover
// @namespace   https://greasyfork.org/en/users/2755-robotoilinc
// @author      RobotOilInc
// @version     0.6.1
// @license     MIT
// @description Removes the terrible sponsored products/banners/suggested searches/etc from Etsy.
// @match       http*://www.etsy.com/search?*
// @match       http*://etsy.com/search?*
// @match       http*://www.etsy.com/c/*
// @match       http*://etsy.com/c/*
// @match       http*://www.etsy.com/*/market/*
// @match       http*://etsy.com/*/market/*
// @icon        https://i.imgur.com/YYVvnud.png
// @run-at      document-body
// ==/UserScript==

new MutationObserver(function(mutationList, observer) {
    // Remove most loved
    document.querySelectorAll('[data-top-rated-narrowing-intent-search]').forEach(function(element) {
        element.remove();
    });

    // Remove related searches
    document.querySelectorAll('[data-search-query-ingresses]').forEach(function(element) {
        element.remove();
    });

    // Remove "Ad by Etsy seller" search results
    document.querySelectorAll('.v2-listing-card__info p').forEach(function(element) {
        if (!element.innerText.includes(' by Etsy seller') && !element.innerText.includes('ad')) {
            return;
        }

        const style = window.getComputedStyle(element);
        if (style.width == "0px" || style.height == "0px" ){
            return;
        }

        const parent = element.closest('li.wt-list-unstyled');
        if(parent) parent.remove();
    });

    // Remove "Ad by Etsy seller" search results - using data logger data
    document.querySelectorAll('[data-logger-id]').forEach(function(element) {
        const parent = element.closest('li.wt-list-unstyled');
        if(parent) parent.remove();
    });

    // Remove "Ad by X" in categories
    document.querySelectorAll('.v2-listing-card__info p').forEach(function(element) {
        if (!element.innerText.includes(' from shop ')) {
            return;
        }

        const style = window.getComputedStyle(element);
        if (style.width == "0px" || style.height == "0px" ){
            return;
        }

        const parent = element.closest('li.wt-list-unstyled');
        if(parent) parent.remove();
    });

    // Remove ads in Market
    document.querySelectorAll('h2[id^="ad-listing-title"]').forEach(function(element) {
        const parent = element.closest('li.wt-list-unstyled');
        if(parent) parent.remove();
    });

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