User:Konstable/monobook.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.

<!--
// detect browser - disable everything for IE, so VandalProof doesn't complain so mcuh

var detect = navigator.userAgent.toLowerCase();
var IE;
var place = detect.indexOf('msie') + 1;

if (place) IE=true;

if (!IE) {



// Script from [[User:Lupin/recent2.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.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>');

popupStructure = 'original';


// Install InstaView
document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/instaview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

InstaView.conf.user.name = 'Konstable';

/* This is to keep track of who is using InstaView: [[User:Pilaf/instaview.js]] */

/************ OLD STUFF *************

// Live Preview customization,
// edit this to your own liking.

wpUserName   = 'Konstable';   // User name to display in signatures
wpShowImages = true;      // Enable downloading and displaying of images

// Include Live Preview...
document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

// Now set everything up
window.onload = Main;

function Main()
{
 LivePreviewInstall();
 // You may include here other "extensions"
}

*/




// This will add an [edit top] link at the top of all pages except preview pages
// by User:Pile0nades


// Add an [edit top] link to pages
addOnloadHook(function () {
  // if this is preview page or generated page, stop
  if(document.getElementById("wikiPreview") || window.location.href.indexOf("/wiki/Special:") != -1) return;

  // get the page title
  var pageTitle = document.title.split(" - ")[0].replace(" ", "_"); 

  // create div and set innerHTML to link
  var divContainer = document.createElement("div");
  divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-right:15px;margin-top:3px;">[<a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="'+document.title.split(" - ")[0]+'">edit top</a>]</div>';

  // insert divContainer into the DOM before the h1
  if(window.location.href.indexOf("&action=edit") == -1)
    document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);

  if(window.location.href.indexOf("&action=edit&section=0") != -1)
    document.getElementById("wpSummary").value = "/* Intro */ ";
});



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


 function tnaddlilink(url, name)
 {
  var na = document.createElement('a');
  na.setAttribute('href', url);

  var txt = document.createTextNode(name);
  na.appendChild(txt);

  var li = document.createElement('li');
  li.appendChild(na);
  return li;
 }
  
 function testn(number)
 {
  var page = prompt("Vandalism to which article?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + number + "-n|" + page + "}} ~" + "~" + "~" + "~";
  f.wpSummary.value = "Regarding [[" + page + "]] - warning " + number;
  f.submit();
 }
 
 function wA() {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "User:Konstable/Welc-Anon" + "}} --~" + "~" + "~" + "~";
  f.wpSummary.value = "Welcome to Wikipedia!";
  f.submit();
 }
 
 /*function wap() {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "User:Where/pwelcome" + "}} ~" + "~" + "~" + "~";
  f.wpSummary.value = "Use preview; also, welcome!";
  f.submit();
 }*/

 function wC() {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:User:Konstable/Welc}}";
  f.wpSummary.value = "Welcome to Wikipedia!";
  f.submit();
 }
 
 
 function es() {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "==Edit summaries==\n{{subst:" + "Edit summary" + "}} ~" + "~" + "~" + "~";
  f.wpSummary.value = "Please use edit summaries";
  f.submit();
 }
 
 function add_testn_tabs()
 {
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

  // Only add for pages with "Editing User talk:" somewhere in the title
  if (document.title.indexOf("Editing User talk:") != -1)
    {
      tabs.appendChild(tnaddlilink('javascript:es()', "ES"));
      tabs.appendChild(tnaddlilink('javascript:testn("test1")',"t1"));
      tabs.appendChild(tnaddlilink('javascript:testn("test1a")',"t1a"));
      tabs.appendChild(tnaddlilink('javascript:testn("test2")',"t2"));
      tabs.appendChild(tnaddlilink('javascript:testn("test2a")',"t2a"));
      tabs.appendChild(tnaddlilink('javascript:testn("test3")',"t3"));
      tabs.appendChild(tnaddlilink('javascript:testn("test4")',"t4"));
      tabs.appendChild(tnaddlilink('javascript:testn("bv")',"bv"));
      tabs.appendChild(tnaddlilink('javascript:testn("obscene")',"o"));
      tabs.appendChild(tnaddlilink('javascript:testn("joke")',"j"));
      tabs.appendChild(tnaddlilink('javascript:testn("welcomenpov")',"w-N"));
      tabs.appendChild(tnaddlilink('javascript:wA()',"w-A"));
      tabs.appendChild(tnaddlilink('javascript:wC()',"w-C")); // welcome custom using User:Konstable/Welc
//      tabs.appendChild(tnaddlilink('javascript:wap()',"w-A-p"));
 }}
addOnloadHook(add_testn_tabs);



// PicturePopups
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Konstable/PicturePopups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

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


function inc (file) {
  var lt = String.fromCharCode(60);
  var gt = String.fromCharCode(62);
  document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+file+'&action=raw&ctype=text/javascript&dontcountme=s"'+gt+lt+'/script'+gt);
}


// STATUS CHANGER
addOnloadHook(function (){
  var user = document.getElementById( 'pt-userpage' ).firstChild.firstChild.data;
  var subpage = "/Status";
  var scheme = "/StatusTemplate";
  var linkprefix = "http://en.wikipedia.org/w/index.php?title=User:";
  var contribs = document.getElementById( 'pt-mycontris' );
  //Add the links
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=in", "In", "pt-status-in", "I'm in!", "");
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=busy", "Busy", "pt-status-busy", "I'm busy!", "");
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=out", "Out", "pt-status-out", "I'm out!", "");
  if (location.href.indexOf("&action=edit&newstatus=") == -1) return; //Are we here to auto-edit the status?
  //Get new status
  statusRegExp = /&action=edit&newstatus=(.*)/;
  status = statusRegExp.exec(location.href)[1];
  //Modify the form
  document.getElementById('wpTextbox1').value = "{{User:"+user+scheme+"|"+status+"}}";
  document.getElementById('wpSummary').value = "Status: "+status;
  document.getElementById('wpMinoredit').checked = 'checked';
  //Submit it!
  document.getElementById('editform').submit();
});

// 

//<pre><nowiki>
function toggle_undelete()
{
  var f = document.getElementById("undelete");
  if (f)
    {
      var inputs = f.getElementsByTagName("input");
      var i;
      for (i = 0; i < inputs.length; ++i)
        if (inputs[i].type == "checkbox")
          inputs[i].checked = !inputs[i].checked;
    }
}

function setup_toggle_undelete()
{
  if (wgPageName == "Special:Undelete")
    {
      var f = document.getElementById("undelete");
      if (f)
        {
          var h2 = f.getElementsByTagName("h2")[0];
          if (h2)
            {
              var button = document.createElement('input');
              button.type = "button";
              button.value = "Invert";
              button.setAttribute('onClick', 'toggle_undelete()');
              f.insertBefore(button, h2);
            }
        }
    }
}

addOnloadHook(setup_toggle_undelete);
//</nowiki></pre>

}
-->