XKCD Text Replacer

Replaces text (mostly) according to http://xkcd.com/1288/ , http://www.xkcd.com/1625/ , and http://www.xkcd.com/1679/ , as well as http://www.xkcd.com/821/ , http://www.xkcd.com/1004/ , http://www.xkcd.com/1025/ , http://www.xkcd.com/1031/ , and http://www.xkcd.com/1418/ . This script is just an update of https://greasyfork.org/en/scripts/1322-xkcd-text-replacer

  1. // ==UserScript==
  2. // @name XKCD Text Replacer
  3. // @version 2.1
  4. // @description Replaces text (mostly) according to http://xkcd.com/1288/ , http://www.xkcd.com/1625/ , and http://www.xkcd.com/1679/ , as well as http://www.xkcd.com/821/ , http://www.xkcd.com/1004/ , http://www.xkcd.com/1025/ , http://www.xkcd.com/1031/ , and http://www.xkcd.com/1418/ . This script is just an update of https://greasyfork.org/en/scripts/1322-xkcd-text-replacer
  5. // @match http://*/*
  6. // @require http://code.jquery.com/jquery-latest.js
  7. // @namespace https://greasyfork.org/en/users/43235-mind-combatant
  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. "debate": "dance-off",
  28. "self driving": "uncontrollably swerving",
  29. "poll": "psychic reading",
  30. "candidate": "airbender",
  31. "drone": "dog",
  32. "vows to": "probably won't",
  33. "at large": "very large",
  34. "successfully": "suddenly",
  35. "expands": "physically expands",
  36. "first-degree": "friggin' awful",
  37. "second-degree": "friggin' awful",
  38. "third-degree": "friggin' awful",
  39. "an unknown number": "like hundreds",
  40. "front runner": "blade runner",
  41. "global": "spherical",
  42. "years": "minutes",
  43. "minutes": "years",
  44. "no indication": "lots of signs",
  45. "urged restraint by": "drunkenly egged on",
  46. "horsepower": "tons of horsemeat",
  47. "gaffe": "magic spell",
  48. "ancient": "haunted",
  49. "star-studded": "blood-soaked",
  50. "remains to be seen": "will never be known",
  51. "silver bullet": "way to kill werewolves",
  52. "subway system": "tunnels I found",
  53. "surprising": "surprising (but not to me)",
  54. "war of words": "interplanetary war",
  55. "tension": "sexual tension",
  56. "cautiously optimistic": "delusional",
  57. "Doctor Who": "The Big Bang Theory",
  58. "win votes": "find Pokémon",
  59. "behind the headlines": "beyond the grave",
  60. "email": "poem",
  61. "Facebook post": "poem",
  62. "tweet": "poem",
  63. "Facebook CEO": "this guy",
  64. "latest": "final",
  65. "disrupt": "destroy",
  66. "meeting": "ménage à trois",
  67. "scientists": "Channing Tatum and his friends",
  68. "you won't believe": "I'm really sad about",
  69. "I think that": "I saw a study once that said",
  70. "Batman": "a man dressed like a bat",
  71. " would be a good name for a band": ".tumblr.com",
  72. "keyboard": "leopard",
  73. "force": "horse"
  74. };
  75. $(function(){
  76. $("body")
  77. .find("*")
  78. .contents()
  79. .filter(function() {
  80. return this.nodeType === 3; //Node.TEXT_NODE
  81. })
  82. .each(function(){
  83. var text = $(this).text();
  84. for (var val in array){
  85. text = text.replace(new RegExp("\\b" + val + "\\b", "gi"), "<span class='xkcd_replaced' title='" + val + "'>" + array[val] + "</span>");
  86. }
  87. $(this).replaceWith(text);
  88. });
  89. });