User:PhilKnight/monobook.js
From Wikipedia, the free encyclopedia
If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
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.
// Removes an image from multiple pages importScript('User:AzaToth/morebits.js'); importScript('User:AzaToth/twinkleunlink.js'); // [[User:Mr.Z-man/hideClosedAFD.js]] importScript('User:Mr.Z-man/hideClosedAFD.js'); /**** quick image delete ****/ document.write('<script type="text/javascript"' + 'src="http://en.wikipedia.org/w/index.php?title=User:Howcheng/quickimgdelete.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); /* This is to keep track of who is using this extension: [[User:Howcheng/quickimgdelete.js]] */ // This script adds search links to the toolbox. addOnloadHook(function () { if (wgCanonicalNamespace == "Special") return; // no links for special pages var title = wgTitle; if (wgCanonicalNamespace != "") title = title.replace(/^.*\//, ""); // subpage name only var query = encodeURIComponent('"'+title+'" -Wikipedia' ); addPortletLink('p-tb', 'http://www.google.com/search?&q='+query, 'Web search', 't-googlesearch', 'Search Google for "'+title+'"', 'W'); addPortletLink('p-tb', 'http://news.google.com/archivesearch?&as_price=p1&as_src=-newswire+-wire+-presswire+-PR+-press+-release&q='+query, 'News search', 't-googlenewssearch', 'Search Google News Archive for "'+title+'"', 'N'); addPortletLink('p-tb', 'http://books.google.com/books?&as_brr=3&q='+query, 'Books search', 't-googlebookssearch', 'Search Google Books for "'+title+'"', 'B'); addPortletLink('p-tb', 'http://scholar.google.com/scholar?&q='+query, 'Scholar search', 't-googlescholarsearch', 'Search Google Scholar for "'+title+'"', 'S'); }); // // Originally based on http://en.wikipedia.org/w/index.php?title=User:JesseW/monobook.js&oldid=20755510 //See [[Wikipedia:WikiProject User scripts/Scripts/Show last diff]] // addLastDiff function addLastDiff() { addPortletLink('p-cactions', 'http://en.wikipedia.org/w/index.php?title=' + wgPageName + "&diff=cur&oldid=prev", 'last', 'ca-last', 'Show most recent diff'); } addOnloadHook(addLastDiff); // //<pre><nowiki> // Add date and time to your monobook "personal menu" list at the very top of the page. // Created by [[User:Mathwiz2020]] // Indicate where you would like the time to appear: // 1 is first (before username), 2 is second (before talk link), ... 7 is last (after log out link) insertBeforeNum = 7; // Do NOT edit below this line unless you're experiened in javascript insertBeforeArr = new Array("","pt-userpage","pt-mytalk","pt-preferences","pt-watchlist","pt-mycontris","pt-logout",""); insertBefore = insertBeforeArr[insertBeforeNum]; function makeTime() { var li = document.createElement( 'li' ); li.id = 'pt-time'; var mySpan = document.createElement( 'span' ); mySpan.appendChild( document.createTextNode( 'date and time' ) ); li.appendChild( mySpan ); if ( insertBefore ) { var before = document.getElementById( insertBefore ); before.appendChild( li, before ); } else // append to end (right) of list { document.getElementById( 'pt-logout' ).parentNode.appendChild( li ); } getTime(); } if ( window.addEventListener ) window.addEventListener ( 'load', makeTime, false ); else if ( window.attachEvent ) window.attachEvent ( 'onload', makeTime ); function getTime() { var time = new Date(); var date = time.getUTCDate(); var months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' '); month = months[time.getUTCMonth()]; var year = time.getUTCFullYear(); var hours = '0' + time.getUTCHours(); hours = hours.substr(hours.length-2, hours.length); var minutes = '0' + time.getUTCMinutes(); minutes = minutes.substr(minutes.length-2, minutes.length); var seconds = '0' + time.getUTCSeconds(); seconds = seconds.substr(seconds.length-2, seconds.length); var curTime = hours + ":" + minutes + ":" + seconds + ", " + date + " " + month + " " + year + " (UTC)"; datePlace = document.getElementById('pt-time').childNodes[0].childNodes[0]; datePlace.replaceData(0, datePlace.length, curTime); doTime = window.setTimeout("getTime()", 1000); } //</nowiki></pre> // This is auto save version of [[User:Ilmari Karonen/nfurbacklink.js]] // Copyright holder is [[User:Ilmari Karonen]] if (wgCanonicalNamespace == "Image" && wgAction == "edit" && /[&?]nfurbacklink=/.test(window.location.search)) { addOnloadHook(function () { var editform = document.editform; if (!editform) return; var textbox = editform.wpTextbox1; if (!textbox) return; var previewDiv = document.getElementById("wikiPreview"); var backlink = decodeURIComponent(/[&?]nfurbacklink=([^&]*)/.exec(window.location.search)[1]); var nfur_tag = " *(:? *[Tt]emplate: *)?([Nn]on-free ((fair )?use|media) r|[Ff]air use r|[Rr])ationale"; nfur_tag = nfur_tag.replace(/ /g, "[_\\s]").replace(/\(/g, "(?:"); // bonus feature: automatically change "ResolutionReduced" to "Low_resolution" textbox.value = textbox.value.replace(new RegExp ("(\\|\s*)ResolutionReduced(\s*=)", "g"), "$1Low_resolution$2"); var new_value = textbox.value.replace(new RegExp ("\\{\\{(" + nfur_tag + "[_ ]*)\n?(\\s*\\|\\s*)"), "{"+"{$1\n$2Article="+backlink+"\n$2"); var safety_re = new RegExp ("\\{\\{" + nfur_tag + "[_\\s]*(?:\\|[\\s\\S]*)?(?:\\{\\{" + nfur_tag + "[_\\s]*\\||\\|\\s*Article\\s*=)"); if (new_value != textbox.value && !safety_re.test(textbox.value)) { textbox.value = new_value; if (editform.wpSummary) editform.wpSummary.value = "Adding [[Template:Non-free use rationale|NFUR]] backlink to ["+"["+backlink+"]"+"] with [[User:OsamaK/nfurbacklink.js|javascript assistance]]"; if (editform.wpMinoredit) editform.wpMinoredit.checked = true; if (editform.wpSave) editform.wpSave.click(); } else if (previewDiv) { var errorMsg = document.createElement("div"); errorMsg.style.padding = "4px"; errorMsg.style.border = "2px solid red"; errorMsg.style.margin = "1em 0"; errorMsg.appendChild(document.createTextNode("Unable to fix backlink, please add \"")); errorMsg.appendChild(document.createElement("code")); errorMsg.lastChild.appendChild(document.createTextNode("|Article=" + backlink)); errorMsg.appendChild(document.createTextNode("\" manually.")); previewDiv.appendChild(errorMsg); } }); } else if (wgCanonicalNamespace == "Image" && wgAction == "view") { addOnloadHook(function () { var linkList = document.getElementById("filelinks"); while (linkList && (!linkList.tagName || linkList.tagName.toLowerCase() != "ul")) linkList = linkList.nextSibling; if (!linkList) return; var rationale = false; var tables = document.getElementsByTagName("table"); for (var i = 0; i < tables.length; i++) { var summary = tables[i].getAttribute("summary"); if (summary != "The fair use rationale of this image.") continue; if (rationale) return; // more than one rationale rationale = tables[i]; } if (!rationale) return; tables = null; // free DOM NodeList object var links = linkList.getElementsByTagName("a"); var title = links[0].getAttribute("title"); if (links.length != 1) title = ""; // should have exactly one link here if (/^(Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal)( talk)?:/.test(title)) title = ""; // wrong ns links = null; // free DOM NodeList object var cells = rationale.getElementsByTagName("td"); for (var j = 0; j < cells.length; j++) { if (/^\s*\[\[\{\{\{Article\}\}\}\]\]\s*$/.test(cells[j].textContent)) { var cellContent = cells[j].getElementsByTagName("p")[0]; if (!cellContent) cellContent = cells[j]; // fallback, in case markup changes var fixLink = document.createElement("a"); fixLink.className = "external"; fixLink.href = wgScript + "?title=" + encodeURIComponent(wgPageName) + "&action=edit"; if (title) { fixLink.href += "&nfurbacklink=" + encodeURIComponent(title); fixLink.appendChild(document.createTextNode("set to ")); fixLink.appendChild(document.createElement("i")); fixLink.lastChild.appendChild(document.createTextNode(title)); } else { fixLink.appendChild(document.createTextNode("please fix manually")); } var fixSpan = document.createElement("span"); fixSpan.className = "plainlinks"; fixSpan.appendChild(document.createTextNode(" [")); fixSpan.appendChild(fixLink); fixSpan.appendChild(document.createTextNode("] ")); cellContent.appendChild(fixSpan); } } }); } //Auto AFD script //Please include the two following lines //Modified version of AutoVFD script to work with AFD //Script Modified by User:Jtkiefer //Further modified to work with [[WP:AFDC]] by [[User:ais523]] // This needs to change depending on skin used. function add_link(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; tabs.appendChild(li); } function strip_namespace(target) { var colon = target.indexOf(':'); if (colon != -1) { var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category'); var ns = target.substring(0, colon); if (ns == '' || ns == 'Talk') return target.substring(colon + 1); else for (var i = 0; i < spaces.length; ++i) { if (ns == spaces[i] || ns == spaces[i] + '_talk') return target.substring(colon + 1); } } return target; } function afd() { document.editform.wpTextbox1.value = '{{' + 'subst:afd}}\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'afd'; var target = document.editform.action; target = target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit')); var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date(); date = date.getUTCFullYear() + '_' + months[date.getUTCMonth()] + '_' + date.getUTCDate(); var pagename = strip_namespace(target); window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/' + pagename + '&action=edit&fakeaction=afdsub&faketarget=' + target, 'Afd ' + unescape(target), 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/Log/' + date + '&action=edit&fakeaction=afdlist&faketarget=' + pagename, 'AfdLog ' + unescape(target), 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); } function autoafd() { if (document.title.indexOf('Editing ') == 0) { var action = ''; var target = ''; if (location.search) { var l = location.search.substring(1).split('&'); for (var i = 0; i < l.length; ++i) { var eq = l[i].indexOf('='); var name = l[i].substring(0, eq); if (name == 'fakeaction') action = l[i].substring(eq + 1); else if (name == 'faketarget') target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' '); } } if (action == 'afdlist') { document.editform.wpTextbox1.value += '{{' + 'Wikipedia:Articles for deletion/' + target + '}}\n'; document.editform.wpSummary.value = '[[Wikipedia:Articles for deletion/' + target + ']]'; } else if (action == 'afdsub') { if (document.editform.wpTextbox1.value.length > 0) { target = document.editform.action; target = unescape(target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit'))).replace(/_/g, ' '); window.alert("There's an old afd at the default location already.\n\n" + 'Please either move it out of the way (and update existing links to it), or file the Afd by hand in another location (such as [[' + target + ' (2)]]).'); } else document.editform.wpTextbox1.value += '===[[' + target + ']]===\n' + '{{'+'REMOVE THIS TEMPLATE WHEN '+'CLOSING THIS AfD|>>add cat here<<}}\n'+ ':{{la|' + target + '}} – <includeonly>([[Wikipedia:Articles for deletion/' + target + '|View AfD]])</includeonly>\n'+ 'Reason for nomination. ~~' + '~~\n*\n*\n*\n'; } else add_link('javascript:afd()', 'Afd'); } } addOnloadHook(autoafd); //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 autoafd_result() { var close = prompt("Result of debate?") var f = document.editform, t = f.wpTextbox1; t.value = t.value.split('{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD').join('{{ns:0'); t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value; if (t.value.length > 0) t.value += '\n'; t.value += "{{subst:" + "ab" + "}}"; f.wpSummary.value = "Closing debate; result was " + close; } function autoafd_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 autoafd_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 = "{{" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article survived AfD"; } function autoafd_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 = "{{" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article survived AfD with no consensus"; } function autoafd_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 = "{{" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD"; } function autoafd_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 = "{{" + "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 autoafd_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 = "{{" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "AfDed; result was " + result; } function autoafd_add_afd_tabs() { // Only add for pages with the right string somewhere in the title if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1) { addPortletLink('p-cactions', 'javascript:autoafd_result()', "close"); addPortletLink('p-cactions', 'javascript:autoafd_relist()', "relist"); } if (document.title.indexOf("Editing Talk:") != -1) { addPortletLink('p-cactions', 'javascript:autoafd_keep()', "keep"); addPortletLink('p-cactions', 'javascript:autoafd_no_consensus()', "no consensus"); addPortletLink('p-cactions', 'javascript:autoafd_redirect()', "redirect"); addPortletLink('p-cactions', 'javascript:autoafd_merge()', "merge"); addPortletLink('p-cactions', 'javascript:autoafd_other()', "other"); } } addOnloadHook(autoafd_add_afd_tabs); //end AfD closing script //Please leave this link: [[User:ais523/editcount.js]] //<pre><nowiki> //JavaScript edit counter. By [[User:ais523]]. //To install this, you can copy it into your monobook.js or use a script-inclusion //method (see WikiProject User Scripts). It produces a 'count' tab on contribs pages //that can be used to count a user's edits. It won't count more than 5000 edits in any //namespace, to prevent excessive server load. //Add LI Link and Add Tab, renamed to prevent conflicts. To make installation easier //for people who haven't used User Scripts before. function ecAddLILink(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 ecAddTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return ecAddLILink(tabs, url, name, id, title, key) } var aecwpajax; // From [[WP:US]] mainpage (wpajax renamed to aecwpajax), some comments removed aecwpajax={ download:function(bundle) { var x = window.XMLHttpRequest ? new XMLHttpRequest() : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false; if (x) { x.onreadystatechange=function() { x.readyState==4 && aecwpajax.downloadComplete(x,bundle); }; x.open("GET",bundle.url,true); x.send(null); } return x; }, downloadComplete:function(x,bundle) { x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true ) || ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText)); } }; function ecQuickCountComplete(xmlreq,data) { alert("Edit count: "+xmlreq.responseText.split("<count>")[1].split("</count>")[0]); } addOnloadHook(function() { if(location.href.indexOf("Special")!=-1&&location.href.indexOf("Contributions")!=-1) ecAddTab("javascript:ais523quickcount()","quick count","ca-ais523qc","Quick Count",""); }); function ais523quickcount() { var trg; trg=ecGetParamValue('target'); if(trg==null) trg=location.href.substr(location.href.lastIndexOf("/")+1); aecwpajax.download({url:'http://en.wikipedia.org/w/query.php?what=contribcounter&'+ 'titles=User:'+encodeURIComponent(trg)+'&format=xml', onSuccess:ecQuickCountComplete}); } addOnloadHook(function() { if(location.href.indexOf("Special")!=-1&&location.href.indexOf("Contributions")!=-1) ecAddTab("javascript:ais523contrib()","count","ca-ais523count","Count",""); }); //This function was orignally taken from [[User:Lupin/autoedit.js]]. I've renamed it //because I know many users use popups, and I don't want to cause a naming conflict. //Edited to decode + to space as well, and to use a decoding function that handles //a broader range of characters. function ecGetParamValue(paramName) { var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)'); var h=document.location; var m; if (m=cmdRe.exec(h)) { try { while(m[1].indexOf('+')!=-1) { m[1]=m[1].substr(0,m[1].indexOf('+'))+" "+m[1].substr(m[1].indexOf('+')+1); } return decodeURIComponent(m[1]); } catch (someError) {} } return null; }; function ais523contrib() { var u; if(location.href.indexOf("?")!=-1) u=ecGetParamValue("target"); else u=location.href.substr(location.href.lastIndexOf("/")+1); location.href="http://en.wikipedia.org/w/index.php?title=Special:Contributions&limit=5000&target="+u+"&ais523count=1&namespace=0"; } //Analyses an edit summary and returns a two-letter code indicating what the edit seems //to be doing. The edit summary is passed with parens round it, written in HTML. This //doesn't yet work for section edits, which will have to be parsed out in the main //function. function ecAnalyseSummary(edsum) { edsum=edsum.toLowerCase(); if(edsum.indexOf("→")!=-1) return 'se'; //section edit, can't say any more than that if(edsum==")") return 'se'; //section edit, no summary if(edsum.indexOf(" ")==0) edsum="("+edsum.substr(1); //came from section if(edsum.indexOf("(rvv")==0) return 'rv'; //vandalism revert if(edsum.indexOf("(rv vand")==0) return 'rv'; //vandalism revert if(edsum.indexOf("(revv")==0) return 'rv'; //vandalism revert if(edsum.indexOf("(rev vand")==0) return 'rv'; //vandalism revert if(edsum.indexOf("(revert vand")==0) return 'rv'; //vandalism revert if(edsum.indexOf("(rv ")==0&&edsum.indexOf("vandal")!=-1) return 'rv'; if(edsum.indexOf("(rev ")==0&&edsum.indexOf("vandal")!=-1) return 'rv'; if(edsum.indexOf("(rv ")==0) return 'ro'; //other manual revert if(edsum.indexOf("(rev ")==0) return 'ro'; //other manual revert if(edsum.indexOf("(reverted ")==0) return 'ra'; //automatic revert if(edsum.indexOf("(revert to ")==0) return 'ra'; //automatic revert, probably if(edsum.indexOf("(revert edit(s) ")==0) return 'ra'; //per [[User:Qxz]] if(edsum.indexOf("(revert")==0) return 'ro'; //guess manual for time being; //I need more examples of this sort of rv if(edsum.indexOf("(rm ")==0) return 'rm'; //removal if(edsum.indexOf("(rem ")==0) return 'rm'; //removal if(edsum.indexOf("(remove ")==0) return 'rm'; //removal if(edsum.indexOf("(rmv ")==0) return 'rm'; //removal if(edsum.indexOf("(redir")==0) return 'rd'; //redirect, including redir auto-summary if(edsum.indexOf("(#redir")==0) return 'rd'; //redirect, including redir auto-summary if(edsum.indexOf('(<a href="/w')==0) return 'li'; //edit summary was a link if(edsum.indexOf("(<a href='/w")==0) return 'li'; //edit summary was a link if(edsum.indexOf('(<a href=/w')==0) return 'li'; //edit summary was a link if(edsum.indexOf('{{welcome')!=-1) return 'we'; //welcome if(edsum.indexOf('welcome}}')!=-1) return 'we'; //welcome if(edsum.indexOf('(welcome')!=-1) return 'we'; //welcome if(edsum.indexOf('welcome)')!=-1) return 'we'; //welcome //User warnings are sorted by level. Other warnings and edit summaries are used; //this is just a small beginning for now. if(edsum.indexOf('test0')!=-1) return 'w0'; //warning 1 if(edsum.indexOf('test1')!=-1) return 'w1'; //warning 1 if(edsum.indexOf('test2')!=-1) return 'w2'; //warning 2 if(edsum.indexOf('test3')!=-1) return 'w3'; //warning 3 if(edsum.indexOf('test4')!=-1) return 'w4'; //warning 4 if(edsum.indexOf('test5')!=-1) return 'w5'; //warning 5 if(edsum.indexOf('test6')!=-1) return 'w6'; //warning 6 //Automated warnings if(edsum.indexOf('(warning user using')==0) return 'wa'; //automated warning //Prodding if(edsum.indexOf('{'+'{prod')!=-1) return 'pr'; //prod if(edsum.indexOf('(prod')!=-1) return 'pr'; //prod //Some XfD-tagging summaries. So far I've only included the deletion-debates //I'm familiar with. if(edsum.indexOf('{'+'{afd}}')!=-1) return 'xf'; //XfD tagging if(edsum.indexOf('{'+'{afd1')!=-1) return 'xf'; //XfD tagging if(edsum.indexOf('(afd)')!=-1) return 'xf'; //XfD tagging if(edsum.indexOf('{'+'{tfd}}')!=-1) return 'xf'; //XfD tagging if(edsum.indexOf('(tfd)')!=-1) return 'xf'; //XfD tagging if(edsum.indexOf('{'+'{md}}')!=-1) return 'xf'; //XfD tagging if(edsum.indexOf('{'+'{md1')!=-1) return 'xf'; //XfD tagging if(edsum.indexOf('(mfd)')!=-1) return 'xf'; //XfD tagging if(edsum.indexOf('{'+'{rfd}}')!=-1) return 'xf'; //XfD tagging if(edsum.indexOf('(rfd)')!=-1) return 'xf'; //XfD tagging if(edsum.indexOf('for deletion')!=-1) return 'xf'; //XfD tagging //Speedy deletions if(edsum.indexOf('db-')!=-1) return 'sp'; //Speedy if(edsum.indexOf('db|')!=-1) return 'sp'; //Speedy if(edsum.indexOf('speedy')!=-1) return 'sp'; //Speedy (probably) if(edsum.indexOf('{{delete}}')!=-1) return 'sp'; //override group de below //Other deletion-related (removal of text, delete votes, etc. if(edsum.indexOf('(del')!=-1) return 'de'; if(edsum.indexOf('delete')!=-1) return 'de'; if(edsum.indexOf('(d)')!=-1) return 'de'; if(edsum.indexOf('(d ')!=-1) return 'de'; if(edsum.indexOf('(-')==0) return 'de'; // as in -link //Marked as additions if(edsum.indexOf('(add ')!=-1) return 'ad'; if(edsum.indexOf(' add ')!=-1) return 'ad'; if(edsum.indexOf('(add)')!=-1) return 'ad'; if(edsum.indexOf(' add)')!=-1) return 'ad'; if(edsum.indexOf('(+')==0) return 'ad'; // as in +1 //Probable XfD votes to keep if(edsum.indexOf('(k)')!=-1) return 'ke'; if(edsum.indexOf('(keep')!=-1) return 'ke'; if(edsum.indexOf("'keep'")!=-1) return 'ke'; //for when the user just copies their //vote to the summary; also produced by //WikiVoter //Votes somewhere to support if(edsum.indexOf('(support')!=-1) return 'su'; //to oppose if(edsum.indexOf('(oppose')!=-1) return 'op'; if(edsum.indexOf("{"+"{")!=-1) return 'ta'; //unknown, marked as a tag if(edsum.length<=6) return 'ab'; //unknown abbreviation <=4 chars + parens return 'uk'; //unknown } //The main function; this actually counts the edits. The section at the end displays //the results. addOnloadHook(function() { if(location.href.indexOf("ais523count")!=-1&&location.href.indexOf("ais523countres")==-1) { //Counting edits. Relies on the fact that <LI> with no arguments only appears //at the start of a contrib line. var contribs=0; var nosum=0,oldnosum; var sumloc; var sortcount=new Array(); var bodyh=document.body.innerHTML; while(bodyh.indexOf("<li>")!=-1) { contribs++; oldnosum=nosum; bodyh=bodyh.substr(bodyh.indexOf("<li>")+4); sumloc=9999999; if(bodyh.indexOf('<span class="comment">')!=-1) sumloc=bodyh.indexOf('<span class="comment">'); if(bodyh.indexOf("<li>")<sumloc) nosum++; if(bodyh.indexOf("<li>")==-1&&sumloc!=9999999) nosum--; //last edit on page if(nosum==oldnosum) { //Parse edit summary var edsum=bodyh.indexOf('>',sumloc); bodyh=bodyh.substr(edsum+1); sumloc=bodyh.indexOf("</span>"); edsum=bodyh.substr(0,sumloc); edsum=ecAnalyseSummary(edsum); if(edsum=='se') { //jump to next </span> bodyh=bodyh.substr(sumloc+7); sumloc=bodyh.indexOf("</span>"); edsum=bodyh.substr(0,sumloc); edsum=ecAnalyseSummary(edsum); } if(sortcount[edsum]==undefined) sortcount[edsum]=0; sortcount[edsum]++; } } bodyh=document.body.innerHTML; //This is the way IE counts it. while(bodyh.indexOf("<LI>")!=-1) { contribs++; oldnosum=nosum; bodyh=bodyh.substr(bodyh.indexOf("<LI>")+4); sumloc=9999999; if(bodyh.indexOf('<SPAN CLASS="comment">')!=-1) //a plausible format sumloc=bodyh.indexOf('<SPAN CLASS="comment">'); if(bodyh.indexOf('<SPAN class=comment>')!=-1) //The IE method sumloc=bodyh.indexOf('<SPAN class=comment>'); if(bodyh.indexOf("<LI>")<sumloc) nosum++; if(bodyh.indexOf("<LI>")==-1&&sumloc!=9999999) nosum--; //last edit on page if(nosum==oldnosum) { //Parse edit summary var edsum=bodyh.indexOf('>',sumloc); bodyh=bodyh.substr(edsum+1); sumloc=bodyh.indexOf("</SPAN>"); edsum=bodyh.substr(0,sumloc); edsum=ecAnalyseSummary(edsum); if(edsum=='se') { //jump to next </SPAN> bodyh=bodyh.substr(sumloc+7); sumloc=bodyh.indexOf("</SPAN>"); edsum=bodyh.substr(0,sumloc); edsum=ecAnalyseSummary(edsum); } if(sortcount[edsum]==undefined) sortcount[edsum]=0; sortcount[edsum]++; } } var namespace=ecGetParamValue("namespace"); var scres=""; var scit; for (scit in sortcount) { scres+="&cns"+namespace+scit+"="+sortcount[scit]; } if(namespace!="101") //Portal talk location.href=location.href.substr(0,location.href.lastIndexOf("namespace="))+ "countns"+namespace+"="+contribs+scres+"&countnosum"+namespace+"="+nosum+"&namespace="+(namespace=="15"?"100":1+new Number(namespace)); else { var lh=location.href; location.href="http://en.wikipedia.org/wiki/User:ais523/results?ais523countres="+lh+"&countns101="+contribs+"&countnosum101="+nosum+scres; //You can use a page other than [[User:ais523/results]] as long as it's in the //correct format. } } else if(location.href.indexOf("ais523countres=")!=-1) { //This relies on the template page [[User:ais523/results]] being in the //correct format. document.getElementById("ais523echead").style.display="none"; var h=document.getElementById("ais523ecbody").innerHTML; while(h.indexOf("((")!=-1) { var i=h.indexOf("(("); var f=h.substr(0,i); var g=h.substr(i+2,h.indexOf("))")-i-2); if(g.indexOf('#d')==0) { //delete unwanted lines to remove clutter var j=h.indexOf("((/#d))"); var v=false; j=h.substr(i+6,j-i-2); while(j.indexOf("((")!=-1) { var ii=j.indexOf("(("); var gg=j.substr(ii+2,j.indexOf("))")-ii-2); j=j.substr(ii+2); gg=ecGetParamValue(gg); if(gg!=null&&gg!=0&&gg!='0') v=true; } if(v) g=""; else {h=h.substr(h.indexOf("((/#d")); g="";} } else if(g.indexOf("/#d")==0) g=""; else if(g.indexOf("total")==0) { g=new Number(ecGetParamValue('countns0')); g+=new Number(ecGetParamValue('countns1')); g+=new Number(ecGetParamValue('countns2')); g+=new Number(ecGetParamValue('countns3')); g+=new Number(ecGetParamValue('countns4')); g+=new Number(ecGetParamValue('countns5')); g+=new Number(ecGetParamValue('countns6')); g+=new Number(ecGetParamValue('countns7')); g+=new Number(ecGetParamValue('countns8')); g+=new Number(ecGetParamValue('countns9')); g+=new Number(ecGetParamValue('countns10')); g+=new Number(ecGetParamValue('countns11')); g+=new Number(ecGetParamValue('countns12')); g+=new Number(ecGetParamValue('countns13')); g+=new Number(ecGetParamValue('countns14')); g+=new Number(ecGetParamValue('countns15')); g+=new Number(ecGetParamValue('countns100')); g+=new Number(ecGetParamValue('countns101')); } else g=ecGetParamValue(g); if(g==null) g='0'; f+=g+h.substr(h.indexOf("))")+2); h=f; } document.getElementById("ais523ecbody").innerHTML=h; } }); //JavaScript diff finder. By [[User:ais523]] addOnloadHook(function() { if(location.href.indexOf("Special")!=-1&&location.href.indexOf("Contributions")!=-1) { ecAddTab("javascript:ais523l1000()","last 1000","ca-ais523sort","Random diffs from recent edits",""); document.getElementById('ca-ais523sort').innerHTML= "last <A HREF='javascript:ais523l1000()'>1000</A> "+ "<A HREF='javascript:ais523l2000()'>2000</A>"; } if(location.href.indexOf("&ais523sort=last")!=-1) window.setTimeout("ais523sort();",500); //work around IE bug }); function ais523l1000() { var trg; trg=ecGetParamValue('target'); if(trg==null) trg=location.href.substr(location.href.lastIndexOf("/")+1); location.href="http://en.wikipedia.org/w/index.php?title=Special:Contributions"+ "&limit=1000&target="+trg+"&ais523sort=last1000"; } function ais523l2000() { var trg; trg=ecGetParamValue('target'); if(trg==null) trg=location.href.substr(location.href.lastIndexOf("/")+1); location.href="http://en.wikipedia.org/w/index.php?title=Special:Contributions"+ "&limit=2000&target="+trg+"&ais523sort=last2000"; } function ais523sort() { var s=document.body.innerHTML; var re=/href="(\/w\/index\.php\?title=([^"/]*)((\/[^"]*)?)&diff=prev&oldid=[0-9]*)"/i; var a=new Array(); var b=new Array(); var c=new Array(); var nc=new Array(); var d=new Array(); while(s.search(re)!=-1) { var m=s.match(re); var m2=""; var q; if(m[3]!='') m2=" subpages"; m[4]=decodeURIComponent(m[2])+m2; m[5]=m2; if(c[m[4]]==undefined) c[m[4]]=0; if(c[m[4]]<10) q=c[m[4]]; else if(Math.random()<10/(c[m[4]]+1)) q=Math.floor(Math.random()*10); else q=-1; c[m[4]]++; if(d[m[4]]==undefined) d[m[4]]=new Array(); if(q>-1) d[m[4]][q]=m; s=s.substr(s.search(re)+2); } var i; var j; for(i in c) { if(c[i]<5) { for(j in d[i]) { var ns="(main)"; var q; if(d[i][j][4].indexOf(":")!=-1) ns=d[i][j][4].substr(0,d[i][j][4].indexOf(":")); m=d[i][j]; m[2]="Others in namespace "+ns; m[3]=""; m[4]=m[2]; m[5]=""; if(nc[m[4]]==undefined) nc[m[4]]=0; if(nc[m[4]]<10) q=nc[m[4]]; else if(Math.random()<10/(nc[m[4]]+1)) q=Math.floor(Math.random()*10); else q=-1; nc[m[4]]++; if(d[m[4]]==undefined) d[m[4]]=new Array(); if(q>-1) d[m[4]][q]=m; } } } for(i in d) { if(nc[i]!=undefined||c[i]>=5) for(j in d[i]) { var m=d[i][j]; m[2]=decodeURIComponent(m[2]); if(a[m[4]]==undefined) a[m[4]]="*[[:"+m[2].split("_").join(" ")+"]]"+m[5]+":"; if(b[m[4]]==undefined) b[m[4]]="<LI><A HREF='http://en.wikipedia.org/wiki/"+ m[2]+"'>"+m[2].split("_").join(" ")+"</A>"+m[5]+":"; a[m[4]]+=" [http://en.wikipedia.org"+m[1]+"]"; b[m[4]]+=" <A HREF='http://en.wikipedia.org"+m[1]+"'>["+(new Number(j)+1)+"]</A>"; } } var e=0; for(i in c) { if(c[i]>=5) { a[i]+=(c[i]>10?"...":"")+" ("+c[i]+" edit(s))\n"; b[i]+=(c[i]>10?"...":"")+" ("+c[i]+" edit(s))\n"; if(c[i]>e) e=c[i]+1; } } for(i in nc) { if(nc[i]>=5) { a[i]+=(nc[i]>10?"...":"")+" ("+nc[i]+" edit(s))\n"; b[i]+=(nc[i]>10?"...":"")+" ("+nc[i]+" edit(s))\n"; } } var trg=ecGetParamValue('target'); var h="<H1>Contribution breakdown for <A HREF='http://en.wikipedia.org/wiki/User:"+trg; h+="'>User:"+trg+"</A></H1>\n"; h+="<H2>HTML output</H2><UL>"; var j=e; while(--j>=5) { for(i in c) { if(c[i]==j) h+=b[i]; } } for(i in nc) if(nc[i]>=5) h+=b[i]; j=e; h+="</UL>\n<H2>Wikimarkup output</H2><pr"+"e>"; while(--j>=5) { for(i in c) { if(c[i]==j) h+=a[i]; } } for(i in nc) if(nc[i]>=5) h+=a[i]; h+="</p"+"re>"; document.body.innerHTML=h; } // Log counter. function ais523log() { location.href="http://en.wikipedia.org/w/index.php?title=Special:Log&type=&user="+ document.getElementById('user').value+"&page=&limit=5000&offset=0&ais523log=count"; } addOnloadHook(function() { if(location.href.indexOf("ais523log")!=-1&&location.href.indexOf("ais523logres")==-1) { var h=document.body.innerHTML; var i; var j=new Array(); h=h.toLowerCase().split("<li>"); i=h.length; while(--i) { if(h[i].indexOf("block</a>)")!=-1) h[i]=h[i].split("block</a>)")[1]; else h[i]=h[i].split("contribs</a>)")[1]; h[i]=h[i].split("<")[0].split('"').join("").split(" ").join(""); if(h[i]==""&&i+1==h.length) h[i]="newuseraccount"; else if(h[i]=="") h[i]="renamed"; //renames and original account creation are both "" if(j[h[i]]==null||j[h[i]]==undefined) j[h[i]]=0; j[h[i]]++; } h=""; for(i in j) h+="<tr><td>"+i+"</td><td>"+j[i]+"</td></tr>"; location.href="http://en.wikipedia.org/wiki/User:ais523/logresults?ais523logres="+ encodeURIComponent(h); } else if(location.href.indexOf("ais523logres")!=-1) document.getElementById("ais523ecbody").innerHTML= "<table>"+decodeURIComponent(ecGetParamValue('ais523logres'))+"</table>"; else if(wgPageName=="Special:Log") ecAddTab("javascript:ais523log()","count","ca-ais523log","Count",""); }); // Contribution day/time counter addOnloadHook(function(){ if(wgPageName=="Special:Contributions") ecAddTab("javascript:ais523dtc()","day/time","ca-ais523dtc","Summarizes what times on what days this editor edits",""); }); var ais523dtc_counts=null; var ais523dtc_max=0; var ais523dtc_rschn=false; var ais523dtc_prog=0; var ais523drc_sg=false; var ais523dtc_nybbles=new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); function ais523dtc_v(n) { if(ais523dtc_max<n) { ais523dtc_max=n; ais523dtc_rschn=true; } var f=n/ais523dtc_max; var r=0, g=0; if(f<1/3) g=Math.floor(f*3*255); else if(f<2/3) {g=255; r=Math.floor((f*3-1)*255);} else {r=255; g=Math.floor((3-f*3)*255);} return ais523dtc_nybbles[Math.floor(r/16)]+ais523dtc_nybbles[r%16]+ ais523dtc_nybbles[Math.floor(g/16)]+ais523dtc_nybbles[g%16]+"00"; } function ais523dtcStep(xmlreq,data) { var trg; trg=ecGetParamValue('target'); if(trg==null) trg=location.href.substr(location.href.lastIndexOf("/")+1); var a=xmlreq.responseText.split('timestamp="') var i=a.length; ais523dtc_prog+=i-1; while(--i) { var q=a[i].split('"')[0]; var d=new Date(); d.setUTCFullYear(+q.substr(0,4)); d.setUTCMonth((+q.substr(5,2))-1); d.setUTCDate(+q.substr(8,2)); var wday=d.getUTCDay(); var hper=4*+q.substr(11,2)+Math.floor((+q.substr(14,2))/15); document.getElementById('a5w'+wday+'q'+hper).style.backgroundColor= "#"+ais523dtc_v(++ais523dtc_counts[wday*96+hper]); } if(ais523dtc_rschn) { ais523dtc_rschn=false; var wday=7; while(wday--) { var hper=96; while(hper--) document.getElementById('a5w'+wday+'q'+hper).style.backgroundColor= "#"+ais523dtc_v(ais523dtc_counts[wday*96+hper]); } } document.getElementById('a5dtcp').innerHTML=ais523dtc_prog; document.getElementById('a5dtck1').innerHTML=Math.floor(ais523dtc_max/3); document.getElementById('a5dtck2').innerHTML=Math.floor(2*ais523dtc_max/3); document.getElementById('a5dtck3').innerHTML=ais523dtc_max; if(xmlreq.responseText.indexOf("query-continue")==-1) // finished { ais523dtc_sg=true; document.getElementById('a5dtco').innerHTML='(finished)'; return; } aecwpajax.download({url:'http://en.wikipedia.org/w/api.php?action=query&list=usercontribs&'+ 'ucuser='+encodeURIComponent(trg)+'&ucprop=timestamp&format=xml&uclimit=100&ucstart='+ xmlreq.responseText.split('ucstart="')[1].split('"')[0],onSuccess:ais523dtcStep}); } function ais523dtcook(xmlreq,data) { if(!ais523dtc_sg) return; document.getElementById('a5dtco').innerHTML="(out of an overestimated "+ xmlreq.responseText.split("<count>")[1].split("</count>")[0]+")"; } function ais523dtc() { var trg; trg=ecGetParamValue('target'); if(trg==null) trg=location.href.substr(location.href.lastIndexOf("/")+1); var h="<table class='wikitable'><tr><th> </th>"; var i=0; while(i<24) h+="<th colspan=4>"+i++ +"</th>" h+="</tr><tr><th>Sun</th>"; i=0; while(i<96) h+="<td id='a5w0q"+i++ +"'> </td>"; h+="</tr><tr><th>Mon</th>"; i=0; while(i<96) h+="<td id='a5w1q"+i++ +"'> </td>"; h+="</tr><tr><th>Tue</th>"; i=0; while(i<96) h+="<td id='a5w2q"+i++ +"'> </td>"; h+="</tr><tr><th>Wed</th>"; i=0; while(i<96) h+="<td id='a5w3q"+i++ +"'> </td>"; h+="</tr><tr><th>Thu</th>"; i=0; while(i<96) h+="<td id='a5w4q"+i++ +"'> </td>"; h+="</tr><tr><th>Fri</th>"; i=0; while(i<96) h+="<td id='a5w5q"+i++ +"'> </td>"; h+="</tr><tr><th>Sat</th>"; i=0; while(i<96) h+="<td id='a5w6q"+i++ +"'> </td>"; h+="</tr></table><div>Processed <span id='a5dtcp'>0</span> edits so far <span id='a5dtco'></span>"; h+=". Key: <span style='background-color:#000000'>0 edits, </span>"; h+="<span style='background-color:#00FF00'><span id='a5dtck1'>0</span> edits, </span>"; h+="<span style='background-color:#FFFF00'><span id='a5dtck2'>0</span> edits, </span>"; h+="<span style='background-color:#FF0000'><span id='a5dtck3'>0</span> edits.</span></div>"; document.getElementById('contentSub').innerHTML=h; if(ais523dtc_counts==null) ais523dtc_counts=new Array(); ais523dtc_max=null; ais523dtc_prog=0; ais523dtc_sg=true; i=7*96; while(i--) ais523dtc_counts[i]=0; aecwpajax.download({url:'http://en.wikipedia.org/w/api.php?action=query&list=usercontribs&'+ 'ucuser='+encodeURIComponent(trg)+'&ucprop=timestamp&format=xml&uclimit=100', onSuccess:ais523dtcStep}); aecwpajax.download({url:'http://en.wikipedia.org/w/query.php?what=contribcounter&'+ 'titles=User:'+encodeURIComponent(trg)+'&format=xml', onSuccess:ais523dtcook}); } //</nowiki></pre> //[[Category:Wikipedia scripts]]