User:Amarkov/monobook.js

function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key) };

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 dodeletion { document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n{' + '{' + 'subst' + ':' + 'delsort' + '|' + 'Japan' + '}' + '}' + ' ' + '--' + ' ' + '~' + '~' + '~' + '~'; document.editform.wpSummary.value = 'Tagged as a Japan-related deletion.'; document.editform.wpMinoredit.checked = true; document.editform.submit; }

function adddeletion { addTab("javascript:dodeletion", "Japan deletion", "ca-Japandeletion", "Japan Deletion", ""); akeytt; }

$(function { if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1) {  addOnloadHook(adddeletion);  } });

function doheader { document.editform.wpTextbox1.value = '<!-' + '-Do not edit this--' + '>' + '{' + '{' + 'bots' + '|' 'deny' + '=' + 'SineBot' + '}' + '}' + '{' + '{' + 'User' + ':' + 'Amarkov' + '/' + 'talkheader' + '}' + '}' + '<!-' + '-Do not edit this--' + '>'; document.editform.wpSummary.value = 'header'; document.editform.wpMinoredit.checked = true; document.editform.submit; }

function addheader { addTab("javascript:doheader", "Add header", "ca-Addheader", "Add header", ""); akeytt; }

$(function { if (document.title.indexOf("Editing User talk:Amarkov") != -1) {  addOnloadHook(addheader);  } });

function doa7 { document.editform.wpTextbox1.value = '{' + '{' + 'db' + '-' + 'a7' + '}' + '}' + '\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'speedy deletion tag a7-does not assert importance'; document.editform.wpMinoredit.checked = false; document.editform.wpWatchthis.checked = true; document.editform.submit; }

function adda7 { addTab("javascript:doa7", "CSD A7", "ca-CSDA7", "CSD A7", ""); akeytt; }

$(function { if (document.title.indexOf("Editing ") != -1 && document.title.indexOf("Editing User talk") != 0) {  addOnloadHook(adda7);  } });

function dog1 { document.editform.wpTextbox1.value = '{' + '{' + 'db' + '-' + 'nonsense}' + '}' + '\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'speedy deletion tag g1-nonsense'; document.editform.wpMinoredit.checked = false; document.editform.wpWatchthis.checked = true; document.editform.submit; }

function addg1 { addTab("javascript:dog1", "CSD G1", "ca-CSDG1", "CSD G1", ""); akeytt; }

$(function { if (document.title.indexOf("Editing ") != -1 && document.title.indexOf("Editing User talk") != 0) {  addOnloadHook(addg1);  } });

function dog11 { document.editform.wpTextbox1.value = '{' + '{' + 'db' + '-' + 'g11' + '}' + '}' + '\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'speedy deletion tag g11-advertising'; document.editform.wpMinoredit.checked = false; document.editform.wpWatchthis.checked = true; document.editform.submit; }

function addg11 { addTab("javascript:dog11", "CSD G11", "ca-CSDG11", "CSD G11", ""); akeytt; }

$(function { if (document.title.indexOf("Editing ") != -1 && document.title.indexOf("Editing User talk") != 0) {  addOnloadHook(addg11);  } });

function dog10 { document.editform.wpTextbox1.value = '{' + '{' + 'db' + '-' + 'g10' + '}' + '}' + '\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'speedy deletion tag g10-attack page'; document.editform.wpMinoredit.checked = false; document.editform.wpWatchthis.checked = true; document.editform.submit; }

function addg10 { addTab("javascript:dog10", "CSD G10", "ca-CSDG10", "CSD G10", ""); akeytt; }

$(function { if (document.title.indexOf("Editing ") != -1 && document.title.indexOf("Editing User talk") != 0) {  addOnloadHook(addg10);  } });

function dovanity { document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n' + '{' + '{' + 'subst' + ':' + 'User' + ':' + 'Amarkov' + '/' + 'vanitywarning' + '}' + '}'; document.editform.wpSummary.value = 'do not create pages on yourself unless you are notable'; document.editform.submit; }

function addvanity { addTab("javascript:dovanity", "vanitywarn", "ca-vanitywarn", "Vanitywarn", ""); akeytt; }

$(function { if (document.title.indexOf("Editing User talk") == 0) {  addOnloadHook(addvanity);  } });

function dopov { document.editform.wpTextbox1.value = '{' + '{' + 'npov' + '}' + '}' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = '{' + '{' + 'npov' + '}' + '}'; document.editform.submit; }

function addpov { addTab("javascript:dopov", "pov", "ca-pov", "pov", ""); akeytt; }

$(function { if (document.title.indexOf("Editing ") != -1 && document.title.indexOf("Editing User talk") != 0) {  addOnloadHook(addpov);  } });

function doblank { document.editform.wpTextbox1.value = '{' + '{' + 'db' + '-' + 'blank' + '}' + '}' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'speedy deletion tag a3-no information'; document.editform.submit; }

function addblank { addTab("javascript:doblank", "blank", "ca-blank", "blank", ""); akeytt; }

$(function { if (document.title.indexOf("Editing ") != -1 && document.title.indexOf("Editing User talk") != 0) {  addOnloadHook(addblank);  } });

function tnaddlilink(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 testn(number) { var page = prompt("Vandalism to which article?") var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += "" + page + " ~" + "~" + "~" + "~"; f.wpSummary.value = "Edit to " + page + " - warning "; }

function add_testn_tabs { var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

// Only add for pages with "Editing User talk:" somewhere in the title if (document.title.indexOf("Editing User talk:") != -1) {     tabs.appendChild(tnaddlilink('javascript:testn(1)',"t1")); tabs.appendChild(tnaddlilink('javascript:testn(2)',"t2")); tabs.appendChild(tnaddlilink('javascript:testn(3)',"t3")); tabs.appendChild(tnaddlilink('javascript:testn(4)',"t4")); } }

$(add_testn_tabs);

function doboilerplate { document.editform.wpTextbox1.value = '{' + '{' + 'linkless' + '}' + '}' + '{' + '{' + 'references' + '}' + '}' + '{' + '{' + 'wikify' + '}' + '}' + '\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'Some cleanup tags'; }

function addboilerplate { addTab("javascript:doboilerplate", "boilerplate", "ca-boilerplate", "boilerplate", ""); akeytt; }

$(function { if (document.title.indexOf("Editing ") != -1 && document.title.indexOf("Editing User talk") != 0) {  addOnloadHook(addboilerplate);  } });

/* Category watch (User:ais523/catwatch.js); adds entries on the watchlist if a page is added to a category (and is still in the category when the watchlist is checked). The entry will only appear if there is another page on the watchlist edited that day (if the addition was the only change on that day, it's neglected). The recategorisation of a page in a watched category will also trigger the watching, even if it's a different category that's added or removed (unless the watched category is removed); removals from the watched category can't be detected. Categories with more than 100 elements won't be watched for server-load reasons. */

//

var cwwpajax; // From WP:US mainpage (wpajax renamed to cwwpajax) cwwpajax={ download:function(bundle) { // mandatory: bundle.url // optional: bundle.onSuccess (xmlhttprequest, bundle) // optional: bundle.onFailure (xmlhttprequest, bundle) // optional: bundle.otherStuff OK too, passed to onSuccess and onFailure var x = window.XMLHttpRequest ? new XMLHttpRequest : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false; if (x) { x.onreadystatechange=function { x.readyState==4 && cwwpajax.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)); } };

// Example: // function dlComplete(xmlreq, data) { //     alert(data.message + xmlreq.responseText); // } // cwwpajax.download({url:'http://en.wikipedia.org/w/index.php?title=Thresher&action=raw', //                   onSuccess: dlComplete, message: "Here's what we got:\n\n" });

// End of WP:US quote

function cwOntoWatchlist(xmlreq, data) { var a=xmlreq.responseText; var c=data.catname; var i; if(a.indexOf(" ")!=-1) return; //cat is empty, nothing to do here if(a.indexOf("latesttime) {       latesttime=temp; a[i]=a[i].substr(a[i].indexOf(" ")+7); latestpage=a[i].substr(0,a[i].indexOf(" ")); }   }  }  a=document.getElementsByTagName("h4"); //get dates in the watchlist var monthname=new Array; monthname['01']="January"; monthname['02']="February"; monthname['03']="March"; monthname['04']="April"; monthname['05']="May"; monthname['06']="June"; monthname['07']="July"; monthname['08']="August"; monthname['09']="September"; monthname['10']="October"; monthname['11']="November"; monthname['12']="December"; latesttime=new String(latesttime); temp=""+new Number(latesttime.substr(6,2))+" "+monthname[latesttime.substr(4,2)]+" "+latesttime.substr(0,4);

i=a.length; while(i--) {   if(a[i].innerHTML==temp) {     temp=a[i].nextSibling.firstChild; while(temp!=null) {       if(temp.tagName!=null) if(temp.tagName.toLowerCase=="li") {         temp2=temp.innerHTML.match(/; ([0-9][0-9]):([0-9][0-9]) \. \./); temp2=new Number(temp2[1])*100+new Number(temp2[2]); if(temp2Category:"+c+"; "+latesttime.substr(8,2)+":"+latesttime.substr(10,2)+" . . (+ "+                    ""+latestpage+" "+                     "(last))"; return; } } }

var WatchedCategories; //prevent error if there isn't a cat-watchlist yet

//An example of a query to check a category would be //http://en.wikipedia.org/w/query.php?what=category&cptitle=Wikipedia%20protected%20edit%20requests&cplimit=100&cpextended $(function{ if(wgPageName=="Special:Watchlist")  {    if(WatchedCategories==undefined)    {      if(confirm("You don't have a category watchlist yet. Do you want to create one?"))        location.href='http://en.wikipedia.org/w/index.php?title=User:'+wgUserName+                      '/WatchedCategories.js&action=edit&preload=User:Ais523/WatchedCategoriesTemplate.js';    }    else    {      var i;      for(i in WatchedCategories)      {        var a=WatchedCategories[i];        cwwpajax.download({url:'http://en.wikipedia.org/w/query.php?what=category&cptitle='+encodeURI(a)+ '&cplimit=100&cpextended&format=xml', onSuccess:cwOntoWatchlist, catname:a});     }    }  } });

// include current user's category watchlist document.write(' '); //

// Script from User:ais523/editcount.js document.write('');

// Script from User:Amarkov/linkedpagecontentadder.js

//Or it will be when that is done, at least

// This is a javascript tool which reports things to AIV, which should work for any browser

function aivreport { var username = wgTitle.split('/')[0]; var reason = prompt("Reason?"); if (!reason) { // Cancel clicked or no reason given; abort return; }

window.location.href = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?action=edit" + "&title=Wikipedia:Administrator intervention against vandalism" + "&username=" + escape(username) + "&reason=" + escape(reason) + "&fakeparam=broom"; }

if (wgCanonicalNamespace.match(/^User/)) { addOnloadHook(function {        addTab("javascript:aivreport", "AIV", "ca-AIV", "AIV", "");        akeytt;    }); }

function makereport { var params = location.search.substring(1).split("&"); var username = unescape(params[2].split("=", 2)[1]); var reason = unescape(params[3].split("=", 2)[1]);

var vandalTag; if (username.match(/^\d+\.\d+\.\d+\.\d+$/)) { vandalTag = 'IPvandal'; } else { vandalTag = 'vandal'; }

document.editform.wpTextbox1.value += '* {' + '{' + vandalTag + '|' + username + '}' + '}' + ' ' + reason + ' -- ~' + '~' + '~' + '~'; document.editform.wpSummary.value = 'Reporting a vandal'; document.editform.wpMinoredit.checked = false; document.editform.submit; }

if (location.search.indexOf("fakeparam") != -1) { addOnloadHook(makereport); }

function moocow { var specialchars = document.getElementById ('editpage-specialchars'); specialchars.innerHTML = "OR" + specialchars.innerHTML; }

if (document.title.indexOf("Editing") != -1) { addOnloadHook(moocow); }

//function contribThousand //{ // if(wgPageName == "Special:Contributions") { // window.location.href += "&limit=1000" //} //}

//addOnloadHook(contribThousand);