Replace Reiner with Reiner

Replaces all occurrences of 雷纳 with Reiner on web pages.

  1. // ==UserScript==
  2. // @name Replace Reiner with Reiner
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Replaces all occurrences of 雷纳 with Reiner on web pages.
  6. // @author You
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. function replaceText(node) {
  16. if (node.nodeType === Node.TEXT_NODE) {
  17. node.nodeValue = node.nodeValue.replace(/雷纳/g, "reiner");
  18. } else if (node.nodeType === Node.ELEMENT_NODE) {
  19. for (const child of node.childNodes) {
  20. replaceText(child);
  21. }
  22. }
  23. }
  24.  
  25. const observer = new MutationObserver((mutations) => {
  26. mutations.forEach((mutation) => {
  27. if (mutation.type === "childList") {
  28. mutation.addedNodes.forEach((node) => {
  29. replaceText(node);
  30. });
  31. }
  32. });
  33. });
  34.  
  35. observer.observe(document.body, { childList: true, subtree: true });
  36.  
  37. // Initial replacement
  38. replaceText(document.body);
  39. })();