// ==UserScript== // @name Hitbox Greentexting // @namespace HitboxGreentexting // @include http://www.hitbox.tv/embedchat/* // @include http://www.hitbox.tv/* // @version 0.1 // @description Enables greentexting to the Hitbox chat // @author purplebutt // ==/UserScript== // Initialize and begin main loop window.onload = function() { addCSS(); setInterval( function() { greentextify(); }, 200); } function addCSS() { // Creates the greentext user style var css = document.createElement('style'); css.type = 'text/css'; css.innerHTML = '.greentext { color: #789922;}'; document.head.appendChild(css); } function greentextify() { // Gets all chat messages var chatMsgs = document.getElementsByClassName("message-user"); if (chatMsgs) { // Loops through them... for ( var i = 0; i < chatMsgs.length; i++ ) { var msg = chatMsgs[i]; // if it begins with ">"... if ( msg.textContent.charAt(0) == ">" ) { ??// ... and if it doesn't already have been greentext'd ... if ( !msg.className.contains("greentext") ) { // greentext it! msg.className += " greentext"; } } } } }