MediaWiki:Chat.js

// Chatango in the wiki. Adapted from Dead Island Wiki. var hasClass = (function {   var reCache = {};   return function (element, className) {      return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);  }; }); function getElementsByClass(elementName, tagname, tclass){ var itemsfound = new Array; var elements = elementName.getElementsByTagName(tagname); for(var i=0;i<elements.length;i++){ if(hasClass(elements[i], tclass)){ itemsfound.push(elements[i]); }	}	return itemsfound; } function insertChatangoSection{ var chatSection = getElementsByClass(document, 'section', 'ChatModule'); if(chatSection[0] != null) chatSection[0].parentNode.removeChild(chatSection[0]); var section = getElementsByClass(document, 'section', 'WikiaBlogListingBox')[0]; if(section == null){ section = getElementsByClass(document, 'section', 'LatestPhotosModule')[0]; if(section == null){ section = getElementsByClass(document, 'section', 'CommunityCornerModule')[0]; if(section == null){ section = getElementsByClass(document, 'div', 'AchievementsModule')[0]; if(section == null){ section = getElementsByClass(document, 'section', 'FollowedPagesModule')[0]; if(section == null){ section = getElementsByClass(document, 'section', 'WikiaLatestEarnedBadgesModule')[0]; if(section == null){ section = document.getElementById('WikiaSpotlightsModule'); if(section == null) return; }					}				}			}		}	}	var newSection = document.createElement("section"); newSection.innerHTML = '  [ Copy this | Start New | Full Size ] '; newSection.setAttribute('class',"module ChatangoModule"); if (section.parentNode.className=='WikiaRail') { section.parentNode.insertBefore(newSection,section); } } addOnloadHook(insertChatangoSection);