Last active
May 17, 2024 15:28
-
-
Save nicola02nb/f7be05e6025d3ee1563a21778de985c8 to your computer and use it in GitHub Desktop.
Subito.it Script for Tampermonkey that removes Ads and Sold Items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Subto.it Tools | |
// @namespace http://tampermonkey.net/ | |
// @version 0.3 | |
// @description Rimuove i banner pubblicitari e i prodotti venduti dalla ricerca | |
// @author You | |
// @match https://www.subito.it/annunci-italia/vendita/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=subito.it | |
// @grant none | |
// @run-at document-end | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js | |
// @license GNU GPLv3 | |
// ==/UserScript== | |
var $ = window.jQuery;//Dipendenza | |
var btn; | |
var btnAriaStatus=false; | |
var hiddenList=new Array(); | |
//Funzione che rimuove tutti i prodotti venduti | |
function toggleHideSold(){ | |
var hide=btnAriaStatus; | |
if(hide){ | |
var list=$(".item-sold-badge"); | |
hiddenList=new Array(); | |
list.each(function() { | |
var item=$( this ).parents(".item-card"); | |
item.hide(); | |
hiddenList.push(item); | |
}); | |
} | |
else{ | |
hiddenList.forEach((item) => item.show()); | |
} | |
} | |
//Funzione che elimina tutti i banner pubblicitari durante la ricerca | |
function deleteAds(){ | |
var divAd=$(".ListingContainer_layout__main__mpMw8 > div:nth-child(1) > div:nth-child(1)"); | |
if(!divAd.hasClass("top-bar"))divAd.remove(); | |
var list=$('div[id^="ad_wrapper_"]'); | |
list.each(function() { | |
$( this ).remove(); | |
}); | |
} | |
//Funzione eliminare elementi dalla apgina | |
function deleteStuff(){ | |
toggleHideSold(); | |
deleteAds(); | |
} | |
//Aggiorna lo stile del bottone per nascondere i prodotti venduti | |
function updateButton(){ | |
if(btnAriaStatus){ | |
btn.attr("aria-checked","false"); | |
btn.attr("data-state","unchecked"); | |
btn.html('<span class="pointer-events-none absolute inset-none flex items-center transition-all duration-200 ease-in-out translate-x-none"><span data-state="unchecked" class="absolute left-none top-none flex items-center justify-center bg-surface rounded-full ring-0 transition-all duration-200 ease-in-out h-sz-24 w-sz-24 translate-x-none text-on-surface/dim-4"><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" data-title="Close" fill="currentColor" stroke="none" class="transition-opacity duration-200 h-sz-12 w-sz-12"><path fill-rule="evenodd" d="m21.6,19.67l-7.68-7.68,7.57-7.59c.53-.53.53-1.4,0-1.93-.53-.53-1.4-.53-1.93,0l-7.57,7.58L4.33,2.4c-.53-.53-1.4-.53-1.93,0-.53.53-.53,1.4,0,1.93l7.66,7.66-7.66,7.65c-.53.53-.53,1.4,0,1.93.53.53,1.4.53,1.93,0l7.66-7.66,7.68,7.68c.53.53,1.4.53,1.93,0,.53-.53.53-1.4,0-1.93h0Z"></path></svg></span></span>'); | |
} | |
else{ | |
btn.attr("aria-checked","true"); | |
btn.attr("data-state","checked"); | |
btn.html('<span class="pointer-events-none absolute inset-none flex items-center transition-all duration-200 ease-in-out translate-x-full"><span data-state="checked" class="absolute left-none top-none flex items-center justify-center bg-surface rounded-full ring-0 transition-all duration-200 ease-in-out h-sz-24 w-sz-24 -translate-x-full"><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" data-title="Check" fill="currentColor" stroke="none" class="transition-opacity duration-200 h-sz-12 w-sz-12"><path d="m8.92,19.08c-.18,0-.36-.03-.53-.1s-.33-.17-.47-.31l-5.49-5.34c-.28-.28-.42-.61-.42-1s.14-.73.42-1c.28-.28.62-.41,1.02-.41s.74.14,1.05.41l4.43,4.3,10.62-10.29c.28-.28.62-.42,1.02-.43.39,0,.73.13,1.02.43.28.28.42.61.42,1s-.14.73-.42,1l-11.65,11.32c-.14.14-.3.24-.47.31-.17.07-.35.1-.53.1Z"></path></svg></span></span>'); | |
} | |
btnAriaStatus=btn.attr("aria-checked")=="true"; | |
} | |
//Funzione che crea un interruttore per abilitare/disabilitare la visione di prodotti venduti | |
function initializeButton(){ | |
var old_section=$("#filters-container:nth-child(1)"); | |
var 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"); | |
btn.on("click",updateButton); | |
updateButton(); | |
var i=0; | |
section.find(".index-module_container__JaNg0").each(function(){ | |
if(i>0)$( this ).remove(); | |
i+=1; | |
}); | |
old_section.before(section); | |
} | |
//Inizializzatione del bottone e Interval al termine del caricamento della pagina | |
window.onload = () =>{ | |
initializeButton(); | |
setInterval(deleteStuff,1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment