MediaWiki:SWU Super Walkthrough rewriteWikiaPageTitle JS

 /********************************************************** * rewriteWikiaPageTitle * * Written to be a much safer alternative to the previous * title rewrite script, while also adding support for * multiple skins. * * By jgjake2 * Profile: http://deadisland.wikia.com/wiki/User:Jgjake2 * Contact me if you have any questions or concerns **********************************************************/	var whiteListTags = ['a','div','img', 'span', 'b', 'i', 'br'], skinNames = ['monobook', 'oasis', 'wikiamobile', 'mercury'], allowedAttrs = ['id', 'class', 'style', 'height', 'width']; function getSkin{ var _skin, check = function{ if (typeof _skin == "string"){ _skin = _skin.toLowerCase; if(_skin == 'ember' || _skin == 'ember-application') _skin = 'mercury'; if(skinNames.indexOf(_skin) > -1) {return true;} }			};		if ($('body.wkMobile').length) { _skin = 'wikiamobile'; } else if ($('body.ember-application').length) { _skin = 'mercury'; } else if ($('body.skin-oasis').length) { _skin = 'oasis'; }		if (check) return _skin; _skin = window.skin || window.kruxDartParam_skin;
 * (function(global){

if (check) return _skin; if(typeof mw == "object" && mw.config && mw.config.get){ _skin = mw.config.get('skin'); if (check) return _skin; }		return null; }	var whiteListPages = [ /^[^\?\#]+Wookieepedia\:Star_Wars\:_Uprising_Super_Walkthrough\//i ];	function isPageEnabled(url){ var checkItem = function(item){ var type = typeof item; if (type == "string") { return (item === url); } else if (type == "function") { var r;				try { r = item(url); } catch(e) {} return (r === true); } else if (item instanceof RegExp) { return item.test(url); }					};		for(var i = 0; i < whiteListPages.length; i++){ if(checkItem(whiteListPages[i])){ return true; }		}	}	/*************************	 * rewriteWikiaPageTitle *************************/	function rewriteWikiaPageTitle { var align = '', fontFamily = null, $titleChange = $('#wikia-title-change'), $titleAlign = $('#wikia-title-align'), $titleFont = $('#wikia-title-font'), $header; if (window.SKIP_TITLE_REWRITE || !$titleChange || !$titleChange.length) return; // Remove comment to enable page white list //try{if(!isPageEnabled(window.location.href)) return;}catch(e){console.log('rewriteWikiaPageTitle url test fail', e)} var _skin = getSkin, cleanTitle; if($titleChange.children.length) { $titleChange.find('*').each(function {				var $this = $(this);				if ($.inArray(this.nodeName.toLowerCase, whiteListTags) == -1) {					$this.remove;				} else {					var attributes = $.map(this.attributes, function(item) { return item.name; });					$.each(attributes, function(i, item) { if(allowedAttrs.indexOf(item.toLowerCase) > -1) $this.removeAttr(item); });				}			});			cleanTitle = $titleChange.html; } else { try { cleanTitle = $titleChange.text; } catch(e) { cleanTitle = $titleChange.html; }			try { cleanTitle = cleanTitle.replace(/\/g, '&gt;').replace(/on(?:load|click|dblclick|mousedown|mouseup|mousemove|mouseover|mouseleave|mouseout)\s*\=\s*(?:\"|\')/gi, 'x').trim;			} catch(e) {}		}		$titleChange.remove;		if ($titleAlign && $titleAlign.length) {			try {				align = $titleAlign.text || ;			} catch(e) {}			if(!align || ['left', 'right', 'center', 'justify', 'initial', 'inherit'].indexOf(align.toLowerCase) == -1) align = ;			$titleAlign.remove;		}		if ($titleFont && $titleFont.length) {			try {				fontFamily = $titleFont.text || ;				if(fontFamily){					fontFamily = fontFamily.replace(/[^\w\-\,\s\"\'_]/gi, ).trim; }			} catch(e) {} $titleFont.remove; }		if (cleanTitle && cleanTitle.trim.length < 200) { // Try and prevent spam with length cap switch(_skin || '') { case 'wikiamobile': $header = $('#wkMainCntHdr > h1'); break; case 'mercury': $header = $('.article-body > .article-title'); break; case 'oasis': $header = $('header.WikiaPageHeader > .header-container > .header-title > h1'); break; default: try {$header = $($('.firstHeading').get(0));} catch(e) {} break; }			if ($header && $header.length) { $header.empty.append(cleanTitle); if(align) $header.css('text-align', align); if(fontFamily) $header.css('font-family', fontFamily); }		}	}	/*********************	 * On Page Ready *********************/	var isReady = false; function onReady { if(isReady) return; isReady = true; try { rewriteWikiaPageTitle; } catch(e) { console.log('rewriteWikiaPageTitle Error', e); }	}	function checkState{ if(document.readyState == 'complete' || (document.getElementById('wikia-title-change') && typeof $ !== "undefined")){ setTimeout(onReady, 0); return true; }	}	if (!checkState) { if(typeof $ !== "undefined") $(onReady); // Make sure jQuery is available first! document.onreadystatechange = checkState; window.onload = onReady; }	if(!global.rewriteWikiaPageTitle){ global.rewriteWikiaPageTitle = rewriteWikiaPageTitle; } })(this);	display: none !important; }
 * 1) wikia-title-change,
 * 2) wikia-title-align,
 * 3) wikia-title-font {