Taming.io ZWSP Injector 2.0

Automatically injects a zero-width space into the Taming.io chat to uncensor selected censored words.

As of 2023-05-24. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Taming.io ZWSP Injector 2.0
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Automatically injects a zero-width space into the Taming.io chat to uncensor selected censored words.
// @author       You
// @match        https://taming.io/
// @icon         https://taming.io/img/creature/boss-seahorse-head.png
// @grant        none
// ==/UserScript==

let censoredWords = prompt("Bypass List: (separated by spaces)", "").split(" ");

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

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) + "​" + 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;