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>
// [[Wikipedia:WikiProject User scripts/Scripts/addLink]]
 function addLink(where, url, name, id, title, key, after) {
     // addLink() accepts either an id or a DOM node, mw.util.addPortletLink() only takes a node
     if (after && !after.cloneNode)
         after = document.getElementById(after);
 
     return mw.util.addPortletLink(where, url, name, id, title, key, after);
 }

function addTab(url, name, id, title, key){
    return addLink('p-cactions', url, name, id, title, key);
}

//If you are not editing a page, a tab will appear allowing you to edit the 0th section of a page (the top area usually used as an introduction.

$(document).ready(function () {
    var x;
    if (!(x = document.getElementById('ca-edit') )) return;
    var url;
    if (!(url = x.getElementsByTagName('a')[0] )) return;
    if (!(url = url.href )) return;
    var y = addLink('p-cactions', url+"&section=0", '0', 'ca-edit-0',
                    'Edit the lead section of this page', '0', x.nextSibling);

    y.className = x.className;  // steal classes from the the edit tab...
    x.className = 'istalk';     // ...and make the edit tab have no right margin

    // exception: don't steal the "selected" class unless actually editing section 0:
    if (/(^| )selected( |$)/.test(y.className)) {
        if (!document.editform || !document.editform.wpSection
            || document.editform.wpSection.value != "0") {
            y.className = y.className.replace(/(^| )selected( |$)/g, "$1");
            x.className += ' selected';
        }
    }
});

function addLastDiff() {
    var l=addTab("//en.wikipedia.org/w/index.php?title=" + mw.config.get('wgPageName') + "&diff=cur&oldid=prev", 'last', '');
    l.lastChild.title="Show most recent diff";
}

if (mw.config.get('wgCanonicalNamespace') != "Special") {
  if (window.addEventListener) window.addEventListener("load", addLastDiff, false);
  else if (window.attachEvent) window.attachEvent("onload", addLastDiff);
}

function addPurge() {
   var t = addTab("//en.wikipedia.org/w/index.php?title=" + mw.config.get('wgPageName') + "&action=purge", 'purge', '');
   t.lastChild.title = "Purge the server cache";
}

if (mw.config.get('wgCanonicalNamespace') != "Special") {
  if (window.addEventListener) window.addEventListener("load", addPurge, false);
  else if (window.attachEvent) window.attachEvent("onload", addPurge);
}

// <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 add_link2(url, name)
  {
    var na = document.createElement('a');
    na.setAttribute('href', url);
    na.appendChild(document.createTextNode(name));
  
    var li = document.createElement('li');
    li.appendChild(na);
  
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    tabs.appendChild(li);
  }
  
  function strip_namespace(target)
  {
    var colon = target.indexOf(':');
    if (colon != -1)
      {
        var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category');
        var ns = target.substring(0, colon);
        if (ns == '' || ns == 'Talk')
          return target.substring(colon + 1);
        else
          for (var i = 0; i < spaces.length; ++i)
            {
              if (ns == spaces[i]
                  || ns == spaces[i] + '_talk')
                return target.substring(colon + 1);
            }
      }
    return target;
  }
  
importScript('User:Holly Cheng/quickimgdelete.js');

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);
    }
}

$(document).ready(function () {
    if(document.forms.editform) {
        addLink('p-cactions', 'javascript:replace()', 'replace', 'ca-replace', 'Regexp replace for the edit window', '', 'ca-history');
    }
    addLastDiff();
    addPurge();
});

importScript("User:Ais523/topcontrib.js");
importScript("User:Anomie/linkclassifier.js");
// </pre>