MPP Note Quota Hack

Sets MPP.noteQuota.points to 1000 or 10000 repeatedly.

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         MPP Note Quota Hack
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Sets MPP.noteQuota.points to 1000 or 10000 repeatedly.
// @author       Electropiano
// @match        *://multiplayerpiano.net/*
// @match        *://multiplayerpiano.org/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let started = false; // Флаг, чтобы отслеживать, была ли получена команда /start
    let intervalId;       // ID интервала для повторной установки

    function setPoints() {
        if (typeof MPP !== 'undefined' && MPP && MPP.noteQuota) {
            MPP.noteQuota.points = 10000; // 1000 квот если для обычной, 10000 если для блек миди
        } else {
            console.log("MPP.noteQuota еще не определен, установка отложена.");
            // Опционально: Можно повторить попытку позже с setTimeout, если это необходимо
        }
    }

    function startRepeating() {
        if (!intervalId) { // Проверяем, не запущен ли уже интервал
            intervalId = setInterval(setPoints, 100); // Запускаем повторную установку каждые 100 мс
            console.log("Повторная установка MPP.noteQuota.points запущена.");
        } else {
            console.log("Повторная установка MPP.noteQuota.points уже запущена.");
        }
    }

    function handleMessage(msg) {
        let cmd = msg.a;
        if (cmd === '/start' && !started) {
            started = true; // Устанавливаем флаг, чтобы больше не запускать этот блок
            console.log("Получена команда /start. Запуск повторной установки MPP.noteQuota.points.");
            startRepeating(); // Запускаем повторную установку
        } else if (cmd === '/start' && started) {
            console.log("Команда /start уже была обработана. Повторный запуск не требуется.");
        }
    }

    // Ожидание инициализации MPP
    let mppCheckInterval = setInterval(function() {
        if (typeof MPP !== 'undefined' && MPP && MPP.client) {
            clearInterval(mppCheckInterval); // Останавливаем интервал проверки

            MPP.client.on('a', function(msg) {
                handleMessage(msg);
            });

            console.log("MPP.client.on('a') listener установлен.");

        } else {
            console.log("Ожидание инициализации MPP...");
        }
    }, 100);

})();