User:John Reaves/monobook.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
//moves
Mvaluejs_class = 'SOMETHING YOU MAKE UP';
//edits
Rvaluejs_class = 'SOMETHING YOU MAKE UP';
//uploads
Uvaluejs_class = 'SOMETHING YOU MAKE UP';
 
importScript('User:AzaToth/twinkledelimages.js');
importScript('User:AzaToth/twinklebatchdelete.js');
 
// User:Steel359/protection.js
importScript('User:Steel359/protection.js');
 
 
//Interiot's javascript edit counter
if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
  document.write('<script type="text/javascript" src="' 
    + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); }
 
 
// [[User:Lupin/popups.js]]
 
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
popupDiffDates=true;
popupAdjustDates=true;
popupRevertSummaryPrompt=true;
popupOnEditSelection=false;
popupAdminLinks=true;
 
addOnloadHook(addnav)
function addnav() {
    var tb = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Special:Newpages', 'New pages', 'n-newpages', 'Special:Newpages', '');
}
 
function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    if(id)
    {
        if(key && title)
        {
            ta[id] = [key, title];
        }
        else if(key)
        {
            ta[id] = [key, ''];
        }
        else if(title)
        {
            ta[id] = ['', title];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c4/Button_ref.png",
     "speedTip": "Ref tags",
     "tagOpen": "<ref>",
     "tagClose": "</ref>",
     "sampleText": "references"};
 
// addPurge
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;
    addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
                   'purge', 'ca-purge', 'Purge server cache for this page', 'p');
});
 
//
 
////////////////////////////////////////////////////////////////
// =-=-=- HELPER FUNCTIONS -=-=-=-
function addlilink(tabs, url, name, id, title, key)
{
//check for duplicates
if (document.getElementById(id)){return;}
//cologne blue bypass
if (document.getElementById('quickbar'))
   {
   if (document.getElementById('quickbar') && document.getElementById('quickbar').getElementsByTagName('h6')[0])
      {
      addquickbarlink(url, name, id, title, 'Edit');
      }
   if (document.getElementById('footer') && !document.getElementById('bodyContent'))
      {
      addfooterlink(url, name, id, title);
      }
   return;
   }
//monobook
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    if(id)
    {
        if(key && title)
        {
            ta[id] = [key, title];
        }
        else if(key)
        {
            ta[id] = [key, ''];
        }
        else if(title)
        {
            ta[id] = ['', title];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
 
function insertAfter(parent, node, referenceNode) {
    parent.insertBefore(node, referenceNode.nextSibling);
}
 
function prependChild(parent, node) {
    parent.insertBefore(node, parent.firstChild);
}
 
function addToolboxLink(url, name, id, key)
{
    if (document.getElementById('p-tb'))
      {var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];}
    addlilink(tb, url, name, id, key);
}
 
function addTab(url, name, id, title, key)
{
//monobook
    if (document.getElementById('p-cactions'))
      {var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];}
//cologneblue
    else {
      if (document.getElementById('quickbar'))
        {var tabs = document.getElementById('quickbar').getElementsByTagName('h6')[2];}
      if (document.getElementById('footer'))
        {var tabs = document.getElementById('footer').getElementsByTagName('td')[0];}
      return addquickbarlink(url, name, id, 'Edit');
    }
      return addlilink(tabs, url, name, id, title, key);
}
 
///////////////
//cologneblue tab/link adder
function addquickbarlink(url, name, id, title, header)
{
var header = '<h6>' + header + '</h6>';
var tabs = document.getElementById('quickbar'); 
if (tabs.innerHTML.indexOf(header) ==-1)
  {return;}
var add_html = '<strong><a id="' + id + '" title="' + title + '" href="' + url + '">' + name + '</a></strong><br />';
var section_html = tabs.innerHTML.split(header)[1].split('<h6>')[0];
var next_section = '<h6>' + tabs.innerHTML.split(header)[1].split('<h6>')[1].split('</h6>')[0] + '</h6>';
tabs.innerHTML = tabs.innerHTML.split(header)[0] + header + section_html + add_html + next_section + tabs.innerHTML.split(next_section)[1];
}
 
function addfooterlink(url, name, id, title)
{
var tabs = document.getElementById('footer').getElementsByTagName('td')[1]; 
var add_html = '<strong><a href="' + url + '" title="' + title + '" id="' + id + '">' + name + '</a></strong>';
tabs.innerHTML = add_html + ' | ' + tabs.innerHTML;
}
///////////////
 
function addLink(where, url, name, id, title, key, after){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
	tabs.insertBefore(li,document.getElementById(after));
    } else {
	tabs.appendChild(li);
    }
    if(id) {
	if(key && title) { ta[id] = [key, title]; }
	else if(key) { ta[id] = [key, '']; }
	else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
/////////////////////////////////////////////
 
/**** Add generic tab ****/
 
function addlilink_simple(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}
 
function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '#';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}
 
/////////
//These are simplier versions of the above, except they add the links on top, not on botton
function addnavbox_link(URL,Name,ID)
{
//cologne blue bypass
   if (document.getElementById('quickbar') && document.getElementById('quickbar').getElementsByTagName('h6')[0])
      {
      var tabs = document.getElementById('quickbar'); 
      addquickbarlink(URL, Name, ID, Name, 'Browse');
      return;
      }
//monobook
var portlet = document.getElementById('p-navigation');
var links = portlet.getElementsByTagName('ul')[0];
links.innerHTML += '<li id="' + ID + '"><a href="' + URL + '">' + Name + '</a></li>';
}
//////////
 
function URLEncoding(input)
      {
        var encodedInputString=escape(input);
        encodedInputString=encodedInputString.replace(/\+/g, "%2B");
        encodedInputString=encodedInputString.replace(/\//g,"%2F");  
        encodedInputString=encodedInputString.replace(/&/g,"%26");     
        var outputurl=encodedInputString;
        return outputurl;
      }
 
if (document.implementation.createDocument)
 {var gml_xmlparser = new DOMParser();}
 
function standard_XMLParse(string) 
{
  if (document.implementation.createDocument)
 {
    return gml_xmlparser.parseFromString(string, "text/xml");
  } 
  else if (window.ActiveXObject) 
  {
    string = string.replace(/<body .*\"ns-(.*)\">/, '<body class="ns-$1">');
    rer = string.match(/<h1 .*<\/h1>/)[0].replace(/&/g, '&');
    if (rer) {string = string.replace(/<h1 .*<\/h1>/, rer);}
    var gml_xmldoc = new ActiveXObject("Microsoft.XMLDOM");
    gml_xmldoc.async = false;
    ret = gml_xmldoc.loadXML(string);
    myErr = gml_xmldoc.parseError;
		if (myErr.errorCode || !ret)
                {
			showError("Error: " + ERROR_XML + myErr.reason);
			return null;
		}
		return gml_xmldoc.documentElement
  }
  return null;
}
 
function HTTPClient()
{
  var xml_http = false;
  if(window.XMLHttpRequest)
    xml_http = new XMLHttpRequest();
  else if (IE){
    try{
      xml_http = new ActiveXObject("Msxml2.XMLHTTP")
    } catch (e){
      try{
        xml_http = new ActiveXObject("Microsoft.XMLHTTP")
      } catch (e){}
    }
  }
	if (!xml_http) showError(ERROR_XML);
  return xml_http
};
 
 //<nowiki> AfD/PfD/Copyvio and tagging 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>');
//</nowiki>[[Category:Wikipedians who use VoA script|{{PAGENAME}}]]
 
// adds a 'logs for this page' link to the toolbox bar
// if the page is a user's page, talk page or subpage, the link will go to logs for the user instead
// if the page is a special page, then no link is displayed
 
addOnloadHook(function () {
 
 // if this is a user, show the logs for the user rather than the page
 if ( wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk" ) {
  url = wgServer + "/w/index.php?title=Special:Log&user=" + wgTitle.split("/")[0];
 } else if ( wgCanonicalNamespace == "Special" ) {
  // don't display link for special pages
  return;
 } else {
  url = wgServer + "/w/index.php?title=Special:Log&page=" + wgPageName;
 }
 
 addPortletLink("p-tb", url, "Logs", "pt-logs");
 
});
 
//
 
//<nowiki> Admin tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/admin/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
//</nowiki>[[Category:Wikipedia administrators who use VoA script|{{PAGENAME}}]]
 
addOnloadHook(function (){
		if(queryString("submitdelete")=="true") document.forms[0].wpConfirmB.click();
	});
	function queryString(p) {
		var re = RegExp('[&?]' + p + '=([^&]*)');
		var matches;
		if (matches = re.exec(document.location)) {
			try { 
				return decodeURI(matches[1]);
			} catch (e) {
			}
		}
		return null;
	};
 
importScript("User:Lupin/recent2.js");