Elon Musk Replacer

Replaces mentions of Elon Musk with a more accurate representation 🤏🍆

  1. // ==UserScript==
  2. // @name Elon Musk Replacer
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Replaces mentions of Elon Musk with a more accurate representation 🤏🍆
  6. // @author Dogecoin Hash
  7. // @match *://*/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. /*
  13. MIT License
  14.  
  15. Copyright (c) 2024 Your Name
  16.  
  17. Permission is hereby granted, free of charge, to any person obtaining a copy
  18. of this software and associated documentation files (the "Software"), to deal
  19. in the Software without restriction, including without limitation the rights
  20. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21. copies of the Software, and to permit persons to whom the Software is
  22. furnished to do so, subject to the following conditions:
  23.  
  24. The above copyright notice and this permission notice shall be included in all
  25. copies or substantial portions of the Software.
  26.  
  27. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  28. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  29. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  30. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  31. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  32. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  33. SOFTWARE.
  34. */
  35.  
  36. (function() {
  37. 'use strict';
  38. const targetText = /Elon Musk/gi;
  39. const replacement = '🤏🍆';
  40. function replaceTextContent(node) {
  41. if (node.nodeType === Node.TEXT_NODE) {
  42. node.nodeValue = node.nodeValue.replace(targetText, replacement);
  43. }
  44. else if (node.nodeType === Node.ELEMENT_NODE &&
  45. !['SCRIPT', 'STYLE', 'NOSCRIPT', 'IFRAME', 'OBJECT', 'TEXTAREA', 'CODE'].includes(node.nodeName)) {
  46. node.childNodes.forEach(replaceTextContent);
  47. }
  48. }
  49.  
  50. function periodicCheck() {
  51. replaceTextContent(document.body);
  52. }
  53.  
  54. periodicCheck();
  55. setInterval(periodicCheck, 5000);
  56. })();