TransHider

Crea dei tasti per mostrare o nascondere gli annunci con i trans su Backeca Incontri

Stan na 26-06-2023. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name            TransHider
// @namespace       http://your-namespace.example.com
// @version         1.0
// @license         MIT
// @description     Crea dei tasti per mostrare o nascondere gli annunci con i trans su Backeca Incontri
// @match           https://*.bakecaincontrii.com/*
// @grant           none
// ==/UserScript==

(function() {
    var targetSubstrings = ["trans"]; // Sottostringhe da cercare (case insensitive)
    var elementsToHide = document.getElementsByClassName("item-card");
    var breadcrumbElement = document.querySelector(".breadcrumb");

    var hideRadio = createRadioButton("hide-radio", "Niente trans", "hide");
    var showRadio = createRadioButton("show-radio", "Solo trans", "show");
    var allRadio = createRadioButton("all-radio", "Mostra tutto", "all");

    breadcrumbElement.appendChild(hideRadio);
    breadcrumbElement.appendChild(showRadio);
    breadcrumbElement.appendChild(allRadio);

    hideRadio.addEventListener("change", function() {
        hideCardsWithSubstring(targetSubstrings);
    });

    showRadio.addEventListener("change", function() {
        showCardsWithSubstring(targetSubstrings);
    });

    allRadio.addEventListener("change", function() {
        showAllCards();
    });

    function createRadioButton(id, label, value) {
        var radio = document.createElement("input");
        radio.type = "radio";
        radio.name = "card-options";
        radio.id = id;
        radio.value = value;

        var radioLabel = document.createElement("label");
        radioLabel.htmlFor = id;
        radioLabel.textContent = label;

        var radioContainer = document.createElement("div");
        radioContainer.appendChild(radio);
        radioContainer.appendChild(radioLabel);

        return radioContainer;
    }

    function hideCardsWithSubstring(substrings) {
        for (var i = 0; i < elementsToHide.length; i++) {
            var element = elementsToHide[i];
            var textFields = element.querySelectorAll(".item-title, .item-description");

            var shouldHide = false;
            for (var j = 0; j < textFields.length; j++) {
                var textField = textFields[j];
                var text = textField.textContent.toLowerCase();
                for (var k = 0; k < substrings.length; k++) {
                    var substring = substrings[k].toLowerCase();
                    if (text.includes(substring)) {
                        shouldHide = true;
                        break;
                    }
                }
                if (shouldHide) {
                    break;
                }
            }

            if (shouldHide) {
                element.style.display = "none";
            } else {
                element.style.display = "block";
            }
        }
    }

    function showCardsWithSubstring(substrings) {
        for (var i = 0; i < elementsToHide.length; i++) {
            var element = elementsToHide[i];
            var textFields = element.querySelectorAll(".item-title, .item-description");

            var shouldShow = false;
            for (var j = 0; j < textFields.length; j++) {
                var textField = textFields[j];
                var text = textField.textContent.toLowerCase();
                for (var k = 0; k < substrings.length; k++) {
                    var substring = substrings[k].toLowerCase();
                    if (text.includes(substring)) {
                        shouldShow = true;
                        break;
                    }
                }
                if (shouldShow) {
                    break;
                }
            }

            if (shouldShow) {
                element.style.display = "block";
            } else {
                element.style.display = "none";
            }
        }
    }

    function showAllCards() {
        for (var i = 0; i < elementsToHide.length; i++) {
            var element = elementsToHide[i];
            element.style.display = "block";
        }
    }
})();