Greasy Fork is available in English.

Wallapop - Filtrar productos reservados

Script para filtrar los productos reservados de Wallapop

// ==UserScript==
// @name        Wallapop - Filtrar productos reservados
// @namespace   Wallapop - Filtrar productos reservados
// @match       https://es.wallapop.com/*
// @grant       none
// @version     1.3.1
// @author      Kioraga
// @license     MIT
// @description Script para filtrar los productos reservados de Wallapop
// @icon        https://www.google.com/s2/favicons?sz=64&domain=wallapop.com
// @run-at       document-end
// @grant       GM_addStyle
// @grant       GM_getValue
// @grant       GM_setValue
// ==/UserScript==

GM_addStyle(`
    .wallapop-button {
	    box-sizing: border-box;
	    border-top-left-radius: 25px;
	    border-top-right-radius: 25px;
	    border-bottom-right-radius: 25px;
	    border-bottom-left-radius: 25px;
	    font-family: Wallie, Helvetica;
	    overflow-x: visible;
	    overflow-y: visible;
	    text-transform: none;
	    appearance: button;
	    cursor: pointer;
	    display: flex;
	    font-weight : 400;
	    color: rgb(232, 230, 227);
	    text-align: center;
	    vertical-align: middle;
	    background-color: rgb(19, 193, 172);
	    border-top-color: transparent;
	    border-top-style: solid;
	    border-top-width: 1;
	    border-right-color: transparent;
	    border-right-style: solid;
	    border-right-width: 1;
	    border-bottom-color: transparent;
	    border-bottom-style: solid;
	    border-bottom-width: 1;
	    border-left-color: transparent;
	    border-left-style: solid;
	    border-left-width: 1;
	    border-image-outset: 0;
	    border-image-repeat: stretch;
	    border-image-slice: 100%;
	    border-image-source: none;
	    border-image-width: 1;
	    padding: 10px 15px;
	    transition-property : all, padding;
	    transition-duration : 0.2s, 0s;
	    transition-timing-function : ease-in-out, ease;
	    transition-delay : 0s, 0s;
	    align-items: center;
	    height: 40px;
	    min-width: fit-content;
    }

    .wallapop-button:hover {
        background-color: rgb(12, 122, 110);
    }
`);

var filtradoActivo = GM_getValue("filtradoActivo", false);

var btn = document.createElement("button");
btn.classList.add("wallapop-button");

if (filtradoActivo) {
    btn.innerHTML = "Mostrar reservados";
} else {
    btn.innerHTML = "Ocultar reservados";
}
btn.style = "margin-left: auto;"

function injectButton() {
    var filtersBar = document.querySelector('div.d-flex.ng-star-inserted');
    var lastChild = filtersBar.lastChild;
    filtersBar.insertBefore(btn, lastChild.nextSibling);
}

btn.onclick = function () {
    filtradoActivo = !filtradoActivo;
    if (filtradoActivo) {
        btn.innerHTML = "Mostrar reservados";
        GM_setValue("filtradoActivo", true);
    } else {
        btn.innerHTML = "Ocultar reservados";
        GM_setValue("filtradoActivo", false);
        location.reload()
    }
};


function filtrarProductos() {
    if (filtradoActivo) {
        var productos = document.querySelectorAll("a.ItemCardList__item.ng-star-inserted");
        productos.forEach(function (anuncio) {
            if (anuncio.querySelector('tsl-svg-icon[src="/assets/icons/item-card/reserved.svg"]')) {
                anuncio.remove();
            }
        });
    }
}

setTimeout(injectButton, 2000);
setInterval(filtrarProductos, 1000);