TransHider

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

26.06.2023 itibariyledir. En son verisyonu görün.

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.

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

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