XKCD Text Replacer

Replaces text (mostly) according to http://xkcd.com/1288/

  1. // ==UserScript==
  2. // @name XKCD Text Replacer
  3. // @version 1.0
  4. // @description Replaces text (mostly) according to http://xkcd.com/1288/
  5. // @match http://*/*
  6. // @require http://code.jquery.com/jquery-latest.js
  7. // @namespace https://gf.qytechs.cn/users/1858
  8. // ==/UserScript==
  9.  
  10. GM_addStyle(".xkcd_replaced:hover { text-decoration:underline; }");
  11.  
  12. var array = {
  13. "witnesses": "dudes I know",
  14. "allegedly": "kinda probably",
  15. "new study": "Tumblr post",
  16. "rebuild": "avenge",
  17. "space": "spaaace",
  18. "Google Glass": "Virtual Boy",
  19. "smartphone": "Pokédex",
  20. "electric": "atomic",
  21. "senator": "elf-lord",
  22. "car": "cat",
  23. "election": "eating contest",
  24. "congressional leaders": "river spirits",
  25. "Homeland Security": "Homestar Runner",
  26. "could not be reached for comment": "is guilty and everyone knows it"
  27. };
  28. $(function(){
  29. $("body")
  30. .find("*")
  31. .contents()
  32. .filter(function() {
  33. return this.nodeType === 3; //Node.TEXT_NODE
  34. })
  35. .each(function(){
  36. var text = $(this).text();
  37. for (var val in array){
  38. text = text.replace(new RegExp("\\b" + val + "\\b", "gi"), "<span class='xkcd_replaced' title='" + val + "'>" + array[val] + "</span>");
  39. }
  40. $(this).replaceWith(text);
  41. });
  42. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址