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.
// <nowiki>
// [[User:Lupin/popups.js]]importScript('User:Lupin/popups.js');

/*
<pre> <nowiki>
Note: After saving, you have to bypass your browser's cache to see the changes.
To do this in Firefox/Mozilla/Safari: hold down Shift while clicking Reload, 
or press Ctrl-Shift-R). 
If you use Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.



/*
</nowiki> </pre>
==WikEd, replaces Firefox's text edit window ==
<pre> <nowiki> */

// install [[User:Cacycle/wikEd]] in-browser text editor
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript');

/*
</nowiki> </pre>
==Lupin's anti-vandal tools ==
<pre> <nowiki> */


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

/*
</nowiki> </pre>
==Popups==
<pre> <nowiki> */
/* [[User:Lupin/popups.js]] */

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

/*{{User:AndyZ/peerreviewer.js}}*/
/*
</nowiki> </pre>
== Watchlist sorter ==
<pre> <nowiki>
Sorts your watchlist by namespace, and also adds spaces for readability.
*/

$(function (){
  if (location.href.indexOf('Special:Watchlist') == -1) return; //Are we on a watchlist?
  //days = document.getElementById('bodyContent').getElementsByTagName('ul');
  days = document.evaluate( //Hell knows how it works - found in "Dive into Greasemonkey"
    "//ul[@class='special']",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);
  for (d = 0; d < days.snapshotLength; d++) { //For each day
    day = days.snapshotItem(d);
    newday = document.createElement('ul'); //This will replace the old listing
    while ((diffs = day.getElementsByTagName('li')).length > 0) { //Are there any diffs left?
      //Try to extract the namespace
      As = diffs[0].getElementsByTagName('a');
      if (As[0].innerHTML == 'diff')
        pagename = As[2].innerHTML;
      else
        pagename = As[1].innerHTML;
      if (pagename.indexOf(':') == -1)
        namespace = 'Main';
      else
        namespace = pagename.split(':')[0]; //This will fail for articles which contain ":" in name
      hdrs = newday.getElementsByTagName('h5'); //Get the list of namespace headers
      hdr = null;
      for (j=0; j<hdrs.length; j++) //Find the header
        if (hdrs[j].innerHTML==namespace) {
          hdr = hdrs[j]; break;
        }
      if (hdr==null) { //Not found? Make a new one!
        hdr = document.createElement('h5');
        hdr.innerHTML = namespace;
        newday.appendChild(hdr);
        namespacesub = document.createElement('ul');
        newday.appendChild(namespacesub);
      }
      hdr.nextSibling.appendChild(diffs[0]); //Move the diff
    }
    newday.appendChild(document.createElement('hr')); //For readablility
    day.parentNode.replaceChild(newday,day);
  }
});



importScript('[[User:Ioeth/friendly.js]]');




/* How to use:
* 
* Add the following to [[Special:Mypage/monobook.js]] as a
* logged-in user using the monobook skin:
*   importScript('User:Gracenotes/rollback.js');
*
* On diff pages, a "sum" link will appear next to "rollback".
* When you click on "sum", you will be prompted to enter a
* summary. Press "Cancel" to cancel, and leave a blank summary
* to use the default. In the summary, the text "$user" will
* automatically be replaced with the user name you're reverting.
* e.g., "rv edits by $user; not true"
*/
 
function addSumLink() {
var ntitle2 = document.getElementById("mw-diff-ntitle2")
if (!ntitle2) return;
var rbnode = getElementsByClassName(document.getElementById("mw-diff-ntitle2"), "span", "mw-rollback-link");
if (rbnode.length != 0)
addRollbackSummaryLink(rbnode[0]);
}
 
function confirmRollback() {
var url = this.href;
var user = url.match(/[?&]from=([^&]*)/);
if (!user) return;
var user = decodeURIComponent(user[1].replace("+", " "));
var summary = prompt("Enter a summary to use for rollback.\n\nLeave blank to use the default. $user will be replaced with \"" + user + "\".")
if (summary == undefined)
return false;
else if (summary == "")
return true;
this.href += "&summary=" + encodeURIComponent(summary.replace(/\$user/g, user));
return true;
};
 
function addRollbackSummaryLink(rbnode) {
var rblink = rbnode.getElementsByTagName("a")[0]
var alink = rblink.cloneNode(true);
alink.className = ""; //don't confuse other scripts
alink.firstChild.nodeValue = "sum";
alink.onclick = confirmRollback;
rbnode.insertBefore(alink, rblink.nextSibling);
rbnode.insertBefore(document.createTextNode("|"), alink);
}
 
$(addSumLink);




//this helps automate AfD closing by adding a 'close' tab to AfD debates
//written by [[User:Johnleemk]] based on [[Wikipedia:WikiProject User scripts/Scripts/test-n.js]] by [[User:Celestianpower]]

function autoafd_result()
{
var close = prompt("Result of debate?")
var f = document.editform, t = f.wpTextbox1;
t.value = t.value.split('{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD').join('{{ns:0');
t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "ab" + "}}";
f.wpSummary.value = "Closing debate; result was " + close;
}

function autoafd_relist()
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "relist" + "|~" + "~" + "~" + "~}}";
f.wpSummary.value = "Relisting debate";
}

function autoafd_keep()
{
var date = prompt("Nomination was made when?")
var votepage = prompt("Vote page is? (Enter 'd' for default.)")
var f = document.editform, t = f.wpTextbox1;

// If default votepage...
if (votepage=="d")
{
var temp = document.editform.action.split("/w/index.php?title=");
var temp = temp[1].split("&action=submit");
var temp = temp[0].substring(5);
var votepage = temp;
}

t.value = "{{" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
f.wpSummary.value = "Article survived AfD";
}

function autoafd_no_consensus()
{
var date = prompt("Nomination was made when?")
var votepage = prompt("Vote page is? (Enter 'd' for default.)")
var f = document.editform, t = f.wpTextbox1;

// If default votepage...
if (votepage=="d")
{
var temp = document.editform.action.split("/w/index.php?title=");
var temp = temp[1].split("&action=submit");
var temp = temp[0].substring(5);
var votepage = temp;
}

t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
f.wpSummary.value = "Article survived AfD with no consensus";
}

function autoafd_redirect()
{
var date = prompt("Nomination was made when?")
var redirect = prompt("Redirect to?")
var votepage = prompt("Vote page is? (Enter 'd' for default.)")
var f = document.editform, t = f.wpTextbox1;

// If default votepage...
if (votepage=="d")
{
var temp = document.editform.action.split("/w/index.php?title=");
var temp = temp[1].split("&action=submit");
var temp = temp[0].substring(5);
var votepage = temp;
}

t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD";
}

function autoafd_merge()
{
var date = prompt("Nomination was made when?")
var redirect = prompt("Merge and redirect to?")
var votepage = prompt("Vote page is? (Enter 'd' for default.)")
var f = document.editform, t = f.wpTextbox1;

// If default votepage...
if (votepage=="d")
{
var temp = document.editform.action.split("/w/index.php?title=");
var temp = temp[1].split("&action=submit");
var temp = temp[0].substring(5);
var votepage = temp;
}

t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD";
}

function autoafd_other()
{
var date = prompt("Nomination was made when?")
var result = prompt("Result was?")
var votepage = prompt("Vote page is? (Enter 'd' for default.)")
var f = document.editform, t = f.wpTextbox1;

// If default votepage...
if (votepage=="d")
{
var temp = document.editform.action.split("/w/index.php?title=");
var temp = temp[1].split("&action=submit");
var temp = temp[0].substring(5);
var votepage = temp;
}

t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
f.wpSummary.value = "AfDed; result was " + result;
}

function autoafd_add_afd_tabs()
{
// Only add for pages with the right string somewhere in the title
if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1)
{
mw.util.addPortletLink('p-cactions', 'javascript:autoafd_result()', "close");
mw.util.addPortletLink('p-cactions', 'javascript:autoafd_relist()', "relist");
}
if (document.title.indexOf("Editing Talk:") != -1)
{
mw.util.addPortletLink('p-cactions', 'javascript:autoafd_keep()', "keep");
mw.util.addPortletLink('p-cactions', 'javascript:autoafd_no_consensus()', "no consensus");
mw.util.addPortletLink('p-cactions', 'javascript:autoafd_redirect()', "redirect");
mw.util.addPortletLink('p-cactions', 'javascript:autoafd_merge()', "merge");
mw.util.addPortletLink('p-cactions', 'javascript:autoafd_other()', "other");
}
}

$(autoafd_add_afd_tabs);

//end AfD closing script

//

importScript('User:Mr.Z-man/closeAFD.js');
// </nowiki>