Basic chat filter bypass

Useless script to bypass some chat filters.

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         Basic chat filter bypass
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Useless script to bypass some chat filters.
// @author       ;-;
// @match        https://arras.io/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const zeroWidthSpace = '\u200B';
    let lastKeyTyped = '';
    let lastKeyLower = '';

    const bypassPairs = [
        ['e', 'z'],
        ['i', 'g'],
        ['u', 'c'],
        ['h', 'i'],
        ['s', 's'],
        ['i', 'c'],
        ['u', 's'],
        ['u', 'n'],
        ['a', 'p'],
        ['o', 'c'],
        ['b', 'i'],
        ['u', 't'],
        ['a', 'g'],
        ['t', 'f'],
        ['y', 's'],
        ['e', 'g']
    ];

    document.addEventListener('keydown', function (e) {
        const input = e.target;
        if (!input || (input.tagName !== 'INPUT' && input.tagName !== 'TEXTAREA')) return;

        const currentKey = e.key;
        const currentKeyLower = currentKey.toLowerCase();
        const pos = input.selectionStart;
        const val = input.value;

        if (lastKeyTyped === ' ' && currentKey === '$') {
            e.preventDefault();
            const before = val.slice(0, pos - 1);
            const after = val.slice(pos);
            input.value = before + ' ' + zeroWidthSpace + '$' + after;
        input.setSelectionRange(pos + 2, pos + 2);
        }

        for (const [first, second] of bypassPairs) {
            if (lastKeyLower === first && currentKeyLower === second) {
                e.preventDefault();
                const before = val.slice(0, pos - 1);
                const after = val.slice(pos);
                input.value = before + lastKeyTyped + zeroWidthSpace + currentKey + after;
                input.setSelectionRange(pos + 2, pos + 2);
                break;
            }
        }

        if (!['Shift', 'Control', 'Alt', 'Meta'].includes(currentKey)) {
            lastKeyTyped = currentKey;
            lastKeyLower = currentKeyLower;
        }
    });
})();