Text Replacer Troll

Replaces all text on a webpage with the letter A

当前为 2024-06-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Text Replacer Troll
  3. // @namespace ReplaceTextInElements
  4. // @version 1.1
  5. // @description Replaces all text on a webpage with the letter A
  6. // @author ArpaRec
  7. // @match *://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Change this to the HTML code of the element you want to replace with
  15. const replaceHTML = '<img src="https://upload.wikimedia.org/wikipedia/uk/thumb/7/78/Trollface.svg/1200px-Trollface.svg.png" width=50px>';
  16.  
  17. function replaceElements() {
  18. const elementsToReplace = document.querySelectorAll("p, span, h1, h2, h3, h4, h5, h6, li, a"); // Select all elements
  19.  
  20. for (const element of elementsToReplace) {
  21. const replacement = document.createElement("div"); // Temporary container
  22. replacement.innerHTML = replaceHTML; // Set replacement HTML content
  23.  
  24. // Extract the actual replacement element from the temporary container
  25. const actualReplacement = replacement.firstChild;
  26.  
  27. element.parentNode.replaceChild(actualReplacement, element);
  28. }
  29. }
  30.  
  31. replaceElements();
  32. })();
  33.