User:Sirex98/monobook.js

// // Edit tools for the vandal whack-a-mole game // User:Kbh3rd/whackamole.js - please include this line // importScript('User:Kbh3rd/whackamole.js');

/**** welcome new user ****/ document.write(' ');

importScript('User:AzaToth/morebits.js'); importScript('User:Ioeth/friendlytag.js');

// Please leave the following line // user:Where/usertabs $(function { if (mw.config.get('wgTitle').indexOf("/") != -1 || document.title.indexOf("- History -") != -1)  //no subpages or history     return;  if (mw.config.get('wgCanonicalNamespace') == "User" || mw.config.get('wgCanonicalNamespace') == "User_talk") {     var username = encodeURIComponent( mw.config.get('wgTitle') );     mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/wiki/Special:Contributions/" + username, "Contribs", "ca-contrib", "User contributions");     mw.util.addPortletLink("p-cactions", "http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "Ed count", "ca-editcount", "Edit count from Interiot's Tool1");     mw.util.addPortletLink("p-cactions", "http://www.math.ucla.edu/~aoleg/wp/rfa/edit_summary.cgi?user=" + username + "&site=en.wikipedia.org", "Sum", "ca-summary", "Edit Summary");     mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/w/index.php?title=Special:Prefixindex&from=" + username + "&namespace=2", "Userspc", "", "List of pages in this user's userspace"); mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/w/index.php?title=Special:Log&type=block&page=User:" + username, "Blocks rec", "ca-blog", "Blocks received by this user"); mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/w/index.php?title=Special:Listusers&username=" + username + "&group=&limit=50", "Userlist", "ca-username", "A list of all registered users"); Special:Listusers } });

//

// This will add an [edit] link at the top of all pages except preview pages and the main page // Originally by User:Pile0nades, modified by User:Gerbrant. // Add an [edit] link to pages hookEvent("load", function {	if(window.location.href.indexOf("/wiki/Special:") != -1) return;	if(document.getElementById("wikiPreview")) return;	if(document.getElementById("histlegend‎")) return;	if(document.getElementById("difference‎")) return;	if(document.getElementById("watchdetails")) return;	if(document.getElementById("mainpage")) return;	if(window.location.href.indexOf("&action=edit") == -1)	{		var pageTitle = document.title.split(" - ")[0].replace(" ", "_");		var divContainer = document.createElement("div");		divContainer.innerHTML = ' \ [edit] ';		var coos = document.getElementById("coordinates");		if(coos) coos.style.right = "4.5em";		document.getElementById("content").insertBefore( divContainer, document.getElementsByTagName("h1")[0]);	}	else if(window.location.href.indexOf("&action=edit&section=0") != -1)	{		e = document.getElementById("wpSummary");		if(e) e.value = "/* Intro */ ";	} });

/* User:DStoykov/defaultsort.js */ function defaultsort { //var apiurl = mw.config.get('wgServer')+mw.config.get('wgScriptPath')+'/api.php?action=query&meta=siteinfo&siprop=namespaces&format=xml'; //var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : null; //xmlhttp.open('GET',apiurl, false); //xmlhttp.send(null); //alert(xmlhttp.responseXML.getElementById('14')); var txt = document.editform.wpTextbox1.value; var sortkey = ''; // Create an array of all category links if (txt.match(/\{\{\s*defaultsort/i)) { alert('There\'s already a defaultsort statement!'); return; }    var catlinks = txt.match(/\[\[\s*((C|K)at(e|e)gor(y|i|ie|ia|ia|ija|io)|Кат(е|э)гор(ия|ија|ія|ыя)|Luokka|Flokkur)\s*:.*\]\]/ig); if (!catlinks) { alert('There are no category links!'); return; }    for (i=0; i< catlinks.length; i++) { // Extract the name of the category var catname = catlinks[i].replace(/.+\s*:\s*([^|]*[^|\s])\s*(\|.*)?\]\]/,"$1"); // Extract the sort key var match = /\|[^\]]+/.exec(catlinks[i]); if (match == null) { alert('Category '+catname+' doesn\'t include a sort key!'); return; }       // Strip the '|' and any trailing spaces var sk = match[0].replace(/\|(.+)/, "$1").replace(/(\S) +$/,"$1"); if (i == 0) { sortkey = sk; } else { if (sortkey != sk) { alert('Not all sort keys are identical!\nThe sort key for category '+catname+' is different.'); return; }       }    }    // Now that we know that everything is OK, we can proceed with modifying the content of the editbox txt = txt.replace(catlinks[0], "\n"+catlinks[0]); for (i=0; i< catlinks.length; i++) { subst = catlinks[i].replace(/\|[^\]]+/,""); txt = txt.replace(catlinks[i], subst); }   document.editform.wpTextbox1.value=txt; } $(function {  if(document.forms.editform) {    mw.util.addPortletLink('p-cactions', 'javascript:defaultsort', 'defaultsort', 'ca-defaultsort', , , document.getElementById('ca-purge'));  } }); /* */ // // Edit tools for the vandal whack-a-mole game // User:Kbh3rd/whackamole.js - please include this line // document.write(' ');

/* */ //On diff pages this script replaces (Difference between revisions)with //different tools for reverting the edit and warning the user that made the edit. //For instructions see talk page. // Revert tools by Lorian function getElementsByClass(searchClass,node,tag) { // Function from http://www.dustindiaz.com/getelementsbyclass/ var classElements = new Array; if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } }  return classElements; }

// _GET code from NoGray JS Library http://www.nogray.com/new_site/ var _GET = new Array; var _uri = location.href;

var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");

var _temp_get_arr_1 = new Array;

for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){ _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("="); _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]); }

delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;

function getMessage (where, user1, user2) { var message = prompt ('What message would you like to leave?', ''); window.location = 'http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message; }

$(function { if (location.href.match(/diff=/)) {    // Get username of submitter    var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;    var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;    document.getElementById('contentSub').innerHTML = '(Revert / Message) (Vandalism / Message) (Warn: Test / Blatant / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3">Nonsense</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=4">Blanking</a>)'; } else if (location.href.match(/revert=1/)) { document.getElementById('wpSummary').value = 'Reverted edits by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+''; document.getElementById('editform').submit; } else if (location.href.match(/revert=2/)) { document.getElementById('wpSummary').value = 'Reverted edits by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+' ('+_GET['message']+')'; document.getElementById('editform').submit; } else if (location.href.match(/vandalism=1/)) { document.getElementById('wpSummary').value = 'Reverted vandalism by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+''; document.getElementById('editform').submit; } else if (location.href.match(/vandalism=2/)) { document.getElementById('wpSummary').value = 'Reverted vandalism by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+' ('+_GET['message']+')'; document.getElementById('editform').submit; } else if (location.href.match(/warn=1/)) { document.getElementById('wpSummary').value = 'Vandalism warning'; document.getElementById('wpTextbox1').value = ' '+''; document.getElementById('editform').submit; } else if (location.href.match(/warn=2/)) { document.getElementById('wpSummary').value = 'Vandalism warning'; document.getElementById('wpTextbox1').value = ' '+''; document.getElementById('editform').submit; } else if (location.href.match(/warn=3/)) { document.getElementById('wpSummary').value = 'Vandalism warning'; document.getElementById('wpTextbox1').value = ' '+''; document.getElementById('editform').submit; } else if (location.href.match(/warn=4/)) { document.getElementById('wpSummary').value = 'Vandalism warning'; document.getElementById('wpTextbox1').value = ' '+''; document.getElementById('editform').submit; } }); /* */

// User:Ais523/topcontrib.js // This script color-codes lines according to who has the top contribution for a page. // $(function  {  if((location.href.indexOf("Special:Contributions")!=-1||      location.href.indexOf("Special%3AContributions")!=-1) &&location.href.indexOf("&ais523")==-1&&location.href.indexOf("?ais523")==-1)    // the ais523 in the line above is meant to be ais523, not your username; it's     // to avoid a clash with a couple of other scripts I've written. Feel free to     // expand it to avoid clashes with other contribs-manipulating scripts, though.  {    var i,li,a;    li=document.getElementById("bodyContent");    li=li.getElementsByTagName("li");    i=-1;    a=new Array;    while(++i<li.length)    {      var s,t;      var html = li[i].innerHTML;      var match = html.match(/"\/wiki\/([^"]*)"/);      if (!match)        match = html.match(/"\/w\/index.php\?title=([^"]*)&amp;redirect=no"/);      t = match[1];      var spans = li[i].getElementsByTagName("span");      var topspanfound = false;      for (var j = 0; j < spans.length; j++)      {        if (spans[j].className == "mw-uctop")        {           topspanfound = true; break; }     }      s = topspanfound ? "#CCCCFF" : "#FFCCCC"; if(a[t]!=undefined) s=(a[t]=="#CCCCFF"?"#CCFFFF":"#FFFFCC"); else a[t]=s; li[i].innerHTML="<SPAN STYLE='background-color:"+s+"'>"+li[i].innerHTML+"</SPAN>"; } } }); //  //

// Adds a drop-down menu to the search box to choose the namespace to search in.

$(function {    var searchGoButton = document.getElementById('searchGoButton');    if (!searchGoButton) return;

var searchNsHidden = document.createElement('input'); searchNsHidden.id = 'searchNsHidden'; searchNsHidden.type = 'hidden'; searchNsHidden.name = 'ns0'; searchNsHidden.value = '1';

var searchNsMenu = document.createElement('select'); searchNsMenu.id = 'searchNsMenu'; searchNsMenu.name = 'ns'; searchNsMenu.options[searchNsMenu.options.length] = new Option('(Main)', 0); searchNsMenu.options[searchNsMenu.options.length] = new Option('Talk', 1); searchNsMenu.options[searchNsMenu.options.length] = new Option('User', 2); searchNsMenu.options[searchNsMenu.options.length] = new Option('User talk', 3); searchNsMenu.options[searchNsMenu.options.length] = new Option('Wikipedia', 4); searchNsMenu.options[searchNsMenu.options.length] = new Option('Wikipedia talk', 5); searchNsMenu.options[searchNsMenu.options.length] = new Option('Image', 6); searchNsMenu.options[searchNsMenu.options.length] = new Option('Image talk', 7); searchNsMenu.options[searchNsMenu.options.length] = new Option('MediaWiki', 8); searchNsMenu.options[searchNsMenu.options.length] = new Option('MediaWiki talk', 9); searchNsMenu.options[searchNsMenu.options.length] = new Option('Template', 10); searchNsMenu.options[searchNsMenu.options.length] = new Option('Template talk', 11); searchNsMenu.options[searchNsMenu.options.length] = new Option('Help', 12); searchNsMenu.options[searchNsMenu.options.length] = new Option('Help talk', 13); searchNsMenu.options[searchNsMenu.options.length] = new Option('Category', 14); searchNsMenu.options[searchNsMenu.options.length] = new Option('Category talk', 15); searchNsMenu.options[searchNsMenu.options.length] = new Option('Portal', 100); searchNsMenu.options[searchNsMenu.options.length] = new Option('Portal talk', 101); searchNsMenu.onchange = function { searchNsHidden.name = 'ns' + (this.selectedIndex < 0 ? '0' : this.options[this.selectedIndex].value); };

// From /skins-1.5/monobook/main.css?5: searchNsMenu.style.width = '10.9em'; searchNsMenu.style.margin = '0'; searchNsMenu.style.fontSize = '95%';

searchGoButton.parentNode.insertBefore(searchNsHidden, searchGoButton); searchGoButton.parentNode.insertBefore(searchNsMenu, searchGoButton); });

//

$(function {    var query_prefix = "title=Special:Watchlist&action=submit&remove=1&id[]=";    //var query_prefix = "action=unwatch&title=";

if (window.location.href.indexOf("Special:Watchlist") < 0) return; if (window.location.href.indexOf("Special:Watchlist/edit") >= 0) return;

var links = document.getElementById('content').getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { if (links[i].href.substring(links[i].href.length-15) != '&action=history') continue; var unwatch = document.createElement('a'); unwatch.href = "/w/index.php?" + query_prefix + encodeURIComponent(links[i].title); unwatch.title = "Unwatch "+links[i].title; unwatch.appendChild(document.createTextNode("unwatch")); links[i].parentNode.insertBefore(unwatch, links[i].nextSibling); // kluge to handle case where "diff" is unlinked: var delim = links[i].previousSibling; delim = (delim.nodeType == 3 ? delim.nodeValue : ""); links[i].parentNode.insertBefore(document.createTextNode(delim.replace(/^.*diff/, "")), unwatch); } });

//

// Script from User:Lupin/recent2.js mw.loader.load(            'https://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js'             + '&action=raw&ctype=text/javascript&dontcountme=s');

// This is based on the original code on Wikipedia:Tools/Editing tools // // The original code was on the project page and needed to be cut and paste to the user's // monobook.js page. However, this caused problems with the quote marks. So I have moved // it to its own page. // // I do not know a lot about Javascript so please do not ask for a complicated change // // See the User:MarkS/Extra edit buttons for changes log

function InsertButtonsToToolBar { //Strike-Out Button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png", "speedTip": "Strike", "tagOpen": " ", "tagClose": " ", "sampleText": "Strike-through text"} //Left-Text Button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/e/ea/Button_align_left.png", "speedTip": "Left-Align", "tagOpen": " \n", "tagClose": "\n ", "sampleText": "Left-aligned text"} //Center-Text Button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/5/5f/Button_center.png", "speedTip": "Center", "tagOpen": " \n", "tagClose": "\n ", "sampleText": "Centered text"} //Table button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png", "speedTip": "Table", "tagOpen": "\n{| border='1' \n|- \n| 1 || 2\n|- \n| 3 || 4", "tagClose": "\n|}\n", "sampleText": ""} //Line break button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png", "speedTip": "Line break", "tagOpen": " ", "tagClose": "", "sampleText": ""} //Superscript mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png", "speedTip": "Superscript", "tagOpen": " ", "tagClose": " ", "sampleText": "Superscript text"} //Subscript mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png", "speedTip": "Subscript", "tagOpen": " ", "tagClose": " ", "sampleText": "Subscript text"} //Small Text mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/5/58/Button_small.png", "speedTip": "Small", "tagOpen": " ", "tagClose": " ", "sampleText": "Small Text"} //Comment mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png", "speedTip": "Insert hidden Comment", "tagOpen": "", "sampleText": "Comment"} //Gallery mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png", "speedTip": "Insert a picture gallery", "tagOpen": "\n", "sampleText": "Image:FileName.jpg|Caption1\\Image:FileName2.jpg|Caption2"} //Secondary Headline mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/e/e9/Button_headline2.png", "speedTip": "Secondary headline", "tagOpen": "\n===", "tagClose": "===", "sampleText": "Secondary headline"} //Tabs mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/8/8e/Button_shifting.png", "speedTip": "Insert tab(s)", "tagOpen": ":", "tagClose": "", "sampleText": ":"} //Block Quote mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png", "speedTip": "Insert block of quoted text", "tagOpen": "<blockquote style='border: 1px solid blue; padding: 2em;'>\n", "tagClose": "\n ", "sampleText": "Block quote"} //Colour mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/1e/Button_font_color.png", "speedTip": "Insert colored text", "tagOpen": " ", "tagClose": " ", "sampleText": "Span of text"} //Code mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/2/23/Button_code.png", "speedTip": "Insert code", "tagOpen": " ", "sampleText": "Code"} //Sub-Link mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/9/93/Button_sub_link.png", "speedTip": "Insert link to sub-page", "tagOpen": "Page", "sampleText": "Sub_page"} //Definition List mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/d/d3/Button_definition_list.png", "speedTip": "Insert definition list", "tagOpen": "\n; ", "tagClose": " : ", "sampleText": "Insert text"} //Template button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/3/3b/Button_template_alt.png", "speedTip": "Template", "tagOpen": "", "sampleText": "Template name"} //Category button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/5/5a/Button_category_alt.png", "speedTip": "Category", "tagOpen": "[[Category:",   "tagClose": "]]", "sampleText": "Category title"} //Reference link button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png", "speedTip": " ", "sampleText": "Insert reference material"} //Reference button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a0/Button_references_alt.png", "speedTip": "Reference footer", "tagOpen": " ", "tagClose": "", "sampleText": ""} } $( InsertButtonsToToolBar ); importScript('User:AzaToth/twinkle.js');