// ==UserScript== // @name Three Aho // @namespace https://TakeAsh.net/ // @version 2024-10-19 11:00 // @description if res_no is multiple of 3, then aho // @author TakeAsh68k // @match https://*.2chan.net/*/res/* // @match http://*.2chan.net/*/res/* // @match https://tsumanne.net/*/data/* // @match https://kako.futakuro.com/futa/* // @match https://*.ftbucket.info/*/cont/* // @icon https://www.google.com/s2/favicons?sz=64&domain=2chan.net // @grant none // ==/UserScript== javascript: (async (d) => { 'use strict'; const ahos = ['', '\u{1F92A}', '\u{1F61C}']; const ids = { cat: '\u{1F431}', dog: '\u{1F436}', fox: '\u{1F98A}', pig: '\u{1F437}', uma: '\u{1F434}', usi: '\u{1F42E}', }; const regIds = new RegExp(`(${Object.keys(ids).join('|')})`, 'gi'); await sleep(3000); const styleThreeAho = d.createElement('style'); styleThreeAho.textContent = '.mark { color: #f00; }'; d.head.appendChild(styleThreeAho); const target = d.body.querySelector('div[class="thre"],div[class="text"]') || d.body; checkAho(target); checkId(target); const observer = new MutationObserver( (mutations) => mutations.forEach( (mutation) => { checkAho(mutation.target); checkId(mutation.target); })); observer.observe(target, { childList: true, subtree: true, }); function sleep(ms, resolve) { return new Promise((resolve) => setTimeout(resolve, ms)); } function checkAho(node) { if (!node) { return; } let aho; Array.from(node.querySelectorAll('span[class="cno"],a[class="postno"],span[class="no_quote"]')) .filter(span => !span.dataset.aho) .forEach(span => { span.dataset.aho = 1; if (!(aho = isAho(span))) { return; } span.innerHTML += ahos[aho]; }); } function isAho(span) { const m = span.textContent.match(/No\.(?\d+)/); if (!m) { return 0; } const cno = m.groups['cno']; return cno % 3 == 0 ? 1 : cno.indexOf('3') >= 0 ? 2 : 0; } function checkId(node) { if (!node) { return; } Array.from(node.querySelectorAll('span[class="cnw"],span[class="user-id"],span[class="idip"]')) .filter(span => !span.dataset.idCat) .forEach(span => { span.dataset.idCat = 1; let hit = ''; span.innerHTML = span.innerHTML.replace(regIds, (w, p1) => { hit += ids[p1.toLowerCase()]; return `${p1}`; }) + hit; }); } })(document);