Taming.io ZWSP Injector 2.0

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

Tính đến 24-05-2023. Xem phiên bản mới nhất.

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

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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;