Greasy Fork

Taming.io Uncensor Chat

Uncensors selected words by the user.

目前为 2023-09-05 提交的版本。查看 最新版本

// ==UserScript==
// @name         Taming.io Uncensor Chat
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  Uncensors selected words by the user.
// @author       You
// @match        https://taming.io/
// @match        https://biologyclass.school/
// @match        https://trymath.org/
// @match        https://school-homework.com/
// @match        https://tamming.io/
// @match        https://mathcool.glitch.me/
// @icon         https://taming.io/img/creature/boss-grim-reaper-scythe-skin1.png
// @grant        none
// ==/UserScript==

let censoredWords = prompt("Uncensored Words: (separate using spaces)", "") || "".split(" ");

const selector = document.querySelector("input");

const character = "‎";

const resetKeybind = document.onkeydown = (evt) => {
    evt = evt || window.event;
    if (evt.keyCode == 27) {
        censoredWords = prompt("Bypass List: (separated by spaces)", censoredWords.join(" ")).split(" ");
    }
};

const indexes = (string, search) => {
  return [...string.matchAll(new RegExp(search, "gi"))].map((a) => a.index);
};

const inject = (string, index) => {
  index++;
  return string.slice(0, index) + character + string.slice(index);
}

const onInput = () => {
if (censoredWords[0] == "" && censoredWords.length == 1) return;
  selector.value = selector.value.replace(/[\u200B-\u200D\uFEFF]/g, '');
  censoredWords.forEach((i) => {
    if (selector.value.toLowerCase().includes(i)) {
      let indexList = indexes(selector.value, i);
      let indexIncrement = 0;

      indexList.forEach((j) => {
        indexList[indexList.indexOf(j)] += indexIncrement;
        indexIncrement += 2;
      });

      indexList.forEach((k) => {
        selector.value = inject(selector.value, k);
        selector.value = inject(selector.value, k + 2);
      });

    }
  });
};

selector.oninput = onInput;