User:Harryboyles/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.
//External scripts
//----------------
//Metadata script
importScript('User:Pyrospirit/metadata.js'); //[[User:Pyrospirit/metadata.js]]
//Navigation popups
importScript('User:Lupin/popups.js');
//Adjusts Special:Log to present information in a easy to read table
importScript('User:Alex_Smotrov/logpage.js');
//Enhances Special:Whatlinkshere with more options for filtering the list
importScript('User:Barticus88/WhatLinksHere.js');
//Adds a tab to edit the 0'th section of the page
importScript('Wikipedia:WikiProject User scripts/Scripts/Add edit section 0');
//Adds a "Changes since last load" link to your watchlist
importScript('Wikipedia:WikiProject_User_scripts/Scripts/Watchlist_since');
//Adds a tab which shows the diff since the current user last edited the page
importScript('Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited'); 
//Adds AJAX unwatch links (x) to each entry in the watchlist. 
importScript('User:Alex Smotrov/wlunwatch.js');
//Adds a tab to hide the "top" diffs on Special:Contributions
importScript('User:Ais523/hidetopcontrib.js');
//Edit suggestion improvement
importScript('User:Cameltrader/Advisor.js');
//Dispenser's Link checker
importScript('User:Dispenser/Link checker/toolbox.js');
//Lupin's Antivandal script
importScript('User:Lupin/recent2.js');
//Dr pda's category template script
importScript('User:Dr pda/templatecheck.js');
//Dr pda's edit references script
importScript('User:Dr pda/editrefs.js');
//Dr pda's article history script
importScript('User:Dr pda/articlehistory.js');
//Articles for creation improvement
if(mw.config.get('wgPageName').split("/")[0] == "Wikipedia:Articles_for_creation")
{
// [[User:Henrik/afc-helper]]
importScript('User:Henrik/js/afc-helper.js'); 
}
//Alters the history tab (see User talk:Alex Smotrov/histcomb.js for description
if(mw.config.get('wgAction') == 'history')
{
  histCombNoCollapse=true;
  importScript('User:Alex Smotrov/histcomb.js');
}
//Navigation popups configuration			 
popupDelay=0.75;
popupHideDelay=0.25;
popupOnEditSelection=false;// Popups will not appear in the edit box
popupSubpopups=false;// Popups won't appear when pointing at a link in a popup
popupFixDabs=true;
popupContribsPreviewLimit=10;// Adjusts the number of contributions shown for a user
//Changes since I last edited configuration
defaultdiffs = 1000;


//Internal scripts
//-------------------
//Trims "Wikipedia, the free encyclopedia" from the title of the page
TrimTitle();
function TrimTitle(){
  var pagetitle= document.title;
  var endtext = 35;
  document.title = String(pagetitle).substring(0,pagetitle.length - endtext);
}

//Adds a list of empty categories in an article to the top of the page
addOnloadHook(function DupCats(){
if(document.getElementById('catlinks')&&wgNamespaceNumber==0)
{
  var newcatlinks = document.getElementById('catlinks').cloneNode(true);
  newcatlinks.id = 'emptycats';
  var newlinkscount = 0;
  var listitems = newcatlinks.firstChild.getElementsByTagName('a');
    for (i=0;i<listitems.length;i++) {
      if(listitems[i].className != 'new') 
      {
        listitems[i].parentNode.removeChild(listitems[i]);
        i--;
      }
      else
      {
        newlinkscount++;
      }
    }
  listitems = newcatlinks.firstChild.getElementsByTagName('a');
  if(newlinkscount > 0)
  {
    sitebyline = document.getElementById("siteSub");
    sitebyline.parentNode.insertBefore(newcatlinks, sitebyline.nextSibling);  
  }
}
});
//Replace edit summary info link with plain text and minor edit link
addOnloadHook(function RemoveEditSummaryLink(){
if(linkElementBox = document.getElementById('wpSummaryLabel'))
{
var linkElementSpan = linkElementBox.firstChild.firstChild;
var newText = document.createTextNode('Edit summary ');
linkElementSpan.removeChild(linkElementSpan.firstChild);
linkElementSpan.insertBefore(newText,linkElementSpan.firstChild);
}
if(linkMinorEdit = document.getElementById('minoredit_helplink'))
{
linkMinorEdit.parentNode.removeChild(linkMinorEdit);
}
})
//Various links for information about users in the toolbox on the left hand side
if (mw.config.get('wgCanonicalNamespace') == "User" || mw.config.get('wgCanonicalNamespace') == "User_talk")
  addOnloadHook(AddUserInformationLinks);
function AddUserInformationLinks(){
    var UserName = mw.config.get('wgTitle').split(":")[0];
        UserName = UserName.split("/")[0];
    //Actions performed by user: deletions, protections, etc)
    url = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=Special:Log&user=" + UserName;
    mw.util.addPortletLink("p-tb", url, "Actions by user", "pt-byuserlogs", "Log of actions this user has performed");
         
	//Actions performed on user (promotions, blocks, etc)
    url = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=Special:Log&page=User:" + UserName;
    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");

	//List of blocks on this user
    url = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=Special:Log&type=block&user=&page=User:" + UserName;
    mw.util.addPortletLink("p-tb", url, "Block log", "pt-blocklog", "Log of blocks applied to this user (if any)");
		 
	//Blocked currently?
    url = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=Special:Ipblocklist&ip=" + UserName;
    mw.util.addPortletLink("p-tb", url, "Block status", "pt-blockstatus", "Whether this user or IP address is currently blocked");
		 
	//Admin or other permissions?
    url = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=Special:Listusers&limit=1&username=" + UserName;
    mw.util.addPortletLink("p-tb", url, "User permissions", "pt-userrights", "Permissions (if any) granted to the user");
		 
	//List of deleted contributions
	url = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=Special:DeletedContributions&target=" + UserName;
    mw.util.addPortletLink("p-tb", url, "Deleted contribs", "pt-deletedcontribs", "List of contributions that have subsequently been deleted");
	
    //Subpages
    url = mw.config.get('wgServer') + mw.config.get('wgScript') +"?title=Special:Prefixindex&namespace=" + mw.config.get('wgNamespaceNumber') + "&from=" + UserName;
    mw.util.addPortletLink("p-tb", url, "Subpages of user", "pt-subpages", "A list of all the subpages existing in a user's userspace");
}

//A clock that sits in the top right hand corner (with a purge link included).
$(function(){
      mw.util.addPortletLink("p-personal", mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName').replace(/&/g,'%26') + '&action=purge', 'UTC time', 'utcdate');
      showtime();
   });
function showtime(){
      var time    = new Date();
      var date    = time.getUTCDate();
      var months  = 'January February March April May June July August September October November December'.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 + ", " + month + " " + date + " " + year + " (UTC)";
      if (document.getElementById('utcdate')){
         document.getElementById('utcdate').firstChild.innerHTML = timeValue;
      }
      timerID = setTimeout('showtime()', 1000);
 }
//Adds a tab to view the source wikicode of the page
$(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);
      }
});
//Renames the new section link on talk pages
$(function () {
  if(document.getElementById('ca-addsection'))
  {
    q=document.getElementById('ca-addsection').firstChild; 
    q.removeChild(q.firstChild);
    q.appendChild(document.createTextNode("+"));
  }
});
//Renames the talk tab   
$(function () {
  if(document.getElementById('ca-talk'))
  {
	q=document.getElementById('ca-talk').firstChild; 
	q.removeChild(q.firstChild);
	q.appendChild(document.createTextNode("talk"));
  } 
});
//Adds a tab which links to the last change made on a page
$(function () {
  if(mw.config.get('wgCanonicalNamespace') != "Special")
  {
    mw.util.addPortletLink('p-cactions', mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName') + "&diff=cur&oldid=prev",    'last', 'ca-last', 'Show most recent diff');
  }
});
//Adds a tab which links to the log for the page
$(function () {
  if(mw.config.get('wgCanonicalNamespace') != "Special")
  {
    url = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=Special:Log&page=" + mw.config.get('wgPageName');
    mw.util.addPortletLink("p-cactions", url, "page log", "ca-pagelog", "Log of actions performed on this page");
  }
});

$(function () {
if(document.getElementById("wikiPreview"))
{
 if(document.getElementById("wikiPreview").display != "none")
{
   document.title = "Previewing " + mw.config.get('wgPageName');
document.getElementsByTagName("h1")[0].innerHTML = "Previewing " + mw.config.get('wgPageName');
}
}

})

$(function () {
    url = mw.config.get('wgServer') + "/wiki/User:" + mw.config.get('wgUserName') + "/monobook.js";
    mw.util.addPortletLink("p-personal", url, "My javascript", "pt-javascript", "Your javascript","" ,document.getElementById("pt-logout"));
if(window.location.href == url)
{
document.getElementById("pt-javascript").className += " active";
}
    url = mw.config.get('wgServer') + "/wiki/User:" + mw.config.get('wgUserName') + "/monobook.css";
    mw.util.addPortletLink("p-personal", url, "My stylesheet", "pt-stylesheet", "Your stylesheet", "",document.getElementById("pt-logout"));
if(window.location.href == url)
{
document.getElementById("pt-stylesheet").className += " active";
}
})
$(function () {

var Title = document.getElementsByTagName("h1")[0]; 
var Sitesub = document.getElementById("siteSub");
Title.parentNode.insertBefore(Sitesub, Title.nextSibling);
if(mw.config.get('wgNamespaceNumber') != 0)
{
   Sitesub.display = "none";
}
var br = document.createElement("br");
var heading = document.getElementById("firstHeading")
heading.parentNode.insertBefore(br, heading.nextSibling);

var bodycon = document.getElementById("bodyContent");
var br2 = document.createElement("br");
bodycon.parentNode.insertBefore(br2, bodycon);

var subline = document.getElementById("contentSub");
br2.parentNode.insertBefore(subline, br2.nextSibling);
})

if(mw.config.get('wgCanonicalNamespace') == "Category")
{
$(function() {
var mwpages = document.getElementById("mw-pages");
if(mwpages != null)
{
var categorylinks = mwpages.getElementsByTagName("a");
var editlinkbase = document.createElement("a");
editlinkbase.href = mw.config.get('wgServer') + mw.config.get('wgScript');
editlinkbase.title = "(edit)";
editlinkbase.className += " editcategorymember";

for(var i = 0; i<categorylinks.length;i++)
{
   var titlepage = categorylinks[i].title
   var editlink = editlinkbase.cloneNode(true);
   editlink.href +=  "?title=" + titlepage + "&action=edit";
editlink.innerHTML = "(edit) ";
   var normallink = categorylinks[i];
   normallink.parentNode.insertBefore(editlink,normallink);
i++;
}

}

})
}