No sold items

Hides sold items and removes ads on subito.it

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         No sold items
// @namespace    https://greatest.deepsurf.us/en/users/47243-liquorburn
// @version      2025-10-29
// @description  Hides sold items and removes ads on subito.it
// @author       Burn
// @copyright    2025, burn (https://openuserjs.org/users/burn)
// @license      MIT
// @match        https://www.subito.it/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let adWrapper = "ad_wrapper_";
    let soldClass = "_soldBadge__"; //"item-sold-badge";
    let parentClass = "AdItem_adItemCard__"; //"SmallCard-module_card__";

    function findElements() {
        const elements = document.querySelectorAll('[id^="'+ adWrapper +'"]');
        elements.forEach(element => {
            element.parentNode.removeChild(element);
            console.log("eliminato ad");
        });

        const soldElements = document.querySelectorAll('[class*="'+ soldClass +'"]');
        soldElements.forEach(element => {
            const parentElement = element.closest('[class*="'+ parentClass +'"]');
            if (parentElement && !parentElement.classList.contains('hidden-by-script')) {
                parentElement.style.display = 'none';
                parentElement.classList.add('hidden-by-script');
                console.log("nascosto sold item");
            }
        });
    }

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            findElements();
        });
    });
    const config = {
        childList: true,
        subtree: true,
        attributes: true
    };
    observer.observe(document.body, config);
    findElements();

    const toggleButton = document.createElement('button');
    toggleButton.id = 'toggle-sold-items-btn';
    toggleButton.textContent = 'Mostra / nascondi venduti';
    document.body.appendChild(toggleButton);

    const style = document.createElement('style');
    style.innerText = `
      #toggle-sold-items-btn {
        position: fixed;
        bottom: 10px;
        right: 10px;
        z-index: 1000;
        background-color: #f9423a;
        color: white;
        padding: 10px 20px;
        border-radius: 4px;
        border: none;
        cursor: pointer;
        font-weight: 600;
      }
      #toggle-sold-items-btn:hover {
        background-color: #fa7b75;
        color: white;
      }
    `;
    document.head.appendChild(style);

    let hiddenItemsVisible = false;
    toggleButton.addEventListener('click', () => {
        hiddenItemsVisible = !hiddenItemsVisible;
        const hiddenElements = document.querySelectorAll('.hidden-by-script');
        hiddenElements.forEach(element => {
            element.style.display = hiddenItemsVisible ? 'block' : 'none';
        });
    });
})();