Jump to content

User:Maxim's JS test account/monobook.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Maxim's JS test account (talk | contribs) at 13:55, 11 August 2007 (....). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
function ecAddLILink(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 ecAddTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    return ecAddLILink(tabs, url, name, id, title, key)
}
 
var aecwpajax;
// From [[WP:US]] mainpage (wpajax renamed to aecwpajax), some comments removed
aecwpajax={
        download:function(bundle) {
                var x = window.XMLHttpRequest ? new XMLHttpRequest()
                : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
                : false;
 
                if (x) {
                        x.onreadystatechange=function() {
                                x.readyState==4 && aecwpajax.downloadComplete(x,bundle);
                        };
                        x.open("GET",bundle.url,true);
                        x.send(null); 
                }
                return x;
        },
 
        downloadComplete:function(x,bundle) {
                x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true )
                || ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText));
        }
};
 
function ecQuickCountComplete(xmlreq,data)
{
  alert("Edit count: "+xmlreq.responseText.split("<count>")[1].split("</count>")[0]);
}
 
addOnloadHook(function() {
  if(location.href.indexOf("Special")!=-1&&location.href.indexOf("Contributions")!=-1)
    ecAddTab("javascript:ais523quickcount()","quick count","ca-ais523qc","Quick Count","");
});
 
function ais523quickcount()
{
  var trg;
  trg=ecGetParamValue('target');
  if(trg==null) trg=location.href.substr(location.href.lastIndexOf("/")+1);
  aecwpajax.download({url:'http://en.wikipedia.org/w/query.php?what=contribcounter&'+
    'titles=User:'+encodeURIComponent(trg)+'&format=xml', onSuccess:ecQuickCountComplete});
}
 
addOnloadHook(function() {
  if(location.href.indexOf("Special")!=-1&&location.href.indexOf("Contributions")!=-1)
    ecAddTab("javascript:ais523contrib()","count","ca-ais523count","Count","");
});