ZOVspeak

Makes every webpage go full ZOV

  1. // ==UserScript==
  2. // @name ZOVspeak
  3. // @name:ru ZOVspeak
  4. // @namespace Violentmonkey Scripts
  5. // @match *://*/*
  6. // @grant none
  7. // @version 1.0
  8. // @author -
  9. // @description Makes every webpage go full ZOV
  10. // @description:ru Этот скрипт сделает любую веб-страницу чуточку уютнее и роднее, если Vы пOнимаете, O чём я.
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. const replaceZOVString = (s) => {
  15. return s
  16. .replace(/[Зз]/g, 'Z')
  17. .replace(/[Вв]/g, 'V')
  18. .replace(/[Оо]/g, 'O');
  19. }
  20.  
  21. const replaceZOVHTML = (element) => {
  22. element.childNodes.forEach((node) => replaceZOVHTML(node));
  23. if (element.nodeType == Node.TEXT_NODE) {
  24. const newValue = replaceZOVString(element.nodeValue);
  25. if (element.nodeValue !== newValue) {
  26. element.nodeValue = newValue;
  27. }
  28. }
  29. }
  30.  
  31. const observer = new MutationObserver(
  32. (mutationList, observer) => {
  33. for (const mutation of mutationList) {
  34. switch (mutation.type) {
  35. case 'childList':
  36. mutation.addedNodes.forEach(replaceZOVHTML);
  37. break;
  38. case 'attributes':
  39. break;
  40. case 'characterData':
  41. replaceZOVHTML(mutation.target);
  42. break;
  43. case 'subtree':
  44. break;
  45. }
  46. }
  47. }
  48. );
  49.  
  50. observer.observe(document, {
  51. childList: true,
  52. // attributes: true,
  53. characterData: true,
  54. subtree: true
  55. });
  56.  
  57. const onLoad = () => {
  58. replaceZOVHTML(document.getElementsByTagName('html')[0]);
  59. }
  60.  
  61. window.addEventListener('load', onLoad, false);