Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name 4chan umineko colored truths
- // @description enable umineko colored truths on 4chan
- // @version 5
- // @grant none
- // @include *//boards.4chan.org/*
- // @include *//boards.4channel.org/*
- // @namespace https://greasyfork.org/users/141341
- // ==/UserScript==
- function process() {
- var posts = document.getElementsByClassName('postMessage');
- for (var post of posts) {
- for (var i = 0; i < post.childNodes.length; ++i) {
- var node = post.childNodes[i];
- if (node.nodeName == '#text') {
- var a, b;
- a = node.textContent.indexOf('[red]');
- b = node.textContent.indexOf('[/red]', a);
- if (a != -1 && b != -1 && a < b) {
- var span = document.createElement("span");
- span.textContent = node.textContent.substring(a + 5, b);
- span.style='color:#ff0000';
- var prefix = document.createTextNode(node.textContent.substring(0, a));
- node.textContent = node.textContent.substring(b + 6);
- post.insertBefore(prefix, node);
- post.insertBefore(span, node);
- --i;
- continue;
- }
- a = node.textContent.indexOf('[blue]');
- b = node.textContent.indexOf('[/blue]', a);
- if (a != -1 && b != -1 && a < b) {
- var span = document.createElement("span");
- span.textContent = node.textContent.substring(a + 6, b);
- span.style='color:#3be2ff';
- var prefix = document.createTextNode(node.textContent.substring(0, a));
- node.textContent = node.textContent.substring(b + 7);
- post.insertBefore(prefix, node);
- post.insertBefore(span, node);
- --i;
- continue;
- }
- a = node.textContent.indexOf('[purple]');
- b = node.textContent.indexOf('[/purple]', a);
- if (a != -1 && b != -1 && a < b) {
- var span = document.createElement("span");
- span.textContent = node.textContent.substring(a + 8, b);
- span.style='color:purple';
- var prefix = document.createTextNode(node.textContent.substring(0, a));
- node.textContent = node.textContent.substring(b + 9);
- post.insertBefore(prefix, node);
- post.insertBefore(span, node);
- --i;
- continue;
- }
- a = node.textContent.indexOf('[gold]');
- b = node.textContent.indexOf('[/gold]', a);
- if (a != -1 && b != -1 && a < b) {
- var span = document.createElement("span");
- span.textContent = node.textContent.substring(a + 6, b);
- span.style='color:gold';
- var prefix = document.createTextNode(node.textContent.substring(0, a));
- node.textContent = node.textContent.substring(b + 7);
- post.insertBefore(prefix, node);
- post.insertBefore(span, node);
- --i;
- continue;
- }
- a = node.textContent.indexOf('[magenta]');
- b = node.textContent.indexOf('[/magenta]', a);
- if (a != -1 && b != -1 && a < b) {
- var span = document.createElement("span");
- span.textContent = node.textContent.substring(a + 6, b);
- span.style='color:#ff00ff';
- var prefix = document.createTextNode(node.textContent.substring(0, a));
- node.textContent = node.textContent.substring(b + 7);
- post.insertBefore(prefix, node);
- post.insertBefore(span, node);
- --i;
- continue;
- }
- }
- }
- }
- }
- process();
- document.addEventListener('4chanXInitFinished', function(e) {
- process();
- });
- document.addEventListener('ThreadUpdate', function(e) {
- process();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement