Advertisement
Guest User

Umineko colored script

a guest
Jun 13th, 2021
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. // ==UserScript==
  2. // @name 4chan umineko colored truths
  3. // @description enable umineko colored truths on 4chan
  4. // @version 5
  5. // @grant none
  6. // @include *//boards.4chan.org/*
  7. // @include *//boards.4channel.org/*
  8. // @namespace https://greasyfork.org/users/141341
  9. // ==/UserScript==
  10. function process() {
  11. var posts = document.getElementsByClassName('postMessage');
  12. for (var post of posts) {
  13. for (var i = 0; i < post.childNodes.length; ++i) {
  14. var node = post.childNodes[i];
  15. if (node.nodeName == '#text') {
  16. var a, b;
  17. a = node.textContent.indexOf('[red]');
  18. b = node.textContent.indexOf('[/red]', a);
  19. if (a != -1 && b != -1 && a < b) {
  20. var span = document.createElement("span");
  21. span.textContent = node.textContent.substring(a + 5, b);
  22. span.style='color:#ff0000';
  23. var prefix = document.createTextNode(node.textContent.substring(0, a));
  24. node.textContent = node.textContent.substring(b + 6);
  25. post.insertBefore(prefix, node);
  26. post.insertBefore(span, node);
  27. --i;
  28. continue;
  29. }
  30. a = node.textContent.indexOf('[blue]');
  31. b = node.textContent.indexOf('[/blue]', a);
  32. if (a != -1 && b != -1 && a < b) {
  33. var span = document.createElement("span");
  34. span.textContent = node.textContent.substring(a + 6, b);
  35. span.style='color:#3be2ff';
  36. var prefix = document.createTextNode(node.textContent.substring(0, a));
  37. node.textContent = node.textContent.substring(b + 7);
  38. post.insertBefore(prefix, node);
  39. post.insertBefore(span, node);
  40. --i;
  41. continue;
  42. }
  43. a = node.textContent.indexOf('[purple]');
  44. b = node.textContent.indexOf('[/purple]', a);
  45. if (a != -1 && b != -1 && a < b) {
  46. var span = document.createElement("span");
  47. span.textContent = node.textContent.substring(a + 8, b);
  48. span.style='color:purple';
  49. var prefix = document.createTextNode(node.textContent.substring(0, a));
  50. node.textContent = node.textContent.substring(b + 9);
  51. post.insertBefore(prefix, node);
  52. post.insertBefore(span, node);
  53. --i;
  54. continue;
  55. }
  56. a = node.textContent.indexOf('[gold]');
  57. b = node.textContent.indexOf('[/gold]', a);
  58. if (a != -1 && b != -1 && a < b) {
  59. var span = document.createElement("span");
  60. span.textContent = node.textContent.substring(a + 6, b);
  61. span.style='color:gold';
  62. var prefix = document.createTextNode(node.textContent.substring(0, a));
  63. node.textContent = node.textContent.substring(b + 7);
  64. post.insertBefore(prefix, node);
  65. post.insertBefore(span, node);
  66. --i;
  67. continue;
  68. }
  69. a = node.textContent.indexOf('[magenta]');
  70. b = node.textContent.indexOf('[/magenta]', a);
  71. if (a != -1 && b != -1 && a < b) {
  72. var span = document.createElement("span");
  73. span.textContent = node.textContent.substring(a + 6, b);
  74. span.style='color:#ff00ff';
  75. var prefix = document.createTextNode(node.textContent.substring(0, a));
  76. node.textContent = node.textContent.substring(b + 7);
  77. post.insertBefore(prefix, node);
  78. post.insertBefore(span, node);
  79. --i;
  80. continue;
  81. }
  82. }
  83. }
  84. }
  85. }
  86. process();
  87. document.addEventListener('4chanXInitFinished', function(e) {
  88. process();
  89. });
  90. document.addEventListener('ThreadUpdate', function(e) {
  91. process();
  92. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement