Basic chat filter bypass

Useless script to bypass some chat filters.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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