User:Mr. Grille/global.js

/* get all personal code files in chat */ /* Important: you must click the chat button in the rail for this to work. */   /* Very important: Chat is still a beta feature. Chat hacks may break as the feature is changed and updated, as it is a work in progress. */   $(setTimeout('ChatCheck', 200)); function ChatCheck { if($('.chat-join button').length != 0) { $('.chat-join button').replaceWith('Join the Chat'); } else { setTimeout('ChatCheck', 200); }   }    function OpenChatWindow { window.chatwindow = window.open('/wiki/Special:Chat'); 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');                    //These are my chat hacks. If you don't want them, you can delete this line. window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:Monchoman45/ChatHacks.js&action=raw&ctype=text/javascript'); }   }

window.onload = function UseVector { var li = document.createElement('li'); var query = ''; for(i in location.href.split('?')) { if(location.href.split('?')[i].split('=')[0] == 'title') { for(j = 1; j < location.href.split('?')[i].split('&').length; j++) { if(location.href.split('?')[i].split('&')[j].split('=')[0] != 'useskin') {query += '&' + location.href.split('?')[i].split('&')[j];} }                   }            }            if(skin == 'oasis') { li.innerHTML = 'Vector' document.getElementById('AccountNavigation').insertBefore(li, document.getElementById('AccountNavigation').firstChild); }           if(skin == 'vector') { var url = ''; var urlquery = ''; var quot = ''; var title = ''; for(i = 0; i < document.getElementsByTagName('a').length; i++) { url = document.getElementsByTagName('a')[i].href; urlquery = ''; if(url.indexOf('?') != -1) { quot = url.split('?'); for(j in quot) { if(quot[j].split('=')[0] == 'title') { title = quot[j].split('=')[1].split('&')[0]; for(k = 1; k < quot[j].split('&').length; k++) { if(quot[j].split('&')[k].split('=')[0] != 'useskin') {urlquery += '&' + quot[j].split('&')[k];} }                                           }                                    }                            }                            else { title = url.split('.')[url.split('.').length - 1].substring(url.split('.')[url.split('.').length - 1].indexOf('/', 4) + 1, url.length); }                           document.getElementsByTagName('a')[i].href = '/index.php?title=' + title + urlquery + '&useskin=vector'; }                   li.innerHTML = ' Oasis ' document.getElementById('p-namespaces').getElementsByTagName('ul')[0].appendChild(li); }   }