ZOVspeak

Makes every webpage go full ZOV

2023-11-22 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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);