User:Mfaizsyahmi/wikia.js

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 rail = getElementsByClass(document, 'div', 'WikiaRail'); if(rail != null){ var chatSection = getElementsByClass(rail, 'section', 'ChatModule'); if(chatSection[0] != null) chatSection[0].parentNode.removeChild(chatSection[0]); var section = getElementsByClass(rail, 'section', 'WikiaBlogListingBox')[0]; if(section == null){ section = getElementsByClass(rail, 'section', 'LatestPhotosModule')[0]; if(section == null){ section = getElementsByClass(rail, 'section', 'CommunityCornerModule')[0]; if(section == null){ section = getElementsByClass(rail, 'div', 'AchievementsModule')[0]; if(section == null){ section = getElementsByClass(rail, 'section', 'FollowedPagesModule')[0]; if(section == null){ section = getElementsByClass(rail, '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"); if (section.parentNode.className=='WikiaRail') { section.parentNode.insertBefore(newSection,section); } } addOnloadHook(insertChatangoSection);