Randomize font!

Клоунский скрипт

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Randomize font!
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Клоунский скрипт
// @author       Fenion
// @match        https://anichat.ru/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=anichat.ru
// @grant        none
// ==/UserScript==

const randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
const boldNames = ['bold', 'heavybold', 'ital', 'boldital', 'heavyital', ''];

const injectToSendMessage = () => {
    const origin = window.processChatPost;
    window.processChatPost = (...args) => {
        const colorInt = randomInt(0, 32);
        const fontInt = randomInt(0, 7);
        const boldInt = randomInt(0, 5);
        fetch('/system/action_profile.php', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
            },
            body:  new URLSearchParams({
                save_color: !colorInt ? '': 'bcolor' + colorInt,
                save_bold: boldNames[randomInt(0, boldNames.length - 1)],
                save_font:  !fontInt ? '': 'bfont' + fontInt,
                token: window.utk,
            })
        })
            .catch(console.error)
            .finally(() => origin(...args));
    };
};

(function () {
    'use strict';

    injectToSendMessage();
})();