TransHider

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

Od 26.06.2023.. Pogledajte najnovija verzija.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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";
        }
    }
})();