Basic chat filter bypass

Useless script to bypass some chat filters.

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         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;
        }
    });
})();