ZOVspeak

Makes every webpage go full ZOV

As of 22.11.2023. See апошняя версія.

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 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            ZOVspeak
// @name:ru         ZOVspeak
// @namespace       Violentmonkey Scripts
// @match           *://*/*
// @grant           none
// @version         1.0
// @author          -
// @description     Makes every webpage go full ZOV
// @description:ru  Этот скрипт сделает любую веб-страницу чуточку уютнее и роднее, если Vы пOнимаете, O чём я.
// @license MIT
// ==/UserScript==

const replaceZOVString = (s) => {
  return s
    .replace(/[Зз]/g, 'Z')
    .replace(/[Вв]/g, 'V')
    .replace(/[Оо]/g, 'O');
}

const replaceZOVHTML = (element) => {
  element.childNodes.forEach((node) => replaceZOVHTML(node));
  if (element.nodeType == Node.TEXT_NODE) {
    const newValue = replaceZOVString(element.nodeValue);
    if (element.nodeValue !== newValue) {
      element.nodeValue = newValue;
    }
  }
}

const observer = new MutationObserver(
  (mutationList, observer) => {
    for (const mutation of mutationList) {
      switch (mutation.type) {
        case 'childList':
          mutation.addedNodes.forEach(replaceZOVHTML);
          break;
        case 'attributes':
          break;
        case 'characterData':
          replaceZOVHTML(mutation.target);
          break;
        case 'subtree':
          break;
      }
    }
  }
);

observer.observe(document, {
  childList: true,
  // attributes: true,
  characterData: true,
  subtree: true
});

const onLoad = () => {
  replaceZOVHTML(document.getElementsByTagName('html')[0]);
}

window.addEventListener('load', onLoad, false);