// ==UserScript== // @name YenTxt 4Chan // @description adds purple text to yen signs(¥). Alt code 0165 on EN US keyboards // @author tested and developed by /qa/ // @namespace /qa/ // @version 2016.10.17.1 // @match *://boards.4chan.org/* // @grant none // @downloadURL none // ==/UserScript== function makePurple(root){ if(root.nodeType !== Node.ELEMENT_NODE){ return; } var nodes = Array.from(root.getElementsByClassName('postMessage')); if(root.classList.contains('postmessage')){ nodes.unshift(root); } nodes.forEach(function(node){ if(node.textContent.indexOf('\xa5') <= -1){ return; } var txtItterator = document.createNodeIterator(node, NodeFilter.SHOW_TEXT); var txtNode; while((txtNode = txtItterator.nextNode())){ var hashIndex = txtNode.textContent.indexOf('\xa5'); if(hashIndex > -1){ var splitNode = txtNode.splitText(hashIndex); var span = document.createElement('span'); span.style.color = "#9370DB"; span.className = "the_m_Word"; span.appendChild(splitNode); txtNode.parentNode.insertBefore(span, txtNode.nextSibling); txtItterator.nextNode(); } } }); } makePurple(document.body); new MutationObserver(function(mutations){ mutations.forEach(function(mutation){ mutation.addedNodes.forEach(makePurple); }); }).observe(document.body, {childList: true, subtree: true});