Jump to content

User:KnowledgeOfSelf/monobook.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript('User:Oxymoron83/blockadd.js');

/* <pre><nowiki> */

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// KnowledgeOfSelf's monobook
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Helper tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Voice of All
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Test-n
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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 += "{{subst:test" + number + "-n|" + page + "}} ~~~~";
  f.wpSummary.value = "Your edits to [[" + page + "]]" 
  document.editform.wpWatchthis.checked = false;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Automatically check "anon only" in block field
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

addOnloadHook(function(){ var x; if (x=document.getElementById('wpAnonOnly')) {x.checked=true;} });

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add link
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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];
        }
    }
    akeytt();
    return li;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add toolbox link
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addToolboxLink(url, name, id){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, url, name, id);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add tab
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add menu
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get page name
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function getPname() {
  z=document.getElementById("content").childNodes;
  for (var n=0;n<z.length;n++) { 
    if (z[n].className=="firstHeading") return z[n].textContent;
  };
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get tidy title
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function get_tidy_title()
{
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));

  return editlk;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add link
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addLink(where, url, name, id, title, key, after){
    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);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        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;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Voice of All tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Master rollback
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Specialadmin/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

addOnloadHook(Dfn_js_con)
function Dfn_js_con()
{
Mvaluejs_class = 'KOS';
Rvaluejs_class = 'KOS';
Uvaluejs_class = 'KOS';
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sleeper tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Sleeper/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// History analysis
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Find and replace
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/replacetxt.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AfD tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AfD nomination and voting tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

document.write('<script type="text/javascript"' +
  'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/automod.js' +
  '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

afdh_signature = '~~'+'~';
afdh_summaryprompt = true;
afdh_useicons = false;

afdh_shortcuts = Array();
afdh_shortcuts['d'] = 'Delete';
afdh_shortcuts['k'] = 'Keep';
afdh_shortcuts['m'] = 'Merge';
afdh_shortcuts['mv'] = 'Move';
afdh_shortcuts['rd'] = 'Redirect';
afdh_shortcuts['rw'] = 'Rewrite';
afdh_shortcuts['t'] = 'Transwiki';
afdh_shortcuts['wd'] = 'Weak delete';
afdh_shortcuts['sd'] = 'Strong delete';
afdh_shortcuts['sp'] = 'Speedy delete';
afdh_shortcuts['sk'] = 'Strong keep';
afdh_shortcuts['wk'] = 'Weak keep';
afdh_shortcuts['c'] = 'Comment';

afdh_icons = Array();
afdh_icons['d'] = afdh_icons['wd'] = afdh_icons['sd'] = afdh_icons['sp'] = 'Symbol delete vote.svg';
afdh_icons['k'] = afdh_icons['sk'] = afdh_icons['wk'] = 'Symbol keep vote.svg';
afdh_icons['m'] = 'Symbol merge vote.svg';
afdh_icons['c'] = 'Symbol comment vote.svg';

afdh_commscs = Array();
afdh_commscs['pn'] = 'per nom.';

function afd_helper() {
    if (auto_mod())
       return;

    var anchors = new Array();
    {
    var oldanchors = document.getElementById('bodyContent').getElementsByTagName('a');
    for (var i=0; i < oldanchors.length; i++)
        anchors[i] = oldanchors[i];
    }
    var url_re = /\?title=Wikipedia:Articles_for_deletion\/([^&]+)&action=edit&/;
    var url, matches;
    for (var i=0; i < anchors.length; i++) {
        if (!(matches = anchors[i].href.match(url_re))
         || (matches[1].substr(0, 4) == 'Log/'))
            continue;
        var na = document.createElement('a');
        na.href = "javascript:afd_vote('"+escape(anchors[i].href)+"')";
        na.title = "Vote on deletion of "+unescape(matches[1]);
        var inlink = document.createElement('sup');
        inlink.appendChild(document.createTextNode('vote'));
        na.appendChild(inlink);
        anchors[i].parentNode.insertBefore(na, anchors[i].nextSibling);
    }

    if (am_get_title().indexOf(':') == -1)
        am_add_li('tb', 'javascript:afd_nominate()', 'Nominate AFD', '', 'Nominate this article for deletion');
}

function afd_vote(edit_link) {
    var shortcuts_list = '';
    for (var key in afdh_shortcuts)
        shortcuts_list += key + ': ' + afdh_shortcuts[key] + '; ';
    var vote = window.prompt("Enter your vote.   (Shortcuts available are: "+shortcuts_list+")");
    if (!vote) return;
    var icon_link = '';
    if (afdh_useicons && afdh_icons[vote.toLowerCase()])
        icon_link = '[[Image:' + afdh_icons[vote.toLowerCase()] + '|20px]] ';
    if (afdh_shortcuts[vote.toLowerCase()])
        vote = afdh_shortcuts[vote.toLowerCase()];

    shortcuts_list = '';
    for (var key in afdh_commscs)
        shortcuts_list += key + ': ' + afdh_commscs[key] + '; ';
    var comment = window.prompt("Enter your comment.  (Shortcuts available are: "+shortcuts_list+")");
    if (typeof comment != 'string') return;
    if (afdh_commscs[comment.toLowerCase()])
        comment = afdh_commscs[comment.toLowerCase()];

    var summary = vote;
    if (afdh_summaryprompt)
      if (!(summary = window.prompt("Enter the edit summary:", summary)))
         summary = vote;
    var url = edit_link + 
        '&amaddafter='+escape("* '''"+icon_link+vote+"''' "+comment+" "+afdh_signature) +
        '&amsummary='+escape(summary);

    if (window.location.href.indexOf("/Log/") == -1)
      window.location.href = url;
    else
      window.open(url, "afd_helper_vote");
}

function afd_nominate() {
    var title = am_get_title();
    var log_date = window.prompt("This should be the date of the latest AFD log. Change it if necessary.", am_guess_date());
    if (!log_date)
        return;
    var reason = window.prompt("Please justify your AFD nomination of "+title+":");
    if (!reason)
        return;
    window.open(am_make_url(title, '{{'+'subst:afd}}', '', 'nomination for [[WP:AFD|deletion]]'), 'afdhn1');
    window.open(am_make_url('Wikipedia:Articles for deletion/Log/'+log_date, '', '{{'+'subst:afd3|pg='+title+'}}', 'Nominating [['+title+']] for deletion'), 'afdhn3');
    window.location.href = am_make_url('Wikipedia:Articles for deletion/'+title, '', '{{'+'subst:afd2|pg='+title+'|text='+reason+' '+afdh_signature+'}}', 'nominated for deletion');
}

addOnloadHook(afd_helper);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AfD closing tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function closeafd(bold, notbold){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = "{{subst:at}} '''" + bold + "''' " + notbold + " ~~~\n" + txt.value + "\n{{subst:ab}}\n";
    form.wpSummary.value = "close discussion: " + bold;
    form.wpWatchthis.checked = false;
}

function afdresult(){
    var form = document.editform;
    form.wpSummary.value = 'AFD result';
    var txt = form.wpTextbox1;
    txt.value = '{{subst:oldafd}} \n' + txt.value;
}

function afddelete(){
    document.forms.deleteconfirm.wpReason.value = '[[Wikipedia:Articles for deletion/' + unescape(window.location.href.replace(/^.*\?title=([^&]+)&action=delete.*$/, '$1').replace(/_/g, ' ')).replace(/^(Talk|Wikipedia( talk)?):/, '') + ']]';
}

function cfddelete(){
    document.forms.deleteconfirm.wpReason.value = 'category emptied per [[Wikipedia:Categories for discussion]]';
}

function replace(){
    var s = prompt("Search regexp?");
    if(s){
        var r = prompt("Replace regexp?");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "g"), r);
    }
}

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_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)
    {
      addLink('p-cactions', 'javascript:autoafd_relist()', "relist");
    }
}

addOnloadHook(autoafd_add_afd_tabs);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tab customisation tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add tab tools (technical)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function edit_summary_watch(msg, summ, watch)
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += msg;
  f.wpSummary.value = summ;
}

function edit_summary_watch2(summ, watch)
{
  var f = document.editform, t = f.wpTextbox1;
  f.wpSummary.value = summ;
}

function edit_summary_watch3(msg, summ, watch)
{
  var f = document.editform, t = f.wpTextbox1;
  t.value = msg;
  f.wpSummary.value = summ;
}

/* function testn(number)
{
  var page = prompt("Which message do you want to issue?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "User:FireFox/" + page + "}} ~" + "~" + "~";
  t.value += '\n';
  f.wpSummary.value = "vandalism warning";
} */

function blockuser(msg, other)
{
  var f = document.getElementsByName('wpBlockReason')[0];
  f.value = msg;
  var j = document.getElementsByName('wpBlockOther')[0];
  j.value = other;
}

function unblockuser(msg, other)
{
  var f = document.getElementsByName('wpUnblockReason')[0];
  f.value = msg;
}

function testv(number)
{
  var f = document.editform, t = f.wpTextbox1;
  t.value = "";
}

function protected(){
    var form = document.editform;
    form.wpSummary.value = '{{protected}}';
    var txt = form.wpTextbox1;
    txt.value = '{{protected}} \n' + txt.value;
}

function vprotected(){
    var form = document.editform;
    form.wpSummary.value = '{{vprotected}}';
    var txt = form.wpTextbox1;
    txt.value = '{{vprotected}} \n' + txt.value;
}

function sprotected(){
    var form = document.editform;
    form.wpSummary.value = '{{sprotected}}';
    var txt = form.wpTextbox1;
    txt.value = '{{sprotected}} \n' + txt.value;
}

function deletedpage(){
    var form = document.editform;
    form.wpSummary.value = '{{deletedpage}}';
    var txt = form.wpTextbox1;
    txt.value = '{{deletedpage}} \n' + txt.value;
}

function usertalkvprotect(){
    var form = document.editform;
    form.wpSummary.value = '{{usertalk-vprotect}}';
    var txt = form.wpTextbox1;
    txt.value = '{{usertalk-vprotect}} \n' + txt.value;
}

function usertalksprotect(){
    var form = document.editform;
    form.wpSummary.value = '{{usertalk-sprotect}}';
    var txt = form.wpTextbox1;
    txt.value = '{{usertalk-sprotect}} \n' + txt.value;
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add tab tools (the actual tabs)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
function edit_summary_watch(msg, summ, watch)
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += msg;
  f.wpSummary.value = summ;
}



function add_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)
    {
      addlimenu(tabs, 'Talk messages', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:Welcome}} -- ~~~~", "Welcome to Wikipedia!", true, 1)','Welcome', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:Anon}} -- ~~~~", "Welcome to Wikipedia!", true, 1)','Anon', '');
      addlilink(talkm, 'javascript:testn(1)', 'Test1', '');
      addlilink(talkm,'javascript:testn("1a")','Test1a', '');
      addlilink(talkm,'javascript:testn(2)','Test2', '');
      addlilink(talkm,'javascript:testn("2a")','Test2a', '');
      addlilink(talkm,'javascript:testn(3)','Test3', '');
      addlilink(talkm,'javascript:testn("3a")','Test3a', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:Test4}} -- ~~~~", "Last warning", false, 1)','Test4', '');
      addlilink(talkm,'javascript:testn("4a")','Test4a', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:anonblock}} -- ~~~~", "You have been blocked", false, 1)','anonblock', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:sockblock}} -- ~~~~", "You have been blocked", false, 1)','sockblock', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:SSPblock}}", "You have been blocked", false, 1)','ipsockblock', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:Test6}} -- ~~~~", "You have been blocked", false, 1)','Test6', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:Test7}} -- ~~~~", "You have been blocked", false, 1)','Test7', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:Test1article}} -- ~~~~", "warning", false, 1)','Test1-art', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:Test2article}} -- ~~~~", "second warning", false, 1)','Test2-art', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:Test3article}} -- ~~~~", "third warning", false, 1)','Test3-art', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:Test4article}} -- ~~~~", "last warning", false, 1)','Test4-art', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:usernameblock}} -- ~~~~", "You have been blocked", false, 1)','usernameblock', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:bv}} -- ~~~~", "Vandalism", false, 1)','BV', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:Vanity|}} -- ~~~~", "About the page you created", false, 1)','Vanity', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:rvfd|}} -- ~~~~", "{{rvfd}}", false, 1)','rvfd', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:blanking}} -- ~~~~", "Blanking pages", false, 1)','blanking', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:blanking2}} -- ~~~~", "Blanking pages", false, 1)','blanking 2', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:blanking3}} -- ~~~~", "Blanking pages", false, 1)','blanking 3', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:blanking4}} -- ~~~~", "Blanking pages", false, 1)','blanking 4', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:npa2}} -- ~~~~", "no personal attacks", false, 1)','npa 2', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:npa3}} -- ~~~~", "no personal attacks", false, 1)','npa 3', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:npa4}} -- ~~~~", "no personal attacks", false, 1)','npa 4', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:npa5}} -- ~~~~", "blocked for personal attacks", false, 1)','npa 5', '');
      addlilink(talkm,'javascript:edit_summary_watch("{{nothanks-sd|pg=page name|url=url of source}} -- ~~~~", "{{nothanks-sd}}", false, 1)','nothanks-sd', '');


    }

  if (document.title.indexOf("Editing User:") != -1)
    {
      addlimenu(tabs, 'userpage tags', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:ibu}}", "blocked", false, 1)',"indefinite");
      addlilink(talkm,'javascript:edit_summary_watch("{{indefblocked-username}}", "username block", false, 1)',"username");
      addlilink(talkm,'javascript:edit_summary_watch("{{indefblocked-vandalism}}", "blocked", false, 1)',"vandalism");
      addlilink(talkm,'javascript:edit_summary_watch("{{indef-latin}}", "username block", false, 1)',"non-latin");
      addlilink(talkm,'javascript:edit_summary_watch("{{pageblankvandal}}", "pageblankvandal", false, 1)',"page blank");
      addlilink(talkm,'javascript:edit_summary_watch("{{pagemovevandal}}", "pagemovevandal", false, 1)',"page move");
    }

  if (document.title.indexOf("Editing Image:") == 0)
    {
      addlilink(tabs, 'javascript:edit_summary_watch("{{subst:nld}}", "no licence", false, 1)',"licence");
    }

  if (document.title.indexOf("Editing User:") == 0)
    {
      addlilink(tabs, 'javascript:testv(1)',"");
    }

  if (document.title.indexOf("Editing User talk:") == 0)
    {
      addlilink(tabs, 'javascript:testv(1)',"");
    }

  if (document.title.indexOf("Editing Wikipedia:Articles for deletion") == 0)
    {
        addlilink(tabs, 'javascript:closeafd(prompt("Result"), (prompt("Additional comments")))', 'Result');
    }
         
  if (document.title.indexOf("Editing User:KnowledgeOfSelf/status") == 0)
    {
      addlimenu(tabs, 'c/s', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch3("{{User:KnowledgeOfSelf/Status2|in}}", "changing status (in)", true, 1)',"i");
      addlilink(talkm,'javascript:edit_summary_watch3("{{User:KnowledgeOfSelf/Status2|out}}", "changing status (out)", true, 1)',"o");
      addlilink(talkm,'javascript:edit_summary_watch3("{{User:KnowledgeOfSelf/Status2|around}}", "changing status (around)", true, 1)',"a");
      addlilink(talkm,'javascript:edit_summary_watch3("{{User:KnowledgeOfSelf/Status2|busy}}", "changing status (busy)", true, 1)',"b");
    }

  if (document.title.indexOf("Editing Wikipedia:Administrator intervention against vandalism") == 0)
    {
      addlimenu(tabs, 'admin intervention against vandalism', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch2("blocked, list empty", true, 1)',"blocked, empty");
      addlilink(talkm,'javascript:edit_summary_watch2("blocked, list not empty", true, 1)',"blocked, not empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, content dispute, list empty", true, 1)',"content dispute, empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, content dispute, list not empty", true, 1)',"content dispute, not empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, has not vandalised since final warning", list empty", true, 1)',"no edit since warning, empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, has not vandalised since final warning", true, 1)',"no edit since warning, not empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, has not been sufficiently warned", list empty", true, 1)',"not sufficiently warned, empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, has not been sufficiently warned", true, 1)',"not sufficiently warned, not empty");
    }

  if (document.title.indexOf("Editing Category") == 0)
    {
      addlimenu(tabs, 'cat', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch2("renaming of category per [[Wikipedia:Categories for discussion]]", true, 1)',"!");
    }

  if (document.title.indexOf("Editing") == 0)
    {
      addlimenu(tabs, 'protected', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:protected()',"dispute");
      addlilink(talkm,'javascript:vprotected()',"vprotect");
      addlilink(talkm,'javascript:sprotected()',"sprotect");
      addlilink(talkm,'javascript:deletedpage()',"deleted");
    }

  if (document.title.indexOf("Block user") == 0)
    {
	addlilink(tabs, 'javascript:blockuser("vandalism from this IP range, sorry. please see [[Wikipedia:Advice to AOL users]] if you have been impacted by this block.", "90 minutes")', "range");
	addlilink(tabs, 'javascript:blockuser("three revert rule violation", "24 hours")', "3RR");
	addlilink(tabs, 'javascript:blockuser("vandalism", "15 minutes")', "15 mins");
	addlilink(tabs, 'javascript:blockuser("vandalism", "3 hours")', "3 hrs");
	addlilink(tabs, 'javascript:blockuser("vandalism", "24 hours")', "24 hrs");
	addlilink(tabs, 'javascript:blockuser("vandalism", "48 hours")', "48 hrs");
	addlilink(tabs, 'javascript:blockuser("vandalism", "96 hours")', "96 hrs");
	addlilink(tabs, 'javascript:blockuser("vandalism", "192 hours")', "192 hrs");
	addlilink(tabs, 'javascript:blockuser("vandalism", "indefinite")', "indefinite");
	addlilink(tabs, 'javascript:blockuser("inappropriate username", "indefinite")', "username");
    }

  if (document.title.indexOf("Unblock user") == 0)
    {
	addlilink(tabs, 'javascript:unblockuser("temporarily removing block to change duration")', "change duration");
	addlilink(tabs, 'javascript:unblockuser("unblock requested (via email)")', "email");
	addlilink(tabs, 'javascript:unblockuser("blocked mistakenly")', "mistake");
	addlilink(tabs, 'javascript:unblockuser("collateral damage")', "collateral");
	addlilink(tabs, 'javascript:unblockuser("release autoblock")', "autoblock");
    }

  if (document.title.indexOf("Confirm delete") == 0)
    {
      addlilink(tabs, 'javascript:afddelete()',"afd");
      addlilink(tabs, 'javascript:cfddelete()',"cfd");
    }

  if (document.title.indexOf("Editing Talk:") == 0)
    {
      addlilink(tabs, 'javascript:afdresult()',"afd");
    }

}

if (window.addEventListener)
  window.addEventListener("load", add_tabs, false);
else if (window.attachEvent)
  window.attachEvent("onload", add_tabs);
  
function addtab(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.id = id;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Edit section zero
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addEditSection0() {
  ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
  if (!document.getElementById) return;
  x = document.getElementById('ca-edit');
  if(!x) return;
  y = document.createElement('LI');
  y.id = 'ca-edit-0';
  if (x.className == 'selected') {
    if (/&action=edit&section=0$/.test(window.location.href)) {
      x.className = 'istalk';
      y.className = 'selected';
    } else {
      x.className = 'selected istalk';
    }
  } else if (x.className == 'selected istalk') {
    if (/&action=edit&section=0$/.test(window.location.href)) {
      x.className = 'istalk';
      y.className = 'selected istalk';
    } else {
      y.className = 'istalk';
    }
  } else {
    y.className = x.className;
    x.className = 'istalk';
  }
  z = document.createElement('A');
  if (x.children) {
    z.href = x.children[0].href + '&section=0';
    z.appendChild(document.createTextNode('0'));
    y.appendChild(z);
    document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
  } else {
    z.href = x.childNodes[0].href + '&section=0';
    z.appendChild(document.createTextNode('0'));
    y.appendChild(z);
    document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
  }
}

if (document.title.indexOf("Editing ") == -1) {
  if (window.addEventListener) window.addEventListener("load", addEditSection0, false);
  else if (window.attachEvent) window.attachEvent("onload", addEditSection0);
}

function getPname() {
  z=document.getElementById("content").childNodes;
  for (var n=0;n<z.length;n++) { 
    if (z[n].className=="firstHeading") return z[n].textContent;
  };
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Block, unblock, and block log tabs
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));
  editlk = editlk.substring(editlk.indexOf(':') + 1);
  var slloc = editlk.indexOf('/');
  if (slloc > 0)
    editlk = editlk.substring(0, slloc);

  addlilink(tabs, '/w/index.php?title=Special:Ipblocklist&action=unblock&ip=' + editlk, 'u');
  addlilink(tabs, '/w/index.php?title=Special:Blockip&ip=' + editlk, 'b');
  addlilink(tabs, '/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + editlk, 'l');

}

function do_onload()
{
  if (document.title.indexOf('User:') == 0
      || document.title.indexOf('User talk:') == 0)
    add_block_tab();
  else if (document.title.indexOf('Block user') == 0) // could stand to be more robust
    do_blockip_stuff();
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Visual aids and changes to personal menus
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Personal menu, navigation, toolbox and more tab customisation
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

if (window.addEventListener) 
  window.addEventListener("load", do_onload, false);
else if (window.attachEvent) 
  window.attachEvent("onload", do_onload);

if ( document.createElement && window.addEventListener )
{
 function SoFixItInit()
 {

 }

 function SoFixItLoad()
 {
 UserMenu = new PortletMenu( 'p-personal'   );
 PageMenu = new PortletMenu( 'p-cactions'   );
  NavMenu = new PortletMenu( 'p-navigation' );
  ToolMenu = new PortletMenu( 'p-tb'         );

 function GetByClass( sElem, sClass )
 { var i, a2 = [], a = document.getElementsByTagName( sElem );
 for ( i = 0; i < a.length; i++ )
 if ( a[ i ].className == sClass )
 a2.push( a[ i ] );
 return a2;
 }
 var a, td = GetByClass( 'td', 'diff-otitle' );
 if ( ( td = td[ 0 ] ) && ( a = td.getElementsByTagName( 'a' )[ 0 ] ) )
 a.href = a.href + '&action=edit'; // need to change text, later

 var userName = UserMenu.getText( 'pt-userpage' );

 UserMenu.setText( 'pt-mytalk'     , 'Talk'  );
 UserMenu.setText( 'pt-preferences', 'Preferences' );
 UserMenu.setText( 'pt-watchlist'  , 'Watchlist' );
 UserMenu.setText( 'pt-mycontris'  , 'Contributions' );
 UserMenu.setText( 'pt-logout'     , 'Log out'   );

 document.getElementById( 'p-personal' ).getElementsByTagName( 'ul' )[0].style.textTransform = 'none';

 if ( PageMenu[ 'ca-history' ] ) // theory: if it has a history tab, then it's purgable
 {
 PageMenu.insertBefore( 'ca-history', 'ca-lastdiff', 'last',
 PageMenu.getHref( 'ca-history' ).replace( /action=history/, 'diff=0' ) );

 PageMenu.getHref( 'ca-history' ).replace( /action=history/, 'action=purge');

                        PageMenu.setText( 'ca-edit'     , 'Edit this page'   );

                        PageMenu.setText( 'ca-history'     , 'History'   );

                        PageMenu.setText( 'ca-delete'     , 'Delete'   );
 }

 var x = 1;
 NavMenu.append( 'n-' + x++, 'monobook.js', 'http://en.wikipedia.org/w/index.php?title=User:KnowledgeOfSelf/monobook.js&action=edit' );
 NavMenu.append( 'n-' + x++, 'monobook.css', 'http://en.wikipedia.org/w/index.php?title=User:KnowledgeOfSelf/monobook.css&action=edit' );
 NavMenu.append( 'n-' + x++, 'Status', 'http://en.wikipedia.org/w/index.php?title=User:KnowledgeOfSelf/status&action=edit' );
 NavMenu.append( 'n- ' + x++, 'Purge', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=purge' );
 ToolMenu.append( 'n-' + x++, 'Block IP', 'http://en.wikipedia.org/wiki/Special:Blockip' );
 ToolMenu.append( 'n-' + x++, 'Unblock IP', 'http://en.wikipedia.org/w/index.php?title=Special:Ipblocklist&action=unblock' );
 ToolMenu.append( 'n-' + x++, 'IP block list', 'http://en.wikipedia.org/wiki/Special:Ipblocklist' );
 ToolMenu.append( 'n-' + x++, 'Autoblocks', 'http://tools.wikimedia.de/~pgk/autoblock.php?autoblock=&blocker=KnowledgeOfSelf&blockee=&time=0&Submit=Submit+Query' );
 ToolMenu.append( 'n-' + x++, 'Requests: AIV', 'http://en.wikipedia.org/wiki/Wikipedia:Administrator_intervention_against_vandalism' );
 ToolMenu.append( 'n-' + x++, 'Requests: Unblock', 'http://en.wikipedia.org/wiki/Category:Requests_for_unblock' );
 ToolMenu.append( 'n-' + x++, 'Requests: Helpme', 'http://en.wikipedia.org/wiki/Category:Wikipedians_looking_for_help' );
 ToolMenu.append( 'n-' + x++, 'Requests: Adminship', 'http://en.wikipedia.org/wiki/Wikipedia:Requests_for_adminship' );
 ToolMenu.append( 'n-' + x++, 'Speedy deletions', 'http://en.wikipedia.org/wiki/Category:Candidates_for_speedy_deletion' );
 ToolMenu.append( 'n-' + x++, 'AfDs to be closed', 'http://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/Old' );
 ToolMenu.append( 'n-' + x++, 'Todays AfDs', 'http://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/Log/Today' );
 ToolMenu.append( 'n-' + x++, 'Yesterdays AfDs', 'http://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/Log/Yesterday' );
 ToolMenu.append( 'n-' + x++, 'Noticeboard', 'http://en.wikipedia.org/wiki/Wikipedia:Administrators%27_noticeboard' );
 ToolMenu.append( 'n-' + x++, 'Noticeboard: Incidents', 'http://en.wikipedia.org/wiki/Wikipedia:Administrators%27_noticeboard/Incidents' );
 ToolMenu.append( 'n-' + x++, 'Noticeboard: 3RR', 'http://en.wikipedia.org/wiki/Wikipedia:Administrators%27_noticeboard/3RR' );
 ToolMenu.append( 'n-' + x++, 'Edit count', 'http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=KnowledgeOfSelf&site=en.wikipedia.org' );
 ToolMenu.append( 'n-' + x++, 'New users', 'http://en.wikipedia.org/w/index.php?title=Special:Log&type=newusers&user=&page=&limit=20&offset=0' );
 }

 function PortletMenu( id ) // constructor
 {
 this.menu = document.getElementById( id );
 this.list = this.menu.getElementsByTagName( 'ul' )[ 0 ]; // bypass "<h5>Views</h5>", etc.

 var LIs = this.list.getElementsByTagName( 'li' );

 for ( var i = 0; i < LIs.length; i++ )
 {
 this[ LIs[ i ].id ] = LIs[ i ];
 }

 this.newItem = function( id, txt, url )
 { var li = document.createElement( 'li' ); li.id   = id;
 var  a = document.createElement( 'a'  );  a.href = url;

  a.appendChild( document.createTextNode( txt ) );
 li.appendChild( a );

 this[ id ] = li; // watch this!!!

 return li;
 }

 this.append = function( id, txt, url )
 { this.list.appendChild( this.newItem( id, txt, url ) );
 }
 
 this.insertBefore = function( old, id, txt, url )
 { this.list.insertBefore( this.newItem( id, txt, url ), this[ old ] );
 }

 this.getText = function( id      ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data }
 this.setText = function( id, txt ) {        this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data = txt }

 this.getHref = function( id      ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].href       }
 this.setHref = function( id, url ) {        this[ id ].getElementsByTagName( 'a' )[ 0 ].href = url }
 
 }

 function RemoveNode( id )
 { var node = document.getElementById( id )
 node.parentNode.removeChild( node );
 }

 SoFixItInit();
 window.addEventListener( 'load', SoFixItLoad, false );
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Page logs link in toolbox
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

addOnloadHook(function () {

 var pagetitleRe=/[^:]*:\/\/en\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?#]*)/;
 ptitle = pagetitleRe.exec(decodeURI(location.href))[2].split('_').join(' ');
 
 if( (window.location.href.indexOf("User:") != -1) || (window.location.href.indexOf("User_talk:") != -1) ) {
  regDropSubpages = /[User|User_talk]:([^&?\/]*)[\/]?.*/;
  user = regDropSubpages.exec(ptitle)[1];
  url = "http://en.wikipedia.org/w/index.php?title=Special%3ALog&user=" + user;
 } else if(window.location.href.indexOf("Special:") != -1) {
  return;
 } else {
  url = "http://en.wikipedia.org/w/index.php?title=Special%3ALog&page=" + ptitle;
 }
 
 tabs = document.getElementById('p-tb').getElementsByTagName('ul')[0];
 l = addlilink(tabs, url, "Logs", "pt-logs");

});

document.write('<style type="text/css">' +
    ' .xdiff { width: 100%; background: white; }' +
    ' .xdiff-row { width: 100%; margin: 0 0 3px 0; overflow: hidden; }' +
    ' .xdiff-col { width: 49%; margin: 0; float: left; clear: none; position: relative; }' +
    ' .xdiff-sign, .xdiff-outer, .xdiff-inner { display: block; margin: 0; }' +
    ' .xdiff-sign { position: absolute; top: 0; left: 0; width: 2em; text-align: center; }' +
    ' .xdiff-outer { padding: 0 0 0 2em; }' +
    ' .xdiff-inner { overflow: auto; overflow-y: visible; width: 100%; }' +
    ' .xdiff-inner.diff-addedline { font-size: 85%; background: #cfc; }' +
    ' .xdiff-inner.diff-deletedline { font-size: 85%; background: #ffa; }' +
    ' .xdiff-inner.diff-context { font-size: 85%; background: #eee; }' +
    (!document.recalc ? '' :  // IE kluge:
        ' * html .xdiff-inner { padding-bottom: expression(this.scrollWidth > this.offsetWidth ? "16px" : 0); }' +
        ' * html .xdiff-sign { top: expression((this.parentNode.clientHeight - this.offsetHeight)/2 + "px"); }') +
    '<'+'/style>');

//addOnloadHook(maybeStart);
addOnloadHook(addMarvin);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Other / Uncategorised
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Interiot edit count (tool 2)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
  mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// End
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/* </nowiki></pre> */