FallMamontsBlock

Mamonts are no longer flying :(

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         FallMamontsBlock
// @namespace    http://tampermonkey.net/
// @version      2.2
// @description  Mamonts are no longer flying :(
// @author       k3kzia
// @license      MIT
// @match        *://lolz.guru/*
// @match        *://zelenka.guru/*
// @match        *://lolz.live/*
// @grant        GM_registerMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at       document-start
// ==/UserScript==

(function () {
    'use strict';

    const defaultSettings = {
        snowMinJs: true,
        interactiveMinJs: true
    };

    const settings = GM_getValue('blockSettings') || defaultSettings;

    if (!GM_getValue('blockSettings')) {
        GM_setValue('blockSettings', defaultSettings);
    }

    const blockList = [];
    if (settings.snowMinJs) blockList.push('snow.min.js');
    if (settings.interactiveMinJs) blockList.push('interactive.min.js');

    const isBlocked = (src) => blockList.some(blockedUrl => src.includes(blockedUrl));

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            mutation.addedNodes.forEach((node) => {
                if (node.tagName === 'SCRIPT' && node.src && isBlocked(node.src)) {
                    console.log('Blocked script:', node.src);
                    node.remove();
                }
            });
        });
    });

    observer.observe(document.documentElement, { childList: true, subtree: true });

    GM_registerMenuCommand(
        `Падающие мамонты (Сейчас ${settings.snowMinJs ? 'выключены' : 'включены'})`,
        () => {
            settings.snowMinJs = !settings.snowMinJs;
            GM_setValue('blockSettings', settings);
            alert(`Падающие мамонты ${settings.snowMinJs ? 'выключены' : 'включены'}, пожалуйста, перезагрузите страницу`);
        }
    );

    GM_registerMenuCommand(
        `Взаимодействия (Сейчас ${settings.interactiveMinJs ? 'выключены' : 'включены'})`,
        () => {
            settings.interactiveMinJs = !settings.interactiveMinJs;
            GM_setValue('blockSettings', settings);
            alert(`Взаимодействия ${settings.interactiveMinJs ? 'выключены' : 'включены'}, пожалуйста, перезагрузите страницу`);
        }
    );
})();