Kick.com Language Filter Memory

Automatically remembers and restores your selected language filter on Kick.com browse page

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.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

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         Kick.com Language Filter Memory
// @version      1.0
// @description  Automatically remembers and restores your selected language filter on Kick.com browse page
// @description:pl Automatycznie zapamiętuje i przywraca wybrany filtr języka na stronie przeglądania Kick.com
// @author       Premiumsmart
// @match        https://kick.com/browse*
// @icon         https://kick.com/favicon.ico
// @license      MIT
// @grant        none
// @namespace https://greasyfork.org/users/1353836
// ==/UserScript==

(function() {
    'use strict';

    const STORAGE_KEY = 'kick_language_filter';

    // Get current language from URL
    function getCurrentLanguageFromURL() {
        const urlParams = new URLSearchParams(window.location.search);
        return urlParams.get('languages');
    }

    // Get saved language from localStorage
    function getSavedLanguage() {
        return localStorage.getItem(STORAGE_KEY);
    }

    // Save language to localStorage
    function saveLanguage(lang) {
        if (lang) {
            localStorage.setItem(STORAGE_KEY, lang);
            console.log(`[Kick Filter] Saved language: ${lang}`);
        } else {
            // If user removed the filter (clicked "Clear all")
            localStorage.removeItem(STORAGE_KEY);
            console.log(`[Kick Filter] Removed saved language`);
        }
    }

    // Main logic
    function applyLanguageFilter() {
        const currentLang = getCurrentLanguageFromURL();
        const savedLang = getSavedLanguage();

        // Case 1: User just selected/changed language
        if (currentLang) {
            saveLanguage(currentLang);
            console.log(`[Kick Filter] Detected language filter: ${currentLang}`);
        }
        // Case 2: No language in URL, but we have saved one
        else if (savedLang && window.location.pathname === '/browse') {
            console.log(`[Kick Filter] Restoring saved language: ${savedLang}`);
            const urlParams = new URLSearchParams(window.location.search);
            urlParams.set('languages', savedLang);

            // Keep other parameters (e.g. sort)
            if (!urlParams.has('sort')) {
                urlParams.set('sort', 'viewers_high_to_low');
            }

            // Redirect with preserved parameters
            window.location.search = urlParams.toString();
        }
        // Case 3: No language in URL and no saved language - user cleared the filter
        else if (!currentLang && !savedLang) {
            console.log(`[Kick Filter] No language filter active`);
        }
    }

    // Listen for URL changes (when user changes filter without page reload)
    let lastURL = window.location.href;
    new MutationObserver(() => {
        const currentURL = window.location.href;
        if (currentURL !== lastURL) {
            lastURL = currentURL;
            applyLanguageFilter();
        }
    }).observe(document, { subtree: true, childList: true });

    // Run on page load
    applyLanguageFilter();

})();