User:Wattz2000/global.js

importScriptPage('AjaxRC/code.js', 'dev'); importScriptPage('AdvancedOasisUI/code.js', 'dev'); $(function { $('.WikiHeaderRestyle div.buttons nav').replaceWith('  Recent Changes '); });

/* Kill message wall */ function KillMessageWall { if(wgPageName != 'User:' + wgUserName + '/talk' && wgPageName != 'User:' + wgUserName + '/Talk') { //check if someone edited your /talk or /Talk page var api = new APIQuery({logger: function {}}); api.newQuery('GET', {action: 'query', prop: 'info', titles: 'User:' + wgUserName + '/talk|User:' + wgUserName + '/Talk'}, function(result) {			var pages = result.query.pages;			for(var i in pages) {				if(i > 0 && pages[i].lastrevid > readCookie('msgwl_' + pages[i].title.substring(pages[i].title.lastIndexOf('/') + 1))) {					var sub = pages[i].title.substring(pages[i].title.lastIndexOf('/') + 1);					if(skin == 'oasis') {						document.getElementById('WikiaFooter').getElementsByTagName('ul')[0].outerHTML += ' You have new messages. ';					}					else {						document.getElementById('contentSub').outerHTML += ' You have new messages (show most recent). ';					}				}			}		});		api.send(0);	}	else {createCookie('msgwl_' + wgPageName.substring(wgPageName.lastIndexOf('/') + 1), wgCurRevisionId, 99999);}	if(wgCanonicalNamespace.indexOf('Message_Wall') == 0 || wgCanonicalNamespace == 'Thread') {		if(document.getElementById('Wall')) { //Page is an actual wall or thread			if(document.getElementById('WallBrickHeader')) {				var header = document.getElementById('WallBrickHeader').getElementsByTagName('a')[0];				header.innerHTML = 'Message Wall:' + header.href.substring(header.href.indexOf('/wiki/Message_Wall:') + '/wiki/Message_Wall:'.length);			}			var blocks = document.getElementById('Wall').getElementsByTagName('blockquote');			for(var i = 0; i < blocks.length; i++) {				if(blocks[i].className == 'speech-bubble-message') {					var div = blocks[i].getElementsByTagName('div');					if(div[0] && div[0].className == 'edited-by') {var links = blocks[i].getElementsByTagName('div')[0].getElementsByTagName('a');} else if(div[0]) {var links = blocks[i].getElementsByTagName('div')[1].getElementsByTagName('a');} if(links[1] && links[1].innerHTML) { links[1].className = ''; links[0].style.display = 'none'; }				}			}		}		else { //Page is history if(skin == 'oasis') {var page = document.getElementById('WikiaArticle');} else {var page = document.getElementById('bodyContent');} var header = page.getElementsByTagName('nav')[0].getElementsByTagName('a')[0]; header.innerHTML = 'Message Wall:' + header.href.substring(header.href.indexOf('/wiki/Message_Wall:') + '/wiki/Message_Wall:'.length); var entries = document.getElementById('WallHistory').getElementsByTagName('tr'); for(var i = 0; i < entries.length; i++) { if(entries[i].className == 'info-entry') { var links = entries[i].getElementsByTagName('a'); if(links[2] && links[2].parentNode.className != 'threadHistory') { links[2].innerHTML = links[2].children[0].innerHTML; links[2].className = ''; links[1].style.display = 'none'; }				}			}		}	} } addOnloadHook(KillMessageWall);

/* Import chat stuff or whatever */ function OpenChatWindow { window.chatwindow = window.open('/index.php?title=Special:Chat&useskin=wikia'); window.chatwindow.onload = function { //addOnloadHook, importScript, and importStylesheet window.chatwindow.$('body').prepend(' \nfunction importScript(b){var a=wgScript+"?title="+encodeURIComponent(b.replace(/ /g,"_")).replace(/%2F/ig,"/").replace(/%3A/ig,":")+"&action=raw&ctype=text/javascript";return importScriptURI(a)}\nfunction importScriptURI(a){var b=document.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");document.getElementsByTagName("head")[0].appendChild(b);return b}\nfunction importScriptPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/javascript";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importScriptURI(a)}\nfunction importStylesheet(a){return importStylesheetURI(wgScript+"?action=raw&ctype=text/css&title="+encodeURIComponent(a.replace(/ /g,"_")))}\nfunction importStylesheetURI(b,d){var a=document.createElement("link");a.type="text/css";a.rel="stylesheet";a.href=b;if(d){a.media=d}document.getElementsByTagName("head")[0].appendChild(a);return a}\nfunction importStylesheetPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/css";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importStylesheetURI(a)}\n//This isn\'t the same as the regular addOnloadHook, because the regular one runs from a script tag in the body that I don\'t feel like appending. It\'s easier to just make it $(function), which is essentially equivalent\nfunction addOnloadHook(func) {$(func);}\n ');                   //global.js                    window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.js&action=raw&ctype=text/javascript');                    //wikia.js                    window.chatwindow.importScriptURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.js&action=raw&ctype=text/javascript');                    //global.css                    window.chatwindow.importStylesheetURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.css&action=raw&ctype=text/css');                    //wikia.css                    window.chatwindow.importStylesheetURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.css&action=raw&ctype=text/css');