Rate my shitty userscript.
// ==UserScript==
// @name 4chan get highlighter
// @version 1.0.0
// @match *://boards.4chan.org/*
// @grant none
// @noframes
// @author Anonymous
// ==/UserScript==
const colors = [
"#999",
"#a66f37",
"#e96060",
"#59fff7",
"#0F0",
"#F00",
"#F0F",
"#59fff7",
];
const css = new CSSStyleSheet();
for (let i = 0; i < colors.length; i++) {
css.insertRule("a:not(:hover) .get-rpt"+(i+2)+" { color: " + colors[i] + "; }");
}
document.adoptedStyleSheets.push(css);
let errorred = false;
function highlight() {
const els = document.getElementsByClassName("postNum");
for (let i = 0; i < els.length; i++) {
try {
const link = els[i].getElementsByTagName("a")[1];
if (link.dataset.gotten) continue;
link.dataset.gotten = true;
const str = link.innerText;
const len = str.length;
const c = str[len-1];
let rpt = 1;
for (let j = len - 2; j >= 0; j--) {
if (str[j] == c)
rpt++;
else break;
}
if (rpt === 1) continue;
const newstr = str.slice(0, len - rpt) + `<span class="get-rpt${rpt}">` + str.slice(len-rpt) + '</span>';
link.innerHTML = newstr;
} catch (error) {
if (!errorred) console.log(error);
errorred = true;
}
}
}
highlight();
const observer = new MutationObserver(highlight);
observer.observe(document.body, {subtree: true, childList: true});