Subito.it Tools

Rimuove i banner pubblicitari e i prodotti venduti dalla ricerca

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         Subito.it Tools
// @namespace    https://gist.github.com/nicola02nb
// @version      0.14
// @description  Rimuove i banner pubblicitari e i prodotti venduti dalla ricerca
// @author       nicola02nb (https://gist.github.com/nicola02nb)
// @match        https://www.subito.it/annunci-*/vendita/*
// @match        https://www.subito.it/*/*.htm
// @icon         https://www.google.com/s2/favicons?sz=64&domain=subito.it
// @grant        none
// @run-at       document-start
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js
// ==/UserScript==
let $ = window.jQuery;//Dipendenza

let btn;
let btnElement;
let hide=true;

const adsSelector = [
    'div[id^="ad_wrapper_"]',
    'iframe[id^="google_ads_iframe_"]',
    'div[class^="AdsGAMP"]',
    'div[id="apn_skin_tag"]',
    'button[class^="banner-module_sticky-banner_"]',
    'div[id="desktop-after-listing-lp-market"]',
    'div[class^="AdsBeforeListingBlock_adsense-before-listing-container_"]'
].join(', ');

//Funzione che elimina tutti i banner pubblicitari durante la ricerca
function deleteAds(){
    document.querySelectorAll(adsSelector).forEach(div => {
        div.remove();
    });
}

let style=document.createElement('style');
style.innerHTML=`
article:has(div > span[class*="soldBadge"]) {
    display: none !important;
}
`;
//Funzione che rimuove tutti i prodotti venduti
function toggleHideSold(){
    if(hide){
        document.head.appendChild(style);
    } else {
        document.head.removeChild(style);
    }
}

//Aggiorna lo stile del bottone per nascondere i prodotti venduti
function updateButton(toggle = true){
    if (toggle) hide = !hide;
    if(hide){
        btn.attr("aria-checked","true");
        btn.attr("data-state","checked");
        btnElement.setAttribute("data-state", "checked");
    }
    else{
        btn.attr("aria-checked","false");
        btn.attr("data-state","unchecked");
        btnElement.setAttribute("data-state", "unchecked");
    }
    toggleHideSold();
}

//Funzione che crea un interruttore per abilitare/disabilitare la visione di prodotti venduti
function initializeButton(){
    let old_section=$("#filters-container:nth-child(1)");

    let section=old_section.clone();
    section.find("h5").text("Plugin Filters");
    section.find("p").text("Custom Filters");
    section.find("label").text("Nascondi venduti").attr("id","radx-99").attr("for","/isSold");

    btn=section.find("button");
    btn.attr("id","/isSold").attr("aria-labelledby","radx-99");
    btnElement = btn.find("span")[0];
    btn.on("click",updateButton);
    updateButton(false);

    let i=0;
    section.find("[class^=\"index-module_container_\"]").each(function(){
        if(i>0)$( this ).remove();
        i+=1;
    });
    old_section.before(section);
}

//Funzione eliminare elementi dalla pagina
function deleteStuff(){
    toggleHideSold();
    deleteAds();
}

//Inizializzatione del bottone e Interval al termine del caricamento della pagina
window.onload = () => {
    initializeButton();
    deleteStuff();
    setInterval(deleteStuff,1000);
}