Jump to content

User:Ais523/sandbox.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ais523 (talk | contribs) at 10:50, 2 November 2007 (readystate check). 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.
/* Script to warn you if your userpage is changed by another user. By [[User:ais53]]. Note that the message persists until you edit
   your userpage yourself. */

function upm_checkthisisme(xmlreq)
{
  var junk;
  try
  {
    var ed=xmlreq.responseText.split('<rev user="')[1].split('"')[0];
    if(ed!=wgUserName) document.getElementById('siteSub').innerHTML+="<div class='usermessage'>Your userpage was changed by "+
      "<a href='/wiki/User:"+encodeURI(ed)+"'>"+ed.split('<').join('&lt;').split('>').join('&gt;').split('&').join('&amp;')+"</a>"+
      " (<a href='/wiki/Special:Mypage'>your userpage</a>, <a href='/w/index.php?title=User:"+encodeURI(wgUserName)+"&diff=last'>"+ 
      "last change</a>)";
  } catch(junk) {};
}

addOnloadHook(function(){
  var a = sajax_init_object();
  a.open('GET', wgServer+wgScriptPath+'/api.php?action=query&prop=revisions&titles=User:'+
    encodeURI(wgUserName)+'&rvlimit=1&rvprop=user&format=xml');
  a.send('');
  a.onreadystatechange = function(){if(a.readystate==4) upm_checkthisisme(a)};
});