Jump to content

User:Elsendero/uwlmodified.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Elsendero (talk | contribs) at 07:17, 7 April 2008. 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.
// test mod version of Tra script


function uwdownload(bundle) {
  // mandatory: bundle.url
  // optional:  bundle.onSuccess (xmlhttprequest, bundle)
  // optional:  bundle.onFailure (xmlhttprequest, bundle)
  // optional:  bundle.otherStuff OK too, passed to onSuccess and onFailure

  var x = window.XMLHttpRequest ? new XMLHttpRequest()
	: window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
	: false;

  if (x) {
    x.onreadystatechange=function() {
    if ( x.readyState==4 ) { uwdownloadComplete(x,bundle); }
    };
    x.open("GET",bundle.url,true);
    x.send(null);
  }
  return x; 
}

function uwdownloadComplete(x,bundle) {
  if (x.status==200) { bundle.onSuccess(x,bundle); } else { bundle.onFailure(x,bundle); alert(x.statusText);}
}



function uwgetstartdate(uwdate) {

  var tempvar = ''

  if (navigator.userAgent.indexOf("Firefox")!=-1){
    tempvar = uwdate.getYear() + 1900
  } else {
    tempvar = uwdate.getYear()
  }

  tempvar += ''

  if ((uwdate.getMonth() + 1) < 10 ) {
    tempvar += '0'
  }

  tempvar += (uwdate.getMonth() + 1)

  tempvar += ''

  if (uwdate.getDate() < 10 ) {
    tempvar += '0'
  }

  tempvar += (uwdate.getDate() - 1) // mod

  tempvar += '000000'

  return tempvar

}



window.gettingWatchlist=false;
uwwatchlist=null;
function uwgetWatchlist() {


  window.gettingWatchlist=true;
  uwdownload({url: 'http://' + document.location.hostname + '/wiki/Special:Watchlist?action=raw',
	      onSuccess: uwprocessWatchlist, onFailure: function () {
 setTimeout(uwgetWatchlist, 15000); return true; }});
}
function uwprocessWatchlist(req, bundle) {

  var watchlist={};
  var lines=req.responseText.split('\n');

  var h1=document.getElementsByTagName('h1')[0]
  var myinfo=document.createElement('ul');
  h1.parentNode.appendChild(myinfo);

  var uwnspg = ''
  var uwinlist = 'no'
  var uwpropline = ''
  var uwdonestart = 'no'
  var uwquerystring = ''
  var uwcountusers = 0

  var uwnow = new Date()




  var h1=document.getElementsByTagName('h1')[0]
  var uwoutput=document.createElement('div');
  h1.parentNode.appendChild(uwoutput);

  uwoutput.innerHTML = '';

  for (var i=0; i<lines.length; ++i) {
//myinfo.innerHTML += 'one'
if (lines[i].indexOf('<textarea') > -1) { uwinlist = 'yes'; }
if (lines[i].indexOf('</textarea') > -1) { uwinlist = 'no'; }

    if (uwinlist == 'yes') {
      uwpropline = lines[i];
      uwnspg=uwpropline.split(':');

      // eliminate all but user or user talk pages
      if ((uwnspg[0] == 'User' || uwnspg[0] == 'User talk') && uwpropline.split('/')[0]==uwpropline && uwcountusers <25) {

        if (uwdonestart == 'yes') {uwquerystring += '|'}
        uwdonestart = 'yes'

        uwquerystring += 'User:' + uwnspg[1]
        uwcountusers += 1

        if (uwcountusers == 25) {

          //send and process stuff

            uwquerystring += '&uclimit=20&ucstart=' + uwgetstartdate(uwnow) + '&uccomments&format=json&dummy=' + parseInt(Math.random()*99999999)



//myinfo.innerHTML += ('http://' + document.location.hostname + '/w/query.php?what=usercontribs&titles=' + uwquerystring + '<b>stop</b>');
            uwdownload({url: 'http://' + document.location.hostname + '/w/query.php?what=usercontribs&titles=' + uwquerystring,
	      onSuccess: function (req, bundle) {  uwoutput.innerHTML += uwprocessuserwatchlist(req.responseText) ;   if (typeof(window.setupTooltips)!='undefined') { setupTooltips(uwoutput); } }});

            uwcountusers = 0
            uwquerystring = ''
            uwdonestart = 'no'

        }





      }      
    }
  }

  uwquerystring += '&uclimit=20&ucstart=' + uwgetstartdate(uwnow) + '&uccomments&format=json&dummy=' + parseInt(Math.random()*99999999)
  // myinfo.innerHTML += '<li>' + uwquerystring + '</li>'

//myinfo.innerHTML += ('http://' + document.location.hostname + '/w/query.php?what=usercontribs&titles=' + uwquerystring);

//if (uwcountusers == 25) {myinfo.innerHTML += 'For performance reasons, only the first 25 users on your watchlist are shown.';}

  uwdownload({url: 'http://' + document.location.hostname + '/w/query.php?what=usercontribs&titles=' +