Hide Specific Flag Cards on Speaky

Hides all user cards with specified flags on Speaky

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         Hide Specific Flag Cards on Speaky
// @description  Hides all user cards with specified flags on Speaky
// @match        *://*.speaky.com/*
// @grant        none
// @version 0.0.1.20250303131759
// @namespace https://greasyfork.org/users/1435046
// ==/UserScript==

(function() {
    'use strict';

    const flagIds = [
        "flag-icons-ma", // Morocco
        "flag-icons-us", // US
        "flag-icons-dz", // Algeria
        "flag-icons-ae", // UAE
        "flag-icons-ca", // Canada
        "flag-icons-gb", // UK
        "flag-icons-sa", // Saudi Arabia
        "flag-icons-iq", // Iraq
        "flag-icons-eg", // Egypt
        "flag-icons-au"  // Australia
    ];

    function hideFlagCards() {
        document.querySelectorAll('li.c-PJLV').forEach(li => {
            flagIds.forEach(flagId => {
                if (li.querySelector(`svg[id="${flagId}"]`)) {
                    li.style.display = 'none';
                }
            });
        });
    }

    function hideLanguageCards() {
        document.querySelectorAll('li.c-PJLV').forEach(li => {
            const speaksAr = li.querySelector('.c-kgeLBM-jWbhrq-speaks-true')?.textContent.includes('ar');
            const learnsArElement = li.querySelector('.c-kgeLBM-gEsXtw-learns-true');
            const learnsAr = learnsArElement ? learnsArElement.textContent.includes('ar') : false;
            if (speaksAr || !learnsArElement || !learnsAr) {
                li.style.display = 'none';
            }
        });
    }

    function hideCards() {
        hideFlagCards();
        hideLanguageCards();
    }

    // Run initially
    hideCards();

    // Observe mutations
    const observer = new MutationObserver(hideCards);
    observer.observe(document.body, { childList: true, subtree: true });
})();