Taming.io Uncensor Chat

Uncensors selected words by the user.

当前为 2023-09-05 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Taming.io Uncensor Chat
// @namespace    http://tampermonkey.net/
// @version      0.5
// @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("Bypass List: (separated by 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;