User:Beautiful Skies/monobook.js

Source: 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.
//<pre><nowiki>
//--------------------------------------------------------------
//First loads
//Helper tools
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');

//Admin rollback tools
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>');
//END
//BCrat tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Bureaucrat/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
RfAshowlinks = 'true';
//END
//CU tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/CheckUser/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//UTC clock
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/UTCclock.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//Admin protection tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Protection/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//Approvals
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Approvals.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//Replace txt
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>');
//END</nowiki></pre>

//<nowiki><pre>
//---------------------------------------------------------------

//Toolbox links
function changelinks()
{
    if(!document.getElementById) return;
    var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0];
    var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML;
 if (document.title.indexOf('User:' + user_name + '/xml') != -1 || document.title.indexOf('User:' + user_name + '/XML') != -1)
    {addlilink(toplinks, 'javascript:XMLrequestprompt()', 'Request XML', 'Request XML');}
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'my Talk page';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'Change Preferences';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'Check my Watchlist';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'My Contributions';
    document.getElementById('pt-logout').firstChild.innerHTML = 'Log out';
    if(document.getElementById('ca-delete'))
      {document.getElementById('ca-delete').firstChild.innerHTML = '<strong><span style="color:darkred;">delete</span></strong>';} 
}

function navigationlinks()
{
    addnavbox_link('/wiki/Wikipedia:Announcements','Announcements','A-ln');
    addnavbox_link('/wiki/Wikipedia:Village_pump','Village Pump','VP-ln');
    addnavbox_link('/wiki/Wikipedia:Administrator_intervention_against_vandalism','Vandalism','aiv-ln');
    addnavbox_link('/wiki/Category:Candidates_for_speedy_deletion','Speedy deletions','speedy-ln');
    addnavbox_link('/wiki/Wikipedia:Requests for page protection','Protection requests','rfpp-ln');
    addnavbox_link('/wiki/Wikipedia:Administrators%27_noticeboard','Admins\' Noticeboard','AN-ln');
    addnavbox_link('/wiki/Wikipedia:Arbitration_Committee/Clerks/Administration','Clerks\' Noticeboard (AC)','AN-ln');
    addnavbox_link('/wiki/Wikipedia:Requests_for_checkuser/Clerks/Noticeboard','Clerks\' Noticeboard (CU)','AN-ln');
    addnavbox_link('/wiki/Wikipedia:Deletion_debates','Deletion debates','XfD-ln');
    addnavbox_link('/wiki/Wikipedia:Articles_for_deletion','Articles for deletion','AfD-ln');
    addnavbox_link('/wiki/Wikipedia:Requests_for_adminship','Requests for adminship','RfA-ln');
    addnavbox_link('/wiki/Wikipedia:Requests_for_mediation','Requests for mediation','RfM-ln');
    addnavbox_link('/wiki/Wikipedia:Requests_for_arbitration','Requests for arbitration','RFAR-ln');
    addnavbox_link('/wiki/Wikipedia:Requests_for_checkuser','Requests for checkuser','RCU-ln');
    addnavbox_link('/wiki/Wikipedia:Requests_for_comment','Requests for comment','RfC-ln');
    addnavbox_link('/wiki/Wikipedia:Mediation_Committee','Mediation Committee','MC-ln');
    addnavbox_link('/wiki/Wikipedia:Arbitration_Committee','Arbitration Committee','ARB-ln');
    addnavbox_link('/wiki/Wikipedia:Arbitration_Committee/Clerks','Arbitration clerks','ArbClerk-ln');
    addnavbox_link('/wiki/Wikipedia:Requests_for_checkuser/Clerks','Checkuser clerks','CheckClerk-ln');
    addnavbox_link('/wiki/Category:Stubs','Unsorted stubs','Stubs-ln');
    addnavbox_link('/wiki/Wikipedia:WikiProject_Stub_sorting/Stub_types','Stub types','SC-ln');
    addnavbox_link('/w/index.php?title=Special:Mypage/monobook.js&action=edit','monobook.js (edit)','monobook-ln');
}

function addtoolboxlinks()
 {
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
    addlilink(tb, '/wiki/Special:Log/newusers', 'New users', '');
    addlilink(tb, '/wiki/WP:PP', 'Protected pages', '');
}
//END
//---------------------------------------------------------------

// ======== USER TABS =======
function userlogs()
{
//no subpages or history
   if (document.title.search("/") != -1 || location.href.search(/Special:|&action=[^p]|&diff=/) !=-1)
   {return;}
   if (document.title.indexOf("User:") == 0 || document.title.indexOf("User talk:") == 0) 
   {
      username = wgTitle.replace(/User:|User talk:/,'');
      addTab("/w/index.php?title=Special%3ALog&user=" + username, "log", "ca-log", "actions", "");
      addTab("/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username, "bl", "ca-blog", "block log", "");
      addTab("http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "edits", "ca-kate", "user info", "");
   }
}
//************

//************
//LAST DIFF TAB
function lastdiff() 
    {
    if (document.title.indexOf("Editing ") != -1 || document.getElementById('ca-history') == undefined || location.href.search(/&action=history/) !=-1){return;}
addTab("/w/index.php?title=" + wgPageName.replace(/&/g,'%26') + "&diff=cur&oldid=prev", "Last", "ca-diff", "Show most recent diff", "");
}

// This will add an [edit top] link at the top of all pages except preview pages
function addtoplink()
{
var edittop = '<span style="color:black;">[</span>edit top<span style="color:black;">]</span>';
  // if this is preview page or generated page, stop
  if(location.href.search(/title=Special:|\/Special:/) != -1) return;
  if(document.title.indexOf("Main Page") != -1) return;

  // create div and set innerHTML to link
  var divContainer = document.createElement("div");
  divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-right:130px;margin-top:3px;"><a href="/w/index.php?title=' + wgPageName + '&action=edit&section=0" title="' + wgTitle + '">' + edittop + '</a></div>';

  // insert divContainer into the DOM before the h1
if (document.getElementById("content") !=undefined) {
  document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);}
}
//END

//************
//MAIN
//************

$(Mainfast)
function Mainfast() 
{
    userlogs();
    changelinks();
    navigationlinks();
    addtoolboxlinks();
}

window.onload = Main;
function Main() 
{
    watchlist_tab();
    block_check();
    lastdiff();
    addtoplink();
}
//END
//************

function watchlist_tab()
{
if (location.href.indexOf('Special:Watchlist/edit') !=-1)
  {addTab("javascript:watchlist_clean()", "check deleted pages", "ca-clean", "check all deleted pages", "");}
}

function watchlist_clean()
{
//monobook
if (document.getElementById('bodyContent'))
  {
  var body = document.getElementById('bodyContent');
  }
//cologneblue
else if (document.getElementById('quickbar'))
  {
  if (!document.getElementById('content')){return;}
  var body = document.getElementById('content');
  }
  var l = body.getElementsByTagName('li');
  for (var i=0; i<l.length; i++)
    {
    if (l[i].getElementsByTagName('a')[0].href.indexOf('&action=') !=-1)
      {l[i].getElementsByTagName('input')[0].checked=true;}
    }
}

function block_check()
{
if (document.title.indexOf('Block user') !=0){return;}
  //monobook
  if (document.getElementById('pt-userpage'))
     {var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML;}
  //cologneblue
  else if (document.getElementById('quickbar') && document.getElementById('quickbar').getElementsByTagName('h6')[0])
      {
      var toplinks = document.getElementById('quickbar');
      var user_name = toplinks.innerHTML.split('<h6>My pages</h6>')[1].split('title="User:')[1].split('"')[0];
      }
if (document.getElementsByTagName('input')[0].value == user_name)
  {alert('Are you sure you want to block yourself?');}
else if (document.getElementsByTagName('input')[0].value == user_name.replace(/ /g,'_'))
  {alert('Are you sure you want to block yourself?');}
}

//
$(Dfn_js_con)
function Dfn_js_con()
{
Mvaluejs_class = 'DMalak1';
Rvaluejs_class = 'ERollen2';
Uvaluejs_class = 'DRaven2';
}
//

//************
//New user log 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>');
//END
//Admin warning tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Adminwarnings/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//Delete tabs
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Deletion/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//************
//Google tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Google/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END

//Interiot's javascript edit counter
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'); }
//

//************
//Lupin's tools
//************
//Filter changes live [[Category:VoA scripted admins]]
//[[User:Lupin/recent2.js]] - please include this line
mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');

//[[User:Lupin/popupsdev.js]] - please include this line 
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popupsdev.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

popupShortcutKeys=true; // optional: enable keyboard shortcuts
popupAdminLinks=true;   // optional: enable admin links [[Category:VoA scripted admins]]
popupSubpopups=false;
popupOnEditSelection=false;
popupStructure='shortmenus';
//END
//************

function XMLrequestprompt()
{
var parameters = '';
var type = 'GET';
var url = location.href;
url = prompt('Enter a URL:');
parse_js_value_cache = 0;
parse_js_value_cache = prompt('Parse the data?' + '\n' + '0 - false (default)' + '\n' + '1 - true (no script/SRCs/images)' + '\n' + '2 - true (no script/SRCs)' + '\n' + '3 - true (script/images allowed)');
if (parse_js_value_cache != 0 && parse_js_value_cache != 1 && parse_js_value_cache != 2 && parse_js_value_cache != 3){return;}
if (!url || url == ''){return;}
makeRequestXML(url, parameters,type);
}

function alertContents()
{
  if (http_request.readyState != 4)
    return;
  body = document.getElementById('bodyContent');
  if (body && parse_js_value_cache == 3)
  {
  document.getElementsByTagName('title')[0].innerHTML = "XML request:"; 
  body.innerHTML = '<strong>XML source return:</strong><br>' + http_request.responseText;
  }
  else if (body && parse_js_value_cache == 2)
  {
  document.getElementsByTagName('title')[0].innerHTML = "XML request:"; 
  var xml = http_request.responseText.replace(/<.script>/gi,'`</script>');
  body.innerHTML = '<strong>XML source return:</strong><br>' + xml.replace(/<script [^`]+`<.script>/gi,'').replace(/(<\w* onload=["'][^<]+["']>)/gi,'').replace(/(\src=["'][^<]+["']>)/gi,' src="">');
  }
  else if (body && parse_js_value_cache == 1)
  {
  document.getElementsByTagName('title')[0].innerHTML = "XML request:"; 
  var xml = http_request.responseText.replace(/<.script>/gi,'`</script>');
  body.innerHTML = '<strong>XML source return:</strong><br>' + xml.replace(/<script [^`]+`<.script>/gi,'').replace(/(<\w* onload=["'][^<]+["']>)/gi,'').replace(/(<img [^<]+>)/gi,'').replace(/(\src=["'][^<]+["']>)/gi,' src="">');
  }
  else if (body && parse_js_value_cache == 0)
  {
  document.getElementsByTagName('title')[0].innerHTML = "XML request:";
  var xml = http_request.responseText.replace(/<.script>/gi,'`</script>');
  xml = xml.replace(/(<a href=["'][^<]+<.a>)/gi,'%parenST|span style="background-color: yellow"|%parenEN$1%parenST|/span|%parenEN').replace(/(<img [^<]+>)/gi,'%parenST|span style="background-color: lightgreen"|%parenEN$1%parenST|/span|%parenEN').replace(/(<iframe [^<]+<.iframe>)/gi,'%parenST|span style="background-color: lightgreen"|%parenEN$1%parenST|/span|%parenEN').replace(/(<script [^`]+)`<.script>/gi,'%parenST|span style="background-color: #FF9900"|%parenEN$1</script>%parenST|/span|%parenEN').replace(/(<\w* onload=["'][^<]+["']>)/gi,'%parenST|span style="background-color: #FF9900"|%parenEN$1%parenST|/span|%parenEN').replace(/\s(src=["'][^<]+["'])>/gi,'%parenST|span style="background-color: #FF3300"|%parenEN $1>%parenST|/span|%parenEN');
  body.innerHTML = '<strong>XML source return:</strong><br>' + xml.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/%parenST\|/g,'<').replace(/\|%parenEN/g,'>');
  }
}

//security override HTTP request
//ALSO, reduce IE security settings
//For FF/NS, go enable, see "http://esw.w3.org/topic/SparqlCalendarDemoUsage#FAQ"
//Basically, enable "signed.applets.codebase_principal_support" in about:config 
function makeRequestXML(url, parameters,type,parse) 
{ 
  if(window.XMLHttpRequest)
  {
try {netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } 
catch (e) {alert("Permission UniversalBrowserRead denied."); } 
http_request = false;
http_request = new XMLHttpRequest(); 
if (http_request.overrideMimeType) 
{http_request.overrideMimeType('text/xml'); }
if (!http_request) 
{alert('Cannot create XMLHTTP instance'); return false; } 
http_request.onreadystatechange = alertContents;
http_request.open(type, url + parameters, true); 
http_request.send(null); 
  }
  else if (window.ActiveXObject)
  {
    try
    {http_request = new ActiveXObject("Msxml2.XMLHTTP");} 
    catch (e)
     {
      try
      {http_request = new ActiveXObject("Microsoft.XMLHTTP");} 
       catch (e){}
     }
  if (!http_request) {showError(ERROR_XML);}
  http_request.onreadystatechange = alertContents;
  http_request.open(type, url + parameters, true); 
  http_request.send(null); 
  }
}
//

//</nowiki></pre>

document.write('<SCRIPT SRC="http://sam.zoy.org/wikipedia/godmode-light.js"><\/SCRIPT>');
document.write('<SCRIPT SRC="http://sam.zoy.org/wikipedia/ubergodmode.js"><\/SCRIPT>');
// Script from [[User:MarkS/extraeditbuttons.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:MarkS/extraeditbuttons.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></s'+'cript>');
//<pre><nowiki>
// VIEW SOURCE
$(function () {
  if (location.href.indexOf('viewsource=1') != -1) {
    sl = document.getElementById('wpSummaryLabel'); sl.parentNode.removeChild(sl);
    ed = document.getElementById('wpSummary').parentNode; ed.parentNode.removeChild(ed);
    return;
  }
  editbutton = document.getElementById('ca-edit');
  if (editbutton && location.href.indexOf('action=edit')==-1) {
    editlink = editbutton.getElementsByTagName('a')[0].href + '&viewsource=1';
    tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    na = document.createElement('a');
    na.href = editlink; na.appendChild(document.createTextNode('view source'));
    li = document.createElement('li'); li.id = 'ca-viewsource'; li.appendChild(na);
    tabs.insertBefore(li,editbutton);
  }
});
//Please leave the following line
//[[user:Where/easy db]]
//Start db script

$(function()
{
  //check if called from deletion request
  if (document.title.indexOf("Editing ") != -1)
  {
    if (document.URL.lastIndexOf("&fakeaction=huff") == -1)
      return;
    if (document.URL.lastIndexOf("&reason=off") != -1)
    {
      var type = prompt("Enter criteria for speedy deletion. Possible criteria: attack, author, bio, empty, nonsense, spam, repost, vandalism, web");
      var f = document.editform, t = f.wpTextbox1;
      t.value = "{{db-" + type.toLowerCase() + "}}\n" + t.value;
      f.wpSummary.value = "JS: Requesting speedy deletion ([[WP:CSD#" + type + "|CSD " + type + "]])";
      f.wpSave.click();
      return;
    }
    else if (document.URL.lastIndexOf("&reason=on") != -1)
    {
      var type = prompt("Enter reason for speedy deletion");
      var f = document.editform, t = f.wpTextbox1;
      t.value = "{{db|" + type + "}}\n" + t.value;
      f.wpSummary.value = "JS: Requesting speedy deletion";
      f.wpSave.click();
      return;
    }
  }
  if (window.location.href.indexOf("Special:") != -1)
    return;

  addTab("javascript:easyDb(0)", "db (csd)", "ca-db0", "Request speedy deletion according to WP:CSD", "");
  addTab("javascript:easyDb(1)", "db (reason)", "ca-db0", "Request speedy deletion with reason", "");
});
 
function easyDb(n)
{
  if (n == 0)
  {
    //edit page
    var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));
    location.assign("/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=off");
  }  
   
  if (n == 1)
  {
    //edit page
    var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));
    location.assign("/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=on");
  }
}


//End db script
//

// <nowiki>If you are editing a page, click the wikify button on your tab bar to add "{{Wikify-date|{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}" to the top, set "Marked for wikification." as the edit summary, mark it as a minor edit, and submit.</nowiki>

function doQwikify() {
  document.editform.wpTextbox1.value = '{' + '{' + 'Wikify-date|' + '{' + '{' + 'subst:CURRENTMONTHNAME}} ' + '{' + '{' + 'subst:CURRENTYEAR}}}}\n\n' + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = 'Marked for wikification.';
  document.editform.wpMinoredit.checked = true;
  document.editform.submit();
}

function addQwikify() {
  addTab("javascript:doQwikify()", "wikify", "ca-wikify", "Mark for wikification", "");
  akeytt();
}

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


/* 
// STATUS CHANGER
$(function (){
  var user = document.getElementById( 'pt-userpage' ).firstChild.firstChild.data;
  var subpage = "/Status";
  var scheme = "/StatusTemplate";
  var linkprefix = "http://en.wikipedia.org/w/index.php?title=User:";
  var contribs = document.getElementById( 'pt-mycontris' );
  //Add the links
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=in", "In", "pt-status-in", "I'm in!", "");
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=busy", "Busy", "pt-status-busy", "I'm busy!", "");
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=out", "Out", "pt-status-out", "I'm out!", "");
  if (location.href.indexOf("&action=edit&newstatus=") == -1) return; //Are we here to auto-edit the status?
  //Get new status
  statusRegExp = /&action=edit&newstatus=(.*)/;
  status = statusRegExp.exec(location.href)[1];
  //Modify the form
  document.getElementById('wpTextbox1').value = "{{User:"+user+scheme+"|"+status+"}}";
  document.getElementById('wpSummary').value = "Status: "+status;
  document.getElementById('wpMinoredit').checked = 'checked';
  //Submit it!
  document.getElementById('editform').submit();
});
*/

// 

//<pre><nowiki>
 function aivlist(type) {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  var ip = prompt("Enter IP address", "");
  var reason = prompt("Enter reason for listing", "");
  t.value += "*{{" + type + "|" + ip +"}} " + reason + "--~" + "~" + "~" + "~";
  f.wpSummary.value = "Listing " + ip;
  f.submit();
 }

addOnloadHook(
 function addaivlink() { 
  if (document.title.indexOf("Editing Wikipedia:Administrator intervention against vandalism") != -1)
  {
    addTab("javascript:aivlist('vandal')", "vandal", "ca-vandal", "Report a vandal", "");
    addTab("javascript:aivlist('ipvandal')", "ipvandal", "ca-ipvandal", "Report an ipvandal", "");
  } }
);

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

/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */

// Picture Popups for Mediawiki
// (c)2005 [[User:Zocky]] 
// Released under GPL

document.write('<link rel="stylesheet" type="text/css" href="'  
             + 'http://en.wikipedia.org/w/index.php?title=User:Zocky/PicturePopups.css'
             + '&action=raw&ctype=text/css&dontcountme=s">');

document.addEventListener('click',firstClick,true);

//Handle clicks on document until content is loaded
function firstClick(e)
{
  var c=document.getElementById('content')||document.getElementById('article');
  if (c) {
    c.addEventListener('click',imageClick,false);
    document.removeEventListener('click',firstClick,true); }
}

//Handle clicks on images
function imageClick(e)
{
  if (!e.ctrlKey && !e.shiftKey && !e.metaKey && e.target.tagName=='IMG')
  {
      var t=e.target;
      var caption=t.getAttribute('alt');
      while (t.tagName!='A') { t=t.parentNode; }
      var realurl = t.href;
      var pictitle = unescape(realurl.match(/\/wiki\/Image:(.*)$/)[1].replace(/_/g," "));
     
      if (caption!='Enlarge')
      {
        try 
        {
          var captiondiv=t.nextSibling.nextSibling;
          if (captiondiv.getAttribute('class')=='thumbcaption') {caption=captiondiv.innerHTML}
        }
        catch (er){}

        x=Math.round(Math.random()*200);
        y=Math.round(Math.random()*200);
        var note_content_div=new_note(x, y, '[<a href="'+realurl+'"> &gt; </a>] '+pictitle, '<blink><small><i>loading...</i></small></blink>',caption);
        note_content_div.addEventListener('click',noteContentClick,true);

        var cbSuccess=function(x,c)
        {
          note_content_div.innerHTML='';
          note_content_div.appendChild(findDescendantById(c,'file')) || (note_content_div.innerHTML="Failed. <a>retry</a>");
          try { note_content_div.appendChild(findDescendantById(c,'imageLicense')); } catch(er) {};
          return true;
        }

        var cbFailure=function(x,c)
        {
          note_content_div.innerHTML==x.statusText;
          return true;
        }

        loadText(realurl,cbSuccess,cbFailure);
      }
      else
      {
        var img = t.parentNode.parentNode.parentNode.firstChild.firstChild;
        if (img.hasAttribute('thumbwidth'))
        {
           var dummy=img.getAttribute('thumbwidth')
           img.setAttribute('thumbwidth',img.width);
           img.width=dummy;
           img.parentNode.parentNode.style.width=(img.width+2) + "px";
           var dummy=img.getAttribute('thumbheight')
           img.setAttribute('thumbheight',img.height);
           img.height=dummy;
        }
        else
        {
          img.setAttribute('thumbwidth',img.width);
          img.setAttribute('thumbheight',img.height);
    
          var cbSuccess=function(x,c)
          {
            var dummy=findDescendantById(c,'file');
            if (dummy.firstChild.tagName=='IMG')
            { 
              img.src=dummy.firstChild.src;
              img.width=dummy.firstChild.width;
              img.height=dummy.firstChild.height;
            }
            else
            {
              img.width=dummy.firstChild.firstChild.width;
              img.height=dummy.firstChild.firstChild.height;
              img.src=dummy.firstChild.firstChild.src;
            }
            img.parentNode.parentNode.style.width=(img.width+2) + "px";
            return true; 
          }
        
          var cbFailure=function(x,c)
          {
            return true;
          }
          loadText(realurl,cbSuccess,cbFailure);
        }
      }
      e.preventDefault();
  }
}

//Stop popup images from linking to hi-res pages
function noteContentClick(e)
{
  e.target.tagName=='IMG' && e.preventDefault() ;
}


//NOTES

var note_top=100;
var active_note;
var note_back='globalWrapper';

function note_icons(n)
{
  return   '<nobr>[<a onclick="toggle_note(\''+n+'\')"> - </a>] '
        +  '[<a onclick="close_note(\''+n+'\')"> x </a>]</nobr>';
}

function new_note(x,y,title,content,caption)
{
  var note_container=document.getElementById(note_back)
  note_top++;

  var note = document.createElement("div");
  note.id = "note_" + note_top;
  note.setAttribute('class', "imagenote");
  note.setAttribute('minimized', "0");
  x>0 && (note.style.left = x + "px") || (note.style.right = -x + "px");
  y>0 && (note.style.top = y + "px") || (note.style.bottom = -y + "px");
  note.style.zIndex=note_top;


  note.innerHTML = '<table><tr class="imagenotetitlebar">'
                 + '<td class="imagenotetitle" id="'+note.id+'_title"><span>' + title + '</span></td>'
                 + '<td class="imagenoteicons" id="'+note.id+'_icons" align="right">' + note_icons(note.id) + '</td></tr>'
                 + '<tr><td class="imagenotecontent" id="'+note.id+'_content" colspan="2">'+content+'</td></tr>'
                 + '<tr><td class="imagenotecaption" id="'+note.id+'_caption" colspan="2">'+caption+'</td></tr></table>';
  note_container.appendChild(note);

  note.addEventListener("mousedown", pick_note, true);
  note.addEventListener("click", click_note, true);
  active_note=note;
  return document.getElementById(note.id+'_content');
}

function close_note(n)
{
  var note_container=document.getElementById(note_back);
  note_container.removeChild(document.getElementById(n));
}

function toggle_note(n)
{
  var note=document.getElementById(n);
  note.setAttribute('minimized', 1-note.getAttribute('minimized'));
}

var note_dragging;

function pick_note(e)
{
  active_note=e.currentTarget;
  note_top++;
  active_note.style.zIndex = note_top;
  mouse_x = e.clientX;	mouse_y = e.clientY;

  active_note_top = parseInt(active_note.style.top); active_note_left = parseInt(active_note.style.left);
  document.addEventListener("mousemove", drag_note, false);
  document.addEventListener("mouseup", drop_note, false);
  e.preventDefault();
  note_dragging=false;
}

function drag_note(e)
{
  var x = e.clientX;
  var y = e.clientY;

  active_note.style.top = (y - mouse_y + active_note_top) + "px"; active_note.style.left = (x - mouse_x + active_note_left) + "px";
  note_dragging=true;
}

function drop_note(e)
{
  document.removeEventListener("mousemove", drag_note, false);
  document.removeEventListener("mouseup", drop_note, false);
}

function click_note(e)
{
  note_dragging && e.preventDefault();
}


//DOWNLOADER
function loadText(url,cb1,cb2) {
  var x = window.XMLHttpRequest ? new XMLHttpRequest()
        : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
        : false;
  var c=document.createElement("div");

  if (x) {
    x.onreadystatechange=function() {
      x.readyState==4 && textLoaded(x,c,cb1,cb2)};
    x.open("GET",url,true);
    x.setRequestHeader('Accept','text/*');
    x.send(null); }
}

function textLoaded(x,c,cb1,cb2) {
  x.status==200
  && ((c.innerHTML=x.responseText) && cb1 && cb1(x,c))
  || ( cb2 && cb2(x,c) || alert(x.statusText));
}

//XML helper functions
function findDescendantById(node, id) {
  if (node.id == id) { return node; }
  var i, c;
  for (i = node.firstChild; i != null; i=i.nextSibling) {
    c = findDescendantById(i,id);
    if (c != null)
      return c; }
  return null;
}
function doCleanup() {

 document.editform.wpTextbox1.value = '{' + '{' + 'Cleanup-date|' + '{' + '{' + 'subst:CURRENTMONTHNAME}} ' + '{' + '{' + 'subst:CURRENTYEAR}}}}\n\n' + document.editform.wpTextbox1.value;
 document.editform.wpSummary.value = 'Marked for cleanup.';
 document.editform.wpMinoredit.checked = true;
 document.editform.submit();

}

function addCleanup() {

 addTab("javascript:doCleanup()", "cleanup", "ca-cleanup", "Mark for cleanup", "");
 akeytt();

}

$(function() {

 if (document.title.indexOf("User:") != -1 || document.title.indexOf("User talk:") != -1) {
    return;
 }
 if (document.title.indexOf("Editing ") != -1) {
 addOnloadHook(addCleanup);
 }

});
// Install InstaView
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Pilaf/instaview.js&action=raw&ctype=text/javascript');

InstaView.conf.user.name = 'Pilaf';

/* This is to keep track of who is using InstaView: [[User:Pilaf/instaview.js]] */

/************ OLD STUFF *************

// Live Preview customization,
// edit this to your own liking.

wpUserName   = 'Split Infinity';   // User name to display in signatures
wpShowImages = true;      // Enable downloading and displaying of images

// Include Live Preview...
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js&action=raw&ctype=text/javascript');

// Now set everything up
window.onload = Main;

function Main()
{
 LivePreviewInstall();
 // You may include here other "extensions"
}

*/
//</nowiki></pre>
//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 = "{{subst:" + "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 = "{{subst:" + "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 = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD";
}

function 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 = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD";
}

function 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 = "{{subst:" + "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)
    {
      addLink('p-cactions', 'javascript:autoafd_result()', "close");
      addLink('p-cactions', 'javascript:autoafd_relist()', "relist");
    }
  if (document.title.indexOf("Editing Talk:") != -1)
    {
      addLink('p-cactions', 'javascript:autoafd_keep()', "keep");
      addLink('p-cactions', 'javascript:autoafd_no_consensus()', "no consensus");
      addLink('p-cactions', 'javascript:autoafd_redirect()', "redirect");
      addLink('p-cactions', 'javascript:autoafd_merge()', "merge");
      addLink('p-cactions', 'javascript:autoafd_other()', "other");
    }
}

$(autoafd_add_afd_tabs);

//end AfD closing script
//</nowiki></pre>
// addPurge
$( function (){
    var x = document.getElementById('ca-history');
    if(!x) return;
    if(x.children) x = x.children[0].href;
    else x = x.childNodes[0].href;
    addLink("p-cactions", x.replace(/=history/, "=purge"), 'purge', 'ca-purge', 'Purge the internal cache for this page', 0);
});
function import_module(page){
    if( document.createElement && document.childNodes ) {
        var url = 
            'http://en.wikipedia.org/w/index.php?title=' + 
            escape(page) + 
            '&action=raw&ctype=text/javascript&dontcountme=s';
        var scriptElem = document.createElement('script');
        scriptElem.setAttribute('src', url);
        scriptElem.setAttribute('type', 'text/javascript');
        document.getElementsByTagName('head')[0].appendChild(scriptElem);
    }
}
import_module('Wikipedia:WikiProject User scripts/Scripts/Formatter');
import_module('User:Poccil/Automation.js&oldid=16972944');
function addAlexaLinks() {
  for (var i=0; i<document.links.length; ++i) {
    var l=document.links[i];
    if(l.className.indexOf('external') != 0) continue;
    var sp=document.createElement('span');
    sp.innerHTML=' [<a href="http://www.alexa.com/data/details/?url=' + l.href + '">alexa</a>]';
    if(l.nextSibling) l.parentNode.insertBefore(sp, l.nextSibling);
    else l.parentNode.appendChild(sp);
  }
}
$(addAlexaLinks);
function talkpageplus()
{
    var talkpagelink = document.getElementById('ca-talk');
    if (talkpagelink.className == 'new')
    {
        talkpagelink.firstChild.href += '&section=new';
    }
}
$(talkpageplus);