Hide Specific Flag Cards on Speaky

Hides all user cards with specified flags on Speaky

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