// ==UserScript== // @name podenco // @namespace http://tampermonkey.net/ // @version 1.0 // @description Adds text based on dice4d4 results on 2chan. // @author 1 4 2 2 (9) pocodede... // @match https://img.2chan.net/* // @grant none // ==/UserScript== (function () { 'use strict'; function processDice() { const quotes = document.querySelectorAll('blockquote'); quotes.forEach(quote => { if (quote.dataset.podencoProcessed) return; // Look for the specific text pattern "dice4d4=" // The structure is usually: ... dice4d4=1 2 3 4 (10) let foundDice = false; let fontElement = null; for (let i = 0; i < quote.childNodes.length; i++) { const node = quote.childNodes[i]; // Check for text node containing "dice4d4=" if (node.nodeType === Node.TEXT_NODE && node.textContent.includes('dice4d4=')) { let next = node.nextSibling; while (next && next.nodeType === Node.TEXT_NODE && !next.textContent.trim()) { next = next.nextSibling; } if (next && next.tagName === 'FONT') { foundDice = true; fontElement = next; break; } } } if (foundDice && fontElement) { const diceText = fontElement.textContent; // e.g., "1 2 2 4 (9)" const match = diceText.match(/^(\d)\s+(\d)\s+(\d)\s+(\d)/); if (match) { const numbers = match.slice(1, 5); // ['1', '2', '2', '4'] const map = { '1': 'ぽ', '2': 'で', '3': 'ん', '4': 'こ' }; let resultString = ''; numbers.forEach(num => { if (map[num]) { resultString += map[num]; } }); resultString += '…'; const resultSpan = document.createElement('span'); resultSpan.textContent = ' ' + resultString; resultSpan.style.color = '#ff0000'; resultSpan.style.fontSize = '80%'; if (fontElement.nextSibling) { quote.insertBefore(resultSpan, fontElement.nextSibling); } else { quote.appendChild(resultSpan); } quote.dataset.podencoProcessed = 'true'; } } }); } processDice(); const observer = new MutationObserver((mutations) => { processDice(); }); observer.observe(document.body, { childList: true, subtree: true }); })();