User:Z.E.R.O./monobook.js
From Wikipedia, the free encyclopedia
If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
//<pre><nowiki> //First loads importScript('User:Voice_of_All/Addtabs/monobook.js'); importScript('User:Voice_of_All/replacetxt.js'); //weird stuff importScript('User:Voice_of_All/Specialadmin/monobook.js'); //bcrat stuff importScript('User:Voice_of_All/Bureaucrat/monobook.js'); importScript('User:Voice_of_All/History/monobook.js'); //CU stuff importScript('User:Voice_of_All/CheckUser/monobook.js'); //BAG stuff importScript('User:Voice_of_All/Approvals.js'); //rollback importScript('User:Voice_of_All/Revert.js'); //New pages tools importScript('User:Voice_of_All/Sleeper/monobook.js'); importScript('User:Voice_of_All/Adminwarnings/monobook.js'); importScript('User:Voice_of_All/Deletion/monobook.js'); importScript('User:Voice_of_All/Google/monobook.js'); //Wikiscripts importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu'); importScript('Wikipedia:WikiProject User scripts/Scripts/addLink'); //monobook.js importScript('User:Z.E.R.O./AzaToth.js'); importScript('User:Z.E.R.O./Cacycle.js') importScript('User:Z.E.R.O./Essjay.js'); importScript('User:Z.E.R.O./GeorgeMoney.js'); importScript('User:Z.E.R.O./Shadow1.js'); //Edit top section importScript('User:Alex_Smotrov/edittop.js'); //</nowiki></pre> ////<pre><nowiki> //Toolbox links function changelinks() { if(!document.getElementById) return; var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0]; var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML; if (document.title.indexOf('User:' + user_name + '/xml') != -1 || document.title.indexOf('User:' + user_name + '/XML') != -1) {addlilink(toplinks, 'javascript:XMLrequestprompt()', 'Request XML', 'Request XML');} document.getElementById('pt-mytalk').firstChild.innerHTML = 'talk'; document.getElementById('pt-preferences').firstChild.innerHTML = 'preferences'; document.getElementById('pt-watchlist').firstChild.innerHTML = 'watchlist'; document.getElementById('pt-mycontris').firstChild.innerHTML = 'contributions'; document.getElementById('pt-logout').firstChild.innerHTML = 'log out'; if(document.getElementById('ca-delete')) {document.getElementById('ca-delete').firstChild.innerHTML = '<strong><span style="color:darkred;">delete</span></strong>';} } function navigationlinks() { addnavbox_link('/wiki/Wikipedia:Administrator_intervention_against_vandalism','Vandalism','aiv-ln'); addnavbox_link('/wiki/Category:Candidates_for_speedy_deletion','Speedy deletions','speedy-ln'); addnavbox_link('/wiki/Wikipedia:Requests for page protection','Protection requests','rfpp-ln'); addnavbox_link('/wiki/Wikipedia:Administrators%27_noticeboard','Noticeboard','AN-ln'); } function addtoolboxlinks() { var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, '/wiki/Special:Newpages', 'New pages', ''); addlilink(tb, '/wiki/Special:Log/newusers', 'New users', ''); addlilink(tb, '/wiki/WP:PP', 'Protected pages', ''); } //</nowiki></pre> ////<pre><nowiki> // USER TABS function userlogs() { //no subpages or history if (document.title.search("/") != -1 || location.href.search(/Special:|&action=[^p]|&diff=/) !=-1) {return;} if (document.title.indexOf("User:") == 0 || document.title.indexOf("User talk:") == 0) { username_a = document.URL.match(/:.*:(.*)/); username=username_a[1]; addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username, "log", "ca-blog", "block log", ""); addTab("http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "info", "ca-kate", "user info", ""); } } //</nowiki></pre> ////<pre><nowiki> //MAIN addOnloadHook(Mainfast) function Mainfast() { userlogs(); changelinks(); navigationlinks(); addtoolboxlinks(); } window.onload = Main; function Main() { watchlist_tab(); block_check(); lastdiff(); addtoplink(); } //END //************ function watchlist_tab() { if (location.href.indexOf('Special:Watchlist/edit') !=-1) {addTab("javascript:watchlist_clean()", "check deleted pages", "ca-clean", "check all deleted pages", "");} } function watchlist_clean() { //monobook if (document.getElementById('bodyContent')) { var body = document.getElementById('bodyContent'); } //cologneblue else if (document.getElementById('quickbar')) { if (!document.getElementById('content')){return;} var body = document.getElementById('content'); } var l = body.getElementsByTagName('li'); for (var i=0; i<l.length; i++) { if (l[i].getElementsByTagName('a')[0].href.indexOf('&action=') !=-1) {l[i].getElementsByTagName('input')[0].checked=true;} } } function block_check() { if (document.title.indexOf('Block user') !=0){return;} //monobook if (document.getElementById('pt-userpage')) {var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML;} //cologneblue else if (document.getElementById('quickbar') && document.getElementById('quickbar').getElementsByTagName('h6')[0]) { var toplinks = document.getElementById('quickbar'); var user_name = toplinks.innerHTML.split('<h6>My pages</h6>')[1].split('title="User:')[1].split('"')[0]; } if (document.getElementsByTagName('input')[0].value == user_name) {alert('Are you sure you want to block yourself?');} else if (document.getElementsByTagName('input')[0].value == user_name.replace(/ /g,'_')) {alert('Are you sure you want to block yourself?');} } // addOnloadHook(Dfn_js_con) function Dfn_js_con() { Mvaluejs_class = 'DMalak1'; Rvaluejs_class = 'ERollen2'; Uvaluejs_class = 'DRaven2'; } // //Interiot's javascript edit counter if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) { document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); } // //************ //Lupin's tools //************ //[[User:Lupin/popupsdev.js]] - please include this line document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popupsdev.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); popupShortcutKeys=true; // optional: enable keyboard shortcuts popupAdminLinks=true; // optional: enable admin links [[Category:VoA scripted admins]] popupSubpopups=true; popupOnEditSelection=true; popupStructure='menus'; popupDelay=0.0; popupHidDelay=0.0; //END //************ function XMLrequestprompt() { var parameters = ''; var type = 'GET'; var url = location.href; url = prompt('Enter a URL:'); parse_js_value_cache = 0; parse_js_value_cache = prompt('Parse the data?' + '\n' + '0 - false (default)' + '\n' + '1 - true (no script/SRCs/images)' + '\n' + '2 - true (no script/SRCs)' + '\n' + '3 - true (script/images allowed)'); if (parse_js_value_cache != 0 && parse_js_value_cache != 1 && parse_js_value_cache != 2 && parse_js_value_cache != 3){return;} if (!url || url == ''){return;} makeRequestXML(url, parameters,type); } function alertContents() { if (http_request.readyState != 4) return; body = document.getElementById('bodyContent'); if (body && parse_js_value_cache == 3) { document.getElementsByTagName('title')[0].innerHTML = "XML request:"; body.innerHTML = '<strong>XML source return:</strong><br>' + http_request.responseText; } else if (body && parse_js_value_cache == 2) { document.getElementsByTagName('title')[0].innerHTML = "XML request:"; var xml = http_request.responseText.replace(/<.script>/gi,'`</script>'); body.innerHTML = '<strong>XML source return:</strong><br>' + xml.replace(/<script [^`]+`<.script>/gi,'').replace(/(<\w* onload=["'][^<]+["']>)/gi,'').replace(/(\src=["'][^<]+["']>)/gi,' src="">'); } else if (body && parse_js_value_cache == 1) { document.getElementsByTagName('title')[0].innerHTML = "XML request:"; var xml = http_request.responseText.replace(/<.script>/gi,'`</script>'); body.innerHTML = '<strong>XML source return:</strong><br>' + xml.replace(/<script [^`]+`<.script>/gi,'').replace(/(<\w* onload=["'][^<]+["']>)/gi,'').replace(/(<img [^<]+>)/gi,'').replace(/(\src=["'][^<]+["']>)/gi,' src="">'); } else if (body && parse_js_value_cache == 0) { document.getElementsByTagName('title')[0].innerHTML = "XML request:"; var xml = http_request.responseText.replace(/<.script>/gi,'`</script>'); xml = xml.replace(/(<a href=["'][^<]+<.a>)/gi,'%parenST|span style="background-color: yellow"|%parenEN$1%parenST|/span|%parenEN').replace(/(<img [^<]+>)/gi,'%parenST|span style="background-color: lightgreen"|%parenEN$1%parenST|/span|%parenEN').replace(/(<iframe [^<]+<.iframe>)/gi,'%parenST|span style="background-color: lightgreen"|%parenEN$1%parenST|/span|%parenEN').replace(/(<script [^`]+)`<.script>/gi,'%parenST|span style="background-color: #FF9900"|%parenEN$1</script>%parenST|/span|%parenEN').replace(/(<\w* onload=["'][^<]+["']>)/gi,'%parenST|span style="background-color: #FF9900"|%parenEN$1%parenST|/span|%parenEN').replace(/\s(src=["'][^<]+["'])>/gi,'%parenST|span style="background-color: #FF3300"|%parenEN $1>%parenST|/span|%parenEN'); body.innerHTML = '<strong>XML source return:</strong><br>' + xml.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/%parenST\|/g,'<').replace(/\|%parenEN/g,'>'); } } //security override HTTP request //ALSO, reduce IE security settings //For FF/NS, go enable, see "http://esw.w3.org/topic/SparqlCalendarDemoUsage#FAQ" //Basically, enable "signed.applets.codebase_principal_support" in about:config function makeRequestXML(url, parameters,type,parse) { if(window.XMLHttpRequest) { try {netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } catch (e) {alert("Permission UniversalBrowserRead denied."); } http_request = false; http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) {http_request.overrideMimeType('text/xml'); } if (!http_request) {alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open(type, url + parameters, true); http_request.send(null); } else if (window.ActiveXObject) { try {http_request = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { try {http_request = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){} } if (!http_request) {showError(ERROR_XML);} http_request.onreadystatechange = alertContents; http_request.open(type, url + parameters, true); http_request.send(null); } } // // VIEW SOURCE addOnloadHook(function () { if (location.href.indexOf('viewsource=1') != -1) { sl = document.getElementById('wpSummaryLabel'); sl.parentNode.removeChild(sl); ed = document.getElementById('wpSummary').parentNode; ed.parentNode.removeChild(ed); return; } editbutton = document.getElementById('ca-edit'); if (editbutton && location.href.indexOf('action=edit')==-1) { editlink = editbutton.getElementsByTagName('a')[0].href + '&viewsource=1'; tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; na = document.createElement('a'); na.href = editlink; na.appendChild(document.createTextNode('view')); li = document.createElement('li'); li.id = 'ca-viewsource'; li.appendChild(na); tabs.insertBefore(li,editbutton); } }); // // Script from [[User:Lupin/recent2.js]] document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); //Interiot's javascript edit counter if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) { document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); } /* Syntax highlighter */ if(document.title.indexOf(".js") == -1) // Ignore pages that end in .js addOnloadHook(function () { /* CSS syntax highlighting */ multicommentRE = new RegExp('(/\\*[\\s\\S]*?\\*/)', 'g'); ruleRE = new RegExp('([^\\{]+)\\{([^\\}]+)\\}', 'g'); idselectorRE = new RegExp('(#[a-zA-Z0-9\-\_]+)\\b', 'g'); classselectorRE = new RegExp('(\\.[a-zA-Z0-9\-\_]+)\\b', 'g'); pairRE = new RegExp('([a-zA-Z-]+):([^;]+);', 'g'); css = document.getElementsByTagName('pre'); for (i = 0; i < css.length; i++) { c = css[i]; content = c.innerHTML; content=content.replace(multicommentRE, '<span class="comment">$1</span>'); content = content.replace(ruleRE, function(text, selector, body) { selector = selector.replace(idselectorRE, '<span class="idselector">$1</span>'); selector = selector.replace(classselectorRE, '<span class="classselector">$1</span>'); body = body.replace(pairRE, '<span class="property">$1</span>:<span class="value">$2</span>;'); return selector + '{' + body + '}'; }); c.innerHTML = content; } }); else { /* JS syntax highlighting */ // /** * Code Syntax Highlighter. * Version 1.3.0 * Copyright (C) 2004 Alex Gorbatchev. * http://www.dreamprojections.com/syntaxhighlighter/ * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ var dp={sh:{Brushes:{},Version:'1.3.0'}};dp.SyntaxHighlighter=dp.sh;dp.sh.Match=function(value,index,css){this.value=value;this.index=index,this.length=value.length,this.css=css};dp.sh.Highlighter=function(){this.addGutter=true,this.collapse=false,this.tabsToSpaces=true};dp.sh.Highlighter.SortCallback=function(m1,m2){if(m1.index<m2.index)return -1;else if(m1.index>m2.index)return 1;else{if(m1.length<m2.length)return -1;else if(m1.length>m2.length)return 1};return 0};dp.sh.Highlighter.prototype.GetMatches=function(regex,css){var index=0;var match=null;while((match=regex.exec(this.code))!=null){this.matches[this.matches.length]=new dp.sh.Match(match[0],match.index,css)}};dp.sh.Highlighter.prototype.AddBit= function(str,css){ var span=document.createElement('span'); str=str.replace(/&/g,'\&'); str=str.replace(/\&/g,'&'); str=str.replace(/\"/g,'"'); str=str.replace(/ |\t/g,' ').replace(/\n/gm,' <br />'); if(css!=null){var regex=new RegExp('<br />','gi');if(regex.test(str)){var lines=str.split(' <br />');str='';for(var i=0;i<lines.length;i++){span=document.createElement('SPAN');span.className=css;span.innerHTML=lines[i];this.div.appendChild(span);if(i+1<lines.length)this.div.appendChild(document.createElement('BR'))}}else{span.className=css,span.innerHTML=str;this.div.appendChild(span)}}else{span.innerHTML=str;this.div.appendChild(span)}};dp.sh.Highlighter.prototype.IsInside=function(match){if(match==null||match.length==0)return;for(var i=0;i<this.matches.length;i++){var c=this.matches[i];if(c==null)continue;if((match.index>c.index)&&(match.index<=c.index+c.length))return true}return false};dp.sh.Highlighter.prototype.ProcessRegexList=function(){for(var i=0;i<this.regexList.length;i++)this.GetMatches(this.regexList[i].regex,this.regexList[i].css)};dp.sh.Highlighter.prototype.ProcessSmartTabs=function(code){var lines=code.split('\n');var result='';var tabSize=4;var tab='\t';function InsertSpaces(line,pos,count){var left=line.substr(0,pos);var right=line.substr(pos+1,line.length);var spaces='';for(var i=0;i<count;i++)spaces+=' ';return left+spaces+right};function ProcessLine(line,tabSize){if(line.indexOf(tab)==-1)return line;var pos=0;while((pos=line.indexOf(tab))!=-1){var spaces=tabSize-pos % tabSize;line=InsertSpaces(line,pos,spaces)}return line};for(var i=0;i<lines.length;i++)result+=ProcessLine(lines[i],tabSize)+'\n';return result};dp.sh.Highlighter.prototype.SwitchToTable=function(){var html=this.div.innerHTML.replace(/<(br)\/?>/gi,'\n');var lines=html.split('\n');var row=null;var cell=null;var tBody=null;var html='';var pipe=' | ';tBody=document.createElement('TBODY');this.table.appendChild(tBody);if(this.addGutter==true){row=tBody.insertRow(-1);cell=row.insertCell(-1)}for(var i=0,lineIndex=this.firstLine;i<lines.length-1;i++,lineIndex++){row=tBody.insertRow(-1);if(this.addGutter==true){cell=row.insertCell(-1);cell.className='gutter';cell.innerHTML=lineIndex};cell=row.insertCell(-1);cell.className='line'+(i % 2+1);cell.innerHTML=lines[i]};this.div.innerHTML=''};dp.sh.Highlighter.prototype.Highlight=function(code){function Trim(str){return str.replace(/^\s*(.*?)[\s\n]*$/g,'$1')};function Chop(str){return str.replace(/\n*$/,'').replace(/^\n*/,'')};function Unindent(str){var lines=str.split('\n');var indents=new Array();var regex=new RegExp('^\\s*','g');var min=1000;for(var i=0;i<lines.length&&min>0;i++){if(Trim(lines[i]).length==0)continue;var matches=regex.exec(lines[i]);if(matches!=null&&matches.length>0)min=Math.min(matches[0].length,min)};if(min>0)for(var i=0;i<lines.length;i++)lines[i]=lines[i].substr(min);return lines.join('\n')};function Copy(string,pos1,pos2){return string.substr(pos1,pos2-pos1)};var pos=0;this.originalCode=code;this.code=Chop(Unindent(code));this.div=document.createElement('DIV');this.table=document.createElement('TABLE');this.matches=new Array();if(this.CssClass!=null)this.table.className=this.CssClass;if(this.tabsToSpaces==true)this.code=this.ProcessSmartTabs(this.code);this.table.border=0;this.table.cellSpacing=0;this.table.cellPadding=0;this.ProcessRegexList();if(this.matches.length==0){this.AddBit(this.code,null);this.SwitchToTable();return};this.matches=this.matches.sort(dp.sh.Highlighter.SortCallback);for(var i=0;i<this.matches.length;i++)if(this.IsInside(this.matches[i]))this.matches[i]=null;for(var i=0;i<this.matches.length;i++){var match=this.matches[i];if(match==null||match.length==0)continue;this.AddBit(Copy(this.code,pos,match.index),null);this.AddBit(match.value,match.css);pos=match.index+match.length};this.AddBit(this.code.substr(pos),null);this.SwitchToTable()};dp.sh.Highlighter.prototype.GetKeyw=function(str){return '\\b'+str.replace(/ /g,'\\b|\\b')+'\\b'};dp.sh.HighlightAll=function(event,showGutter,firstLine){var elements=document.getElementsByTagName('PRE');var highlighter=null;var registered=new Object();if(elements==null)return;for(var i=0;i<elements.length;i++){var element=elements[i];highlighter=new dp.sh.Brushes['JScript']();highlighter.addGutter=(showGutter==null)?true:showGutter;highlighter.firstLine=(firstLine==null)?0:firstLine;highlighter.Highlight(element['innerHTML']);element.innerHTML="";element.className='dp-highlighter';element.appendChild(highlighter.table)}}; dp.sh.Brushes.JScript = function(){ var keywords = 'abstract boolean break byte case catch char class const continue debugger ' + 'default delete do double else enum export extends false final finally float ' + 'for function goto if implements import in instanceof int interface long native ' + 'new null package private protected public return short static super switch ' + 'synchronized this throw throws transient true try typeof var void volatile while with'; this.regexList = [ {regex: new RegExp('//.*$', 'gm'), css: 'comment' }, // one line comments {regex: new RegExp('/\\*[\\s\\S]*?\\*/', 'g'),css: 'comment' }, // multiline comments {regex: new RegExp('"(?:[^"\n]|[\"])*?".*?','g'),css: 'string' }, // double quoted strings {regex: new RegExp("'(?:[^'\n]|[\'])*?'.*?",'g'),css: 'string' }, // single quoted strings {regex: new RegExp('^\\s*#.*', 'gm'), css: 'preprocessor'},// preprocessor tags like #region and #endregion {regex: new RegExp(this.GetKeyw(keywords),'gm'),css: 'keyword'} // keywords ]; this.CssClass = 'dp-c'; } dp.sh.Brushes.JScript.prototype = new dp.sh.Highlighter(); addOnloadHook(dp.SyntaxHighlighter.HighlightAll); // } /* Add history link to the "You have new messages" box */ function newmessagehistory() { var divs = document.getElementsByTagName('div'); var talkmessagebox; for(var x = 0; x < divs.length; ++x) { if(divs[x].className.indexOf('usermessage') != -1) { talkmessagebox = divs[x]; x = divs.length; // force break } } divs = ''; // release divs? if(!talkmessagebox) return false; var newmessagelink = talkmessagebox.getElementsByTagName('a')[0]; var historylink = document.createElement('a'); historylink.href = newmessagelink.href.replace(/\/wiki\//, '/w/index.php?title=') + '&action=history'; historylink.className = 'extiw'; historylink.appendChild(document.createTextNode('changes')); // var talkmessagetext = 'You have '; // talkmessagebox.innerHTML = talkmessagetext; // talkmessagebox.appendChild(newmessagelink); talkmessagebox.appendChild(document.createTextNode(' (')); talkmessagebox.appendChild(historylink); talkmessagebox.appendChild(document.createTextNode(')')); } //</nowiki></pre>[[Category:VoA scripted admins]]