User:Ais523/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.
/* Link to [[User:Lupin/popups.js]] for tracking purposes
<!-- No longer using this // Link to [[user:Where/easy db]] for tracking purposes -->
<pre><nowiki>
*/
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 addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    return addlilink(tabs, url, name, id, title, key);
};
function showlimenu(id)
{
  document.getElementById("ais523_"+id).style.display="block";
}
function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = 'javascript:showlimenu("'+id+'")';
    var mn = document.createElement('ul');
    if(id) mn.id = 'ais523_'+id;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}
 
 
// test
//addOnloadHook(function() {
//addTab("javascript:alert('This is a test');","test","ca-testing","Testing tab","");
//});
 
/* Based on [[User:Misza13/Scripts/Status switcher]], but performing quite a different function (that of conditionally including the popup script) */
addOnloadHook(function (){
  var user = document.getElementById( 'pt-userpage' ).firstChild.firstChild.data;
  var subpage = '/monobook.js/popupson.js';
  var linkprefix = "http://en.wikipedia.org/w/index.php?title=User:";
  var contribs = document.getElementById( 'pt-mycontris' );
  var commontext =
"if(ais523_popupson)"+
"  document.write('<s"+"cript type="+'"'+"text/javascript"+'"'+" src="+'"'+"' "+
"               + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' "+
"               + '&action=raw&ctype=text/javascript&dontcountme=s"+'"'+"></s"+"cript>');"+
"else"+
"  document.write('<s"+"cript type="+'"'+"text/javascript"+'"'+" src="+'"'+"' "+
"               + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/autoedit.js' "+
"               + '&action=raw&ctype=text/javascript&dontcountme=s"+'"'+"></s"+"cript>');";
  //Add the links
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&ais523autoedit=true", "popups on/off", "pt-popup-toggle", "Switch popups on or off.", "");
  if (location.href.indexOf("&action=edit&ais523autoedit=true") == -1) return; //Are we here to auto-edit the status?
  //Get new status
  //Modify the form
  if(document.getElementById('wpTextbox1').value.indexOf("_popupson=1") != -1)
    document.getElementById('wpTextbox1').value = "var ais523_popupson=0;"+commontext;
  else
    document.getElementById('wpTextbox1').value = "var ais523_popupson=1;"+commontext;
  document.getElementById('wpSummary').value = "Toggling use of popups";
  document.getElementById('wpMinoredit').checked = 'checked';
  //Submit it!
  document.getElementById('editform').submit();
});
 
//Autopurge. I wrote this one.
addOnloadHook(function() {
if(location.href=="http://en.wikipedia.org/wiki/User:Ais523" || location.href=="http://en.wikipedia.org/wiki/User:ais523") location.href="http://en.wikipedia.org/w/index.php?title=User:Ais523&action=purge";
});
//This could also be applied to other pages.
 
//My edit counter, development version
if(!window.navigator||!window.navigator.userAgent||window.navigator.userAgent.indexOf("Mozilla")==-1||window.navigator.userAgent.indexOf("rv:1.4")==-1)
document.write('<sc'+'ript type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?'
             + 'title=User:ais523/editcountdev.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s"></scr'+'ipt>');
 
/* This was only a temporary script; I'll uncomment it if I need to use it again.
//Per [[WP:AN]] revision 67651803, making a script to remove the ezproxy link from pages
addOnloadHook(function() {
if(location.href.indexOf('action=edit')!=-1)
  addTab("javascript:removeEZ();","rem ez","ca-rmez","Remove ezproxy references","");
});
 
function removeEZ()
{
  document.editform.wpTextbox1.value=document.editform.wpTextbox1.value.
    split('ezproxy.auckland.ac.nz').join('');
  document.editform.wpSummary.value='Repaired external link proxy rewrites using'+
    '[[WP:US|user scripts]]';
  document.editform.wpDiff.click(); //to check
}
*/
 
// AfD decatting
addOnloadHook(function() {
if(location.href.indexOf('afddecat=Y')!=-1)
{
  if(document.editform.wpTextbox1.value.indexOf(
     'The following discussion is an archived debate of the proposed deletion of '+
     'the article below.')==-1) {window.close(); return;} //still open
  document.editform.wpTextbox1.value=document.editform.wpTextbox1.value.
    split("{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD|").join("{{ns:0|");
  document.editform.wpMinoredit.checked='checked';
  document.editform.wpSummary.value="Removing category from closed AfD (using [[WP:US|user scripts]])";
  document.editform.wpDiff.click(); //just testing for now
}
});
 
//test
/*addOnloadHook(function() {
  var i;
  if(location.href.indexOf('action=edit')!=-1)
  {
    if(document.editform.wpTextbox1.value.indexOf(
      'The following discussion is an archived debate of the proposed deletion of '+
      'the article below.')==-1) {i=1; return;}
    alert("This AfD is closed.");
  }
});*/
 
//Conditional inclusion of popups (these are a prereq for the easytag script)
document.write('<sc'+'ript type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:ais523/monobook.js/popupson.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></scr'+'ipt>');
 
//Title override
addOnloadHook(function() {
  if(document.getElementById('titleOverride')!=null)
  {
    var h1s=document.body.getElementsByTagName("h1");
    var i;
    for(i in h1s)
      if(h1s[i].className=="firstHeading")
        h1s[i].replaceChild(document.getElementById('titleOverride').firstChild,
                            h1s[i].firstChild);
  }
});
 
//Give bodyContent a class
addOnloadHook(function() {document.getElementById('bodyContent').className="bodyContentClass";});
 
//A script by [[User:Gracenotes]] to allow longer edit summaries
addOnloadHook(function() {
    var sumBox;
    if (sumBox = document.getElementById('wpSummary'))
        sumBox.setAttribute("maxlength", "250");
});
 
/*
</nowiki></pre>
*/
 
importScript('User:Ais523/votesymbols.js'); //[[User:Ais523/votesymbols.js]]
importScript('User:Ais523/topcontrib.js'); //[[User:Ais523/topcontrib.js]]
importScript('User:Ais523/contribcalendar.js'); //[[User:Ais523/contribcalendar.js]]
importScript('User:Ais523/highlightmyname2.js'); //[[User:Ais523/highlightmyname2.js]]
importScript('User:Ais523/catwatch.js'); //[[User:Ais523/catwatch.js]]
importScript('User:Ais523/sandbox.js'); //[[User:Ais523/sandbox.js]]
importScript('User:Ais523/watchlistnotifier.js'); //[[User:Ais523/watchlistnotifier.js]]
importScript('User:Ais523/adminrights.js'); //[[User:Ais523/adminrights.js]]
importScript('User:Ais523/stubtagtab2.js'); //[[User:Ais523/stubtagtab2.js]]
importScript('User:Ais523/editsection0tab.js'); //[[User:Ais523/editsection0tab.js]]
importScript('User:Ais523/bracketmatch.js'); //[[User:Ais523/bracketmatch.js]]