User:TheBen10Mazter/global.js

1./* get all personal code files in chat */ 2./* Important: you must click the chat button in the rail for this to work. */ 3./* 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. */ 4.$(function { 5.        window.chatcheck = setInterval('ChatCheck', 200); 6.        if(skin == 'monobook') { 7.                var a = document.getElementsByTagName('a'); 8.                for(var i in a) { 9.                        if(a[i].href.indexOf('/wiki/Special:Chat') != -1) { 10.                                a[i].href = 'javascript:OpenChatWindow; return false;'; 11.                        } 12.                } 13.        } 14.}); 15. 16.function ChatCheck { 17.       if($('.chat-join button').length != 0) { 18.               $('.chat-join button').replaceWith('Join the Chat'); 19.               clearInterval(window.chatcheck); 20.       } 21.} 22. 23.function OpenChatWindow { 24.       window.chatwindow = window.open('/index.php?title=Special:Chat&useskin=wikia'); 25.       window.chatwindow.onload = function  { 26.               //addOnloadHook, importScript, and importStylesheet 27.               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 '); 28.               //global.js 29.                window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.js&action=raw&ctype=text/javascript'); 30.                //wikia.js 31.                window.chatwindow.importScriptURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.js&action=raw&ctype=text/javascript'); 32.                //global.css 33.                window.chatwindow.importStylesheetURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.css&action=raw&ctype=text/css'); 34.                //wikia.css 35.                window.chatwindow.importStylesheetURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.css&action=raw&ctype=text/css'); 36. 37. //These are my chat hacks. If you don't want them, you can delete this line. 38.               window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:Monchoman45/ChatHacks.js&action=raw&ctype=text/javascript'); 39.       } 40.}