BetterTTV Plus

It's BetterTTV but the settings are stored by the Script Manager.

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            BetterTTV Plus
// @description     It's BetterTTV but the settings are stored by the Script Manager.
// @icon            https://cdn.betterttv.net/assets/logos/bttv_logo.png
// @author          SkauOfArcadia
// @homepage        https://skau.neocities.org/
// @match           https://*.twitch.tv/*
// @version         2025.11.24
// @grant           GM.getValue
// @grant           GM.setValue
// @require         https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @run-at          document-start
// @namespace https://greasyfork.org/users/751327
// ==/UserScript==
(function() {
    const BTTV_CDN = 'https://cdn.betterttv.net';
    const SETTINGS_KEY = 'bttv_settings';
    const DEFAULT_SETTINGS = '{\"emoteMenu\":2,\"emotes\":[55,16],\"channelPoints\":[7,2],\"autoClaim\":[1,1]}';
    const POLLING_INTERVAL = 1000; // Time in milliseconds for checking updates

    // Load BetterTTV script
    window.addEventListener("DOMContentLoaded", function() {
        const jsNode = document.createElement('script');
        jsNode.setAttribute('src', `${BTTV_CDN}/betterttv.js`);
        document.body.appendChild(jsNode);
    });

    // Variables for tracking the last known settings
    let lastSettings = localStorage.getItem(SETTINGS_KEY) || DEFAULT_SETTINGS;

    function logWithTimestamp(message) {
        const timestamp = new Date().toLocaleTimeString();
        console.log(`[${timestamp}] BTTV Plus: ${message}`);
    }

    // Function to save settings to GM
    function saveSettings(settings) {
        GM.setValue(SETTINGS_KEY, settings);
        logWithTimestamp("Settings saved!");
    }

    // Load settings from GM and set them to localStorage
    async function loadSettings() {
        const savedSettings = await GM.getValue(SETTINGS_KEY, lastSettings);
        localStorage.setItem(SETTINGS_KEY, savedSettings);
        logWithTimestamp("Settings loaded!");
    }

    // Initialize settings on script load
    loadSettings();

    // First use save
    GM.getValue(SETTINGS_KEY, null).then(value => {
        if (value === null) {
            saveSettings(lastSettings);
        }
    });

    // Periodically check for changes in localStorage
    setInterval(() => {
        const currentSettings = localStorage.getItem(SETTINGS_KEY);
        if (currentSettings === null) {
            currentSettings = lastSettings;
            localStorage.setItem(SETTINGS_KEY, currentSettings);
        }
        if (currentSettings !== lastSettings) {
            lastSettings = currentSettings;
            saveSettings(currentSettings);
        }
    }, POLLING_INTERVAL);
})();