Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// Renames the search buttons
   addOnloadHook(function(){
      document.getElementById('searchGoButton').value = "Direct"; 
      document.getElementById('mw-searchButton').value = "Fuzzy"; 
      q=document.getElementById('ca-talk').firstChild; 
      q.removeChild(q.firstChild);
      q.appendChild(document.createTextNode("talk"));
   });


// http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Unwatch
   addOnloadHook(function () {

   // Check if we're on the watchlist
      if (!wgCanonicalSpecialPageName || wgCanonicalSpecialPageName != "Watchlist") return;
      if (!document.forms[0] || !document.forms[0].namespace) return;

   // Unwatch links go back to watchlist with "Removing requested items from watchlist..." message
      var query_prefix = "title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=submit&remove=1&id[]=";

   // get list of all links in content:
      var links = document.getElementById('content').getElementsByTagName('a');

   // make a static copy of the nodelist and lose the original for speed
   // while we're at it, prune the uninteresting links from the list
      var linksCopy = new Array ();
      for (var i = 0; i < links.length; i++) {
         if (/[?&]action=history([&#]|$)/.test(links[i].href)) linksCopy.push(links[i]);
      }
      links = linksCopy;

      for (var i = 0; i < links.length; i++) {

      // create unwatch link and append it after history link
         var unwatch = document.createElement('a');
         unwatch.href = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?" + query_prefix + encodeURIComponent(links[i].title);
         unwatch.title = "Unwatch "+links[i].title;
         unwatch.appendChild(document.createTextNode("unwatch"));
         links[i].parentNode.insertBefore(unwatch, links[i].nextSibling);

      // insert a delimiter between the two links
         var delim = links[i].previousSibling;
         delimText = (delim.nodeType == 3 ? delim.nodeValue : ""); // kluge to handle case where "diff" is unlinked
         delim = document.createTextNode(delimText.replace(/^.*diff/, ""));
         links[i].parentNode.insertBefore(delim, unwatch);
      }
   });


// http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Add_purge_to_tabs
   addOnloadHook(function () {
      var hist; var url;
      if (!(hist = document.getElementById('ca-history') )) return;
      if (!(url = hist.getElementsByTagName('a')[0] )) return;
      if (!(url = url.href )) return;
      mw.util.addPortletLink('p-personal', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
                   'purge', 'ca-purge', 'Purge server cache for this page', '0','pt-logout');
   });


// Customised from http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Logs_link
   addOnloadHook(function () {
  
      if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") 
      {
      // Gets base username without subpages or namespace attatched e.g. "Harryboyles"
         var pagepath = wgTitle.split(":")[0];
         username = pagepath.split("/")[0];

      // Actions performed by user (their log)
         url = wgServer + "/w/index.php?title=Special:Log&user=" + username;
         mw.util.addPortletLink("p-tb", url, "Actions by user", "pt-byuserlogs", "Log of actions this user has performed");
         username = wgTitle.split("/")[0];

         url = wgServer + "/w/index.php?title=Special:Log&page=" + wgPageName;
         mw.util.addPortletLink("p-tb", url, "Actions on user", "pt-onuserlog", "Log of actions performed on this user as well as their main user page");

         url = wgServer + "/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A" + username;
         mw.util.addPortletLink("p-tb", url, "Block log for user", "pt-blocklog", "Log of blocks applied to this user (if any)");
         url = wgServer + "/w/index.php?title=Special:Log&page=" + wgPageName;
         mw.util.addPortletLink("p-cactions", url, "page log", "pt-pagelog", "Log of actions performed on this page");

      }
      else if ( wgCanonicalNamespace == "Special" ) 
      {
      // Don't display link for special pages
         return;
         } 
      else 
      {
      // Logs for the page
         url = wgServer + "/w/index.php?title=Special:Log&page=" + wgPageName;
         mw.util.addPortletLink("p-cactions", url, "page log", "pt-pagelog");
      }
   });

// http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Add_edit_section_0
   addOnloadHook(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 = mw.util.addPortletLink('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';
         }
      }
   });


// http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Show_last_diff
   addOnloadHook(addLastDiff);

   function addLastDiff()
   {
      if(wgCanonicalNamespace == "Special" ) return;
      mw.util.addPortletLink('p-cactions', 'http://en.wikipedia.org/w/index.php?title=' + wgPageName + "&diff=cur&oldid=prev",    'last', 'ca-last', 'Show most recent diff');
   }




// http://en.wikipedia.org/wiki/User:Misza13/Scripts/View_source
   addOnloadHook(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('source'));
         li = document.createElement('li'); li.id = 'ca-viewsource'; li.appendChild(na);
         tabs.insertBefore(li,editbutton);
      }
   });


//http://en.wikipedia.org/wiki/User:Barticus88/WhatLinksHere.js
   mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Barticus88/WhatLinksHere.js' 
             + '&action=raw&ctype=text/javascript');


//http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Changes_since_I_last_edited
   addOnloadHook(addSinceTab);

   function addSinceTab() {
      if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
         do_since_I_last_edited()
      }
      else if (wgCanonicalNamespace != "Special") {
         mw.util.addPortletLink("p-cactions", "/w/index.php?title="+wgPageName+"&action=history&gotosince=true", 'since', '', "since");
      }
   }

   function do_since_I_last_edited() {
      var csub=document.getElementById("contentSub");
      var msg=document.createElement("p");
      msg.appendChild(document.createTextNode
                        ("Parsing history... please wait..."));
      msg.className="error";
      csub.insertBefore(msg, csub.firstChild)

      var username=document.getElementById("pt-userpage").textContent;
      var hists=document.getElementById("pagehistory").getElementsByTagName('li');
      for (n=0;n<hists.length;n++) {
         if (hists[n].getElementsByTagName("span")[0].getElementsByTagName('a')[0].textContent==username) {
            document.location=hists[n].childNodes[1].href; 
            return;
         }
      }
      msg.replaceChild(document.createTextNode
         ("You have not edited this page! (recently)"),msg.firstChild);
   }


// http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Watchlist_since
   addOnloadHook(function () {
      if (!wgCanonicalSpecialPageName || wgCanonicalSpecialPageName != "Watchlist") return;
      if (!document.forms[0] || !document.forms[0].namespace) return;

      var link = document.createElement('a');
      link.id = 'listSince';
      link.href = '#listSince';  // must have a href to show as link!

      var then = +(new Date());
      var fixLinkHref = function () {
         var url = window.location.href.split('#')[0];
         var days = ( +(new Date()) - then )/(1000 * 3600 * 24);
         if (url.match(/[?&]days=/))
            this.href = url.replace(/([?&]days=)[^&]*/, '$1'+days);
         else
            this.href = url + (url.indexOf('?') < 0 ? '?':'&') + 'days=' + days;
            return true;
         };
      link.onclick = fixLinkHref;
      link.onmousedown = fixLinkHref;  // react to middle clicks too

      var frag = document.createDocumentFragment();
      frag.appendChild(document.createTextNode(' | '));
      frag.appendChild(link);
      link.appendChild(document.createTextNode('Changes'));
      frag.appendChild(document.createTextNode(' since last load.'));

   // just one little ID attribute would be _so_ nice...
      var nsSelectForm = document.getElementsByTagName('form')[0];
      nsSelectForm.parentNode.insertBefore(frag, nsSelectForm);
   });

// A clock that autoupdates
// From the user scripts project
   addOnloadHook(function(){
      mw.util.addPortletLink("p-personal", 'http://en.wikipedia.org/w/index.php?title=' + wgPageName.replace(/&/g,'%26') + '&action=purge', 'UTC time', 'utcdate');
      showtime();
   });

   function showtime()
   {
      var time    = new Date();
      var date    = time.getUTCDate();
      var months  = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
          month   = months[time.getUTCMonth()];
      var year    = time.getUTCFullYear();
      var hours   = '0' + time.getUTCHours();
          hours   = hours.substr(hours.length-2, hours.length);
      var minutes = '0' + time.getUTCMinutes();
          minutes = minutes.substr(minutes.length-2, minutes.length);
      var seconds = '0' + time.getUTCSeconds();
          seconds = seconds.substr(seconds.length-2, seconds.length);
      var timeValue = hours + ":" + minutes + ":" + seconds + ", " + date + " " + month + " " + year + " (UTC)";
      if (document.getElementById('utcdate')){
         document.getElementById('utcdate').firstChild.innerHTML = timeValue;
      }
      timerID = setTimeout('showtime()', 1000);
   }