User:DakotaKahn/monobook.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
addOnloadHook(function (){ if(queryString("submitdelete")=="true") document.forms[0].wpConfirmB.click(); }); function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } } return null; }; //<pre><nowiki> // [[User:Lupin/popups.js]] //<nowiki> Helper tools document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Addtabs/monobook.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); //</nowiki> //popups! document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); popupAdminLinks=true; // //<nowiki> UTC clock document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/UTCclock.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); //</nowiki>[[Category:VoA scripted users|{{PAGENAME}}]] // Filter changes live // [[User:Lupin/recent2.js]] - please include this line 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>'); // Useful stuff from [[Wikipedia:WikiProject_User_scripts]] function addToolboxLink(url, name, id){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, url, name, id); } function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) { if(key && title) ta[id] = [key, title]; else if(key) ta[id] = [key, '']; else if(title) ta[id] = ['', title]; } // re-render the title and accesskeys from existing code in wikibits.js akeytt(); return li; } function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlilink(tabs, url, name, id, title, key); } // culled from [[User:Lupin/popups.js]] function nichalp_articleFromURL(h) { if (typeof h != 'String') h=String(h); h=decodeURI(h); var m=RegExp('[^:]*://en\\.wikipedia\\.org/(wiki/|w/index\\.php\\?title=)([^&?]*)').exec(h); if(m===null) return null; return m[2]; } function nichalp_isIpUser(user) { return RegExp('(User:)?' + '((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}' + '(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])') .test(user); } function nichalp_removeAnchor(article) { // is there a #? if not, we're done var i=article.indexOf('#'); if (i == -1) return article; return article.substring(0,i); } function nichalp_userName(article) { var i=article.indexOf('User'); var j=article.indexOf(':'); if (i != 0 || j == -1) return null; var k=article.indexOf('/'); if (k==-1) return article.substring(j+1); else return article.substring(j+1,k); } // do it function nichalp_customLinks() { var article=nichalp_articleFromURL(document.location.href); if (!article) return; var user=nichalp_userName(article); if(!user) return; user=nichalp_removeAnchor(user); if (!nichalp_isIpUser(user)) { addToolboxLink('http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=enwiki&user='+user, user+"'s edit count", 'toolbox_katestool'); } var special='http://en.wikipedia.org/w/index.php?title=Special:'; addToolboxLink(special + 'Log&user='+user, user+"'s log", 'toolbox_userlog'); addToolboxLink(special + 'Blockip&ip='+user, 'Block '+user, 'toolbox_blockuser'); addToolboxLink(special + 'Ipblocklist&action=unblock&ip='+user, 'Unblock '+user, 'toolbox_unblockuser'); } // make it all happen on page load if (window.addEventListener) window.addEventListener("load",nichalp_customLinks,false); else if (window.attachEvent) window.attachEvent("onload",nichalp_customLinks); else { window._old_nichalp_onload = window.onload; window.onload = function() { window._old_nichalp_onload(); nichalp_customLinks(); } } //this helps automate AfD closing by adding a 'close' tab to AfD debates //written by [[User:Johnleemk]] based on [[Wikipedia:WikiProject User scripts/Scripts/test-n.js]] by [[User:Celestianpower]] function afdaddlilink(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); var txt = document.createTextNode(name); na.appendChild(txt); var li = document.createElement('li'); li.appendChild(na); return li; } function result() { var close = prompt("Result of debate?") var f = document.editform, t = f.wpTextbox1; t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value; if (t.value.length > 0) t.value += '\n'; t.value += "{{subst:" + "ab" + "}}"; f.wpSummary.value = "Close as " + close; } function relist() { var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += "{{subst:" + "relist" + "|~" + "~" + "~" + "~}}"; f.wpSummary.value = "Relisting debate"; } function keep() { var date = prompt("Nomination was made when?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article survived AfD"; } function no_consensus() { var date = prompt("Nomination was made when?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article survived AfD with no consensus"; } function redirect() { var date = prompt("Nomination was made when?") var redirect = prompt("Redirect to?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD"; } function merge() { var date = prompt("Nomination was made when?") var redirect = prompt("Merge and redirect to?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD"; } function other() { var date = prompt("Nomination was made when?") var result = prompt("Result was?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "AfDed; result was " + result; } function add_afd_tabs() { var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; // Only add for pages with the right string somewhere in the title if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1) { tabs.appendChild(afdaddlilink('javascript:result()',"close")); tabs.appendChild(afdaddlilink('javascript:relist()',"relist")); } if (document.title.indexOf("Editing Talk:") != -1) { tabs.appendChild(afdaddlilink('javascript:keep()',"keep")); tabs.appendChild(afdaddlilink('javascript:no_consensus()',"no consensus")); tabs.appendChild(afdaddlilink('javascript:redirect()',"redirect")); tabs.appendChild(afdaddlilink('javascript:merge()',"merge")); tabs.appendChild(afdaddlilink('javascript:other()',"other")); } } addOnloadHook(add_afd_tabs); //end AfD closing script //from Func, hacked into warn tabs only //*********************** // // Released into the public domain, btw. // Func's monobook.js, now with ADMIN powers.... :) // if ( window.addEventListener ) // modern browsers, screw IE :) { function WikiInit() { Wiki = {}; // global Wiki.href = window.location.href; Wiki.path = window.location.pathname; Wiki.quer = window.location.search; if ( Wiki.quer.length < 2 ) Wiki.quer = ''; Wiki.wiki = ! Wiki.path.indexOf( '/wiki/' ); Wiki.diff = Wiki.quer.indexOf( 'diff=' ) != -1; Wiki.edit = ( Wiki.quer.indexOf( 'action=edit' ) != -1 ) || ( Wiki.quer.indexOf( 'action=submit' ) != -1 ); Wiki.user = Wiki.href.indexOf( 'User:' ) != -1; // make more robust Wiki.talk = Wiki.href.indexOf( 'User_talk:' ) != -1; // make more robust Wiki.spec = Wiki.href.indexOf( 'Special:' ) != -1; Wiki.recentchanges = Wiki.href.indexOf( 'Special:Recentchanges' ) != -1 || Wiki.href.indexOf( 'Special%3ARecentchanges' ) != -1 ; } // Pass actions from one page to the next via // window.name; which is faster and easier than // using a cookie. // function PassItOn( _action_ ) { if ( _action_ ) window.name = 'wpFuncAction=' + _action_; else { var hack = window.name; window.name = ''; if ( ! hack.indexOf( 'wpFuncAction=' ) ) { hack = hack.substr( 13 ); if ( hack == 'lastdiff' ) { if ( Wiki.quer ) window.location.href += '&diff=0'; else window.location.href += '?diff=0'; } // more to come.... } } } function wpFuncPreLoad() { WikiInit(); // Global Wiki object. PassItOn(); // Do we need to be somewhere else? } wpFuncPreLoad(); // Remind me to ask the developers to throw // unique IDs onto important elements!!! // function GetByClass( className, tagName, elemObj ) { var i, filter, found = []; elemObj = elemObj || document; if ( tagName ) { filter = elemObj.getElementsByTagName( tagName ); for ( i = 0; i < filter.length; i++ ) if ( filter[ i ].className == className ) found.push( filter[ i ] ); } else // blah, do it when I need it { } return found; } function SP(x) { var i, s = ''; x = x || 1; while ( x-- ) s += ' '; return document.createTextNode( s ); } function NB(x) { var i, s = ''; x = x || 1; while ( x-- ) s += '\xA0'; return document.createTextNode( s ); } function BR(){ return document.createElement( 'br' ) } function NewLink( txt, url, plainlinks, linkColor ) { var a = document.createElement( 'a' ); a.appendChild( document.createTextNode( txt ) ); a.href = url; if ( plainlinks ) a.className = 'plainlinks'; if ( linkColor ) { if ( typeof linkColor == "string" ) a.style.color = linkColor; else a.style.color = '#FF0000'; // old default behavior } return a; } function RCPatrol() // for admins { var table, TDs, otitle, ntitle, prevLink, currLink, link, rollback, contribs, block; var tr, td; if ( Wiki.edit ) { gEditForm = document.getElementById( 'editform' ); gTextBox = gEditForm[ 'wpTextbox1' ]; gSummary = gEditForm[ 'wpSummary' ]; gMinorBox = gEditForm[ 'wpMinoredit' ]; gWatchBox = gEditForm[ 'wpWatchthis' ]; var addtexts = document.createElement( 'div' ); function Inserter( seeText, addText, editSum, addLoc, color, submit ) // local function { var a = NewLink( seeText, '', true, color ); a.addText = addText; a.addLoc = addLoc || 8; // 2 == top; 5 == insertion-loc; 8 == bottom a.editSum = editSum || ''; a.submit = submit || false; a.onclick = function() { if ( this.addLoc == 8 ) gTextBox.value += this.addText; else if ( this.addLoc == 2 ) gTextBox.value = this.addText + gTextBox.value; else /* this.addLoc == 5; Safari problems */ ; gMinorBox.checked = true; // gWatchBox.checked = false; if ( this.editSum ) gSummary.value += this.editSum; if ( this.submit ) gEditForm.submit(); return false; } return a; } if ( Wiki.talk ) // here is where we tell the vandals to bugger off { var kTest = '#0000AA', // blue kWarn = '#00AA00', // green kFinal = '#AAAA00', // yellow kBlock = '#AA0000'; // red var tableTags = [ [ [ 'test', 'test' ], [ 'test2', 'test 2', 'test2a', 'test 2a' ], // special case [ 'test3', 'test 3' ], [ 'test4', 'final warning' ], [ 'test5', 'blocked' ] ], [ null, [ 'blanking', 'blanking' ], [ 'blanking2', 'blanking 2' ], [ 'blanking3', 'final warning' ], [ 'blanking4', 'blocked' ] ], [ [ 'drmafd', 'removing AFDs' ], [ 'drmafd2', 'removing AFDs, 2nd' ], [ 'drmafd3', 'removing AFDs, 3rd' ], [ 'drmafd4', 'final warning' ], [ 'drmafd5', 'blocked' ] ], [ [ 'spam', 'spam' ], [ 'spam2', 'spammer' ], [ 'spam2a', 'repeated spamming' ], [ 'spam3', 'final warning' ], [ 'spam4', 'blocked' ] ], [ [ 'verror', 'test' ], [ 'verror2', 'test 2' ], [ 'verror3', 'test 3' ], [ 'verror4', 'final warning' ], [ 'verror5', 'blocked' ] ], [ null, null, [ '3RR', '3RR warning' ], [ '3RR2', 'final 3RR warning' ], [ '3RR3', 'blocked for 3RR' ] ], [ null, null, [ 'attack', 'personal attacks' ], null, null ] ]; table = document.createElement( 'table' ); // Formatting // table.style.fontSize = 'x-small'; var i, j, a, color; for ( i = 0; i < tableTags.length; i++ ) { tr = document.createElement( 'tr' ); a = tableTags[ i ]; for ( j = 0; j < 5; j++ ) { td = document.createElement( 'td' ); color = ( j == 0 ) ? kTest : ( j < 3 ) ? kWarn : ( j == 3 ) ? kFinal : kBlock ; if ( a[ j ] ) { td.appendChild( Inserter( a[ j ][ 0 ], // click on text '{{subst:' + a[ j ][ 0 ] + '}} ~~~~\n\n', // insert this text a[ j ][ 1 ], // edit summary text 8, // insert at end color ) ); td.appendChild( NB() ); td.appendChild( Inserter( '!', // click on text '{{subst:' + a[ j ][ 0 ] + '}} ~~~~\n\n', // insert this text a[ j ][ 1 ], // edit summary text 8, // insert at end color, true // auto-sumbit ) ); if ( a[ j ][ 2 ] ) // 2 links in one cell, ie: test2a { td.appendChild( BR() ); td.appendChild(Inserter(a[j][2],'{{subst:'+a[j][2]+'}} ~~~~\n\n',a[j][3],8,color)); td.appendChild( NB() ); td.appendChild(Inserter('!','{{subst:'+a[j][2]+'}} ~~~~\n\n',a[j][3],8,color,true)); } } else td.appendChild( NB() ); tr.appendChild( td ); } table.appendChild( tr ); } addtexts.appendChild( table ); var span = document.createElement( 'span' ); span.style.fontSize = 'x-small'; span.appendChild(Inserter('Welcomenpov','{{subst:Welcomenpov}} ~~~~\n\n','pov',8,'#0000AA')); span.appendChild(NB()); span.appendChild(Inserter('!','{{subst:Welcomenpov}} ~~~~\n\n','pov',8,'#0000AA',true)); span.appendChild( NB(4) ); span.appendChild(Inserter('nothanks|PAGE','{{subst:nothanks|PAGE}} ~~~~\n\n','copyvio',8,'#0000AA')); span.appendChild( NB(4) ); span.appendChild(Inserter('vanity|PAGE','{{subst:vanity|PAGE}} ~~~~\n\n','[[WP:NOT]]',8,'#0000AA')); span.appendChild( NB(4) ); addtexts.appendChild( span ); } gEditForm.parentNode.insertBefore( addtexts, gEditForm ); } } // Due to problems with Safari, this CURRENTLY will only insert at the END for now. // function FieldInsert( field, text, _where_ ) { field.value += text; } function PortletMenu( id ) // constructor { this.port = document.getElementById( id ); this.menu = this.port.getElementsByTagName( 'ul' )[ 0 ]; this.menu.style.textTransform = 'none'; // override the CSS this.items = {}; this.links = {}; var i, o, items = this.menu.getElementsByTagName( 'li' ); for ( i = 0; i < items.length; i++ ) { // now with sanity checks // if ( ( o = items[ i ] ) ) { this.items[ o.id ] = o; if ( o.firstChild && o.firstChild.href ) { this.links[ o.id ] = o.firstChild; this.links[ o.id ].style.textTransform = 'none'; // I could do this in the .css... } } } this.register = function( id, txt, url ) // internal, basically { var li = document.createElement( 'li' ); li.id = id; var a = NewLink( txt, url ); li.appendChild( a ); this.items[ id ] = li; this.links[ id ] = a; a.style.textTransform = 'none'; // I hate css so much.... return li; } this.append = function( id, txt, url ) { this.menu.appendChild( this.register( id, txt, url ) ); }; this.insert = function( before, id, txt, url ) { this.menu.insertBefore( this.register( id, txt, url ), this.items[ before ] ); }; this.follow = function( after, id, txt, url ) { this.menu.insertBefore( this.register( id, txt, url ), this.items[ after ].nextSibling ); } this.getText = function( id ){ return this.links[ id ].firstChild.nodeValue }; this.setText = function( id, txt ){ this.links[ id ].firstChild.nodeValue = txt }; this.getHref = function( id ){ return this.links[ id ].href }; this.setHref = function( id, url ){ this.links[ id ].href = url }; } function PageActions() { // ca-nstab-main Article /wiki/PAGE | /w/...action=edit // ca-nstab-user User page /wiki/User:USER | /w/...action=edit // ca-article Special Page (I find 'ca-article' slightly ironic, since it isn't.) // // ca-talk Discussion /wiki/Talk:... User_talk... /w/...action=edit // // ca-edit Edit this page /w/...action=edit // ca-addsection + /w/...action=edit§ion=new // ca-viewsource View source /w/...action=edit // // ca-history History /w/...action=history // // ca-protect Protect /w/...action=protect // ca-delete Delete /w/...action=delete // // ca-move Move Special:Movepage/PAGE // // ca-watch Watch /w/...action=watch // ca-unwatch Unwatch /w/...action=unwatch // // User Talk Edits Logs Edit 0 + History Diff Protect Delete Move Watch Logs Purge // Page Talk Edit 0 History Diff Protect Delete Move Watch Logs Purge // As an admin, I'm not sure when this would be nessesary.... // var edit = PageMenu.items[ 'ca-viewsource' ] ? 'ca-viewsource' : 'ca-edit'; // I need the space. // if ( PageMenu.items[ 'ca-talk' ] ) PageMenu.setText( 'ca-talk', 'Talk' ); if ( PageMenu.items[ 'ca-edit' ] ) PageMenu.setText( 'ca-edit', 'Edit' ); if ( PageMenu.items[ 'ca-viewsource' ] ) PageMenu.setText( 'ca-viewsource', 'View' ); // Move the offset from off of the right of ca-talk to the left of ca-edit // // from /skins-1.5/monobook/main.css : // // /* offsets to distinguish the tab groups */ // li#ca-talk { margin-right: 1.6em; } // li#ca-watch, li#ca-unwatch, li#ca-varlang-0, li#ca-print { margin-left: 1.6em; } // if ( PageMenu.items[ 'ca-talk' ] ) { PageMenu.items[ 'ca-talk' ].style.marginRight = '0.3em'; // ??? how to just go back to the browser's default ??? PageMenu.items[ edit ].style.marginLeft = '1.6em'; } if ( PageMenu.items[ 'ca-nstab-user' ] ) { PageMenu.setText( 'ca-nstab-user', 'User' ); // User: or User talk: // var user = document.getElementsByTagName( 'h1' )[ 0 ].firstChild.nodeValue; user = user.substr( user.indexOf( ':' ) + 1 ); if ( user.indexOf( '/' ) != -1 ) // subpage user = user.split( '/' )[ 0 ]; PageMenu.insert( edit, 'ca-edits', 'Edits', '/wiki/Special:Contributions/' + user ); PageMenu.insert( edit, 'ca-logs', 'Logs', '/w/index.php?title=Special%3ALog&user=' + user ); } } function wpFuncOnLoad() { PageMenu = new PortletMenu( 'p-cactions' ); UserMenu = new PortletMenu( 'p-personal' ); NavMenu = new PortletMenu( 'p-navigation' ); ToolMenu = new PortletMenu( 'p-tb' ); RCPatrol(); PageActions(); UserActions(); } window.addEventListener( 'load', wpFuncOnLoad, false ); } // //END //***************************** function hidevfd(){ var divs = document.getElementsByTagName("div"); for(var x = 0; x < divs.length; ++x) if(divs[x].className.indexOf("vfd") != -1) divs[x].style.display = "none"; document.getElementById('footer').style.display = 'none'; } function showvfd(){ var divs = document.getElementsByTagName("div"); for(var x = 0; x < divs.length; ++x) if(divs[x].className.indexOf("vfd") != -1) divs[x].style.display = ""; document.getElementById('footer').style.display = ''; } function addlilink(tabs, url, name){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); tabs.appendChild(li); return li; } function vfdlinks(){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(document.title.indexOf("Wikipedia:Articles for deletion") == 0){ addlilink(tabs, 'javascript:hidevfd()', 'Hide'); addlilink(tabs, 'javascript:showvfd()', 'Show'); } } if (window.addEventListener) window.addEventListener("load",vfdlinks,false); else if (window.attachEvent) window.attachEvent("onload",vfdlinks); // </nowiki></pre>[[Category:Wikipedia administrators who use VoA script|{{PAGENAME}}]]