FREEDOM from Anti-Filter (no censorship)

Enjoy it without the gartic.io filter. The disadvantage is that the number of letters has been reduced from 100 to 50.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         FREEDOM from Anti-Filter (no censorship)
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Enjoy it without the gartic.io filter. The disadvantage is that the number of letters has been reduced from 100 to 50.
// @author       KokoTheHand
// @match        *://gartic.io/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let keysPressed = [];

    document.addEventListener('keydown', (event) => {
        if (event.key.length === 1 && event.key.match(/[a-z]/i)) {
            keysPressed.push(event.key.toLowerCase());

            if (keysPressed.length > 1) {
                keysPressed.shift();
            }

            const checkKeyCombination = (keys, textToAdd) => {
                if (keysPressed.length === keys.length && keysPressed.every((val, index) => val === keys[index])) {
                    const inputField = document.querySelector('input[type="text"][name="chat"]');
                    if (inputField) {
                        inputField.value += textToAdd;
                        inputField.dispatchEvent(new Event('input'));
                    }
                    keysPressed = [];
                }
            };

            for (let charCode = 97; charCode <= 122; charCode++) { // a-z (ASCII 97-122)
                const letter = String.fromCharCode(charCode);
                checkKeyCombination([letter], '؜'); // an invisible sign between letters
            }
        }
    });
})();