TransFilter

Filtro che permette di scegliere, in una ricerca sul popolare sito di escort Bakeca Incontri, se escludere i trans o se visualizzare solo quelli.

اعتبارا من 29-06-2023. شاهد أحدث إصدار.

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name             TransFilter
// @version          1.2
// @license          MIT
// @description      Filtro che permette di scegliere, in una ricerca sul popolare sito di escort Bakeca Incontri, se escludere i trans o se visualizzare solo quelli.
// @match            https://*.bakecaincontrii.com/donna-cerca-uomo/
// @match            https://*.bakecaincontrii.com/donna-cerca-uomo/?*
// @grant            none
// @namespace http://your-namespace.example.com
// ==/UserScript==

(function() {
    var targetSubstrings = ["trans"];
    var breadcrumbElement = document.querySelector(".breadcrumb");
    let elementsToHide;
    var selectedFilter = localStorage.getItem('transFilter') || 'all';

    function getCards(){
        elementsToHide= document.getElementsByClassName("item-card");
    }

    setTimeout(getCards, 1500)

    var buttonContainer = document.createElement("div");
    buttonContainer.id = "button-container";
    buttonContainer.style.width = "100%";
    buttonContainer.style.display = "flex";
    buttonContainer.style.flexDirection = "column";
    buttonContainer.style.justifyContent = "center";
    buttonContainer.style.alignItems = "end";
    buttonContainer.style.position = "fixed";
    buttonContainer.style.zIndex = "10";
    breadcrumbElement.appendChild(buttonContainer);

    var hideButton = createButton("🍑 Niente trans", "hide");
    var allButton = createButton("Mostra tutto", "all");
    var showButton = createButton("Solo trans 🍌", "show");

    hideButton.addEventListener("click", function() {
        hideCardsWithSubstring(targetSubstrings);
        setActiveButton(hideButton);
        localStorage.setItem('transFilter', 'hide')
    });

    showButton.addEventListener("click", function() {
        showCardsWithSubstring(targetSubstrings);
        setActiveButton(showButton);
        localStorage.setItem('transFilter', 'show')
    });

    allButton.addEventListener("click", function() {
        showAllCards();
        setActiveButton(allButton);
        localStorage.setItem('transFilter', 'all')
    });

    function createButton(label, value) {
        var button = document.createElement("button");
        button.textContent = label;
        button.style.minWidth = "110px";
        button.style.margin = "10px";
        button.style.padding = "5px 10px";
        button.style.borderRadius = "5px";
        button.style.border = "none";
        button.style.background = "pink"

        buttonContainer.appendChild(button);

        if(selectedFilter === value) {
            setActiveButton(button)
        }

        return button;
    }

    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= "flex";
            }
        }
    }

    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= "flex";
                console.log("display block", element.textContent)
            } else {
                element.style.display = "none";
                console.log("display none", element.textContent)
            }
        }
    }

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

    function setActiveButton(activeButton) {
        var buttons = buttonContainer.querySelectorAll("button");
        buttons.forEach(function(button) {
            if (button === activeButton) {
                button.style.backgroundColor = "red";
            } else {
                button.style.backgroundColor = "pink";
            }
        });
    }
})();