Changes

Jump to navigation Jump to search
3,337 bytes added ,  00:32, September 1, 2007
m
no edit summary
Line 1: Line 1: −
// document.write('<SCRIPT SRC="http://sam.zoy.org/wikipedia/godmode-light.js"><\/SCRIPT>');
  −
   
//<pre>
 
//<pre>
   Line 60: Line 58:     
//</pre>
 
//</pre>
 +
 +
/* Watchlist notifier ([[User:Ais523/watchlistnotifier.js]]); displays a message every time a watched page changes. */
 +
//<pre><nowiki>
 +
 +
var wmwpajax;
 +
// From [[WP:US]] mainpage (wpajax renamed to wmwpajax)
 +
wmwpajax={
 +
        download:function(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() {
 +
                                x.readyState==4 && wmwpajax.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+': '+bundle.url));
 +
        }
 +
};
 +
 +
// Example:
 +
// function dlComplete(xmlreq, data) {
 +
//      alert(data.message + xmlreq.responseText);
 +
// }
 +
//  wmwpajax.download({url:'http://en.wikipedia.org/w/index.php?title=Thresher&action=raw',
 +
//                  onSuccess: dlComplete, message: "Here's what we got:\n\n" });
 +
 +
// End of [[WP:US]] quote
 +
 +
function wmWatchEditFound(xmlreq, data) {
 +
  var watchrev, watchsum, watchrevold, watchpage, junk;
 +
  watchrev=xmlreq.responseText.split('timestamp="')[1].split('"')[0];
 +
  if(wgPageName == "Special:Watchlist")
 +
    document.cookie="ais523wmwatchrev="+watchrev+".; path=/";
 +
  else
 +
  {
 +
    watchsum=xmlreq.responseText.split('comment="')[1].split('"')[0];
 +
    watchpage=xmlreq.responseText.split('title="')[1].split('"')[0];
 +
    try
 +
    {
 +
      watchrevold=document.cookie.split('ais523wmwatchrev=')[1].split('.')[0];
 +
    }
 +
    catch(junk) {watchrevold=0;}
 +
    watchsum=watchsum.split('<').join('&lt;').split('>').join('&gt;');
 +
    watchpage=watchpage.split('<').join('&lt;').split('>').join('&gt;');
 +
    if(watchrev!=watchrevold)
 +
      document.getElementById('contentSub').innerHTML+=
 +
        "<div class='watchlistnotify'>\""+watchpage+'" changed: "'+watchsum+'".</div>';
 +
  }
 +
}
 +
 +
addOnloadHook(function() {
 +
  /* Find the top item in the watchlist, and its edit summary. We only need one item, so
 +
    set the limit to 1 to ease the load on the server. */
 +
  //if(location.href.indexOf("/wiki/")!=-1)
 +
    wmwpajax.download({url:'http://en.wikipedia.org/w/api.php?action=query&list=watchlist&wllimit=1&'+
 +
      'wldir=older&format=xml&wlprop=comment|timestamp|title', onSuccess: wmWatchEditFound});
 +
});
 +
// </nowiki></pre>
 +
 +
if (wgCanonicalSpecialPageName && wgCanonicalSpecialPageName=='Watchlist' && wgAction=='view')
 +
addOnloadHook(function () {
 +
var frm = document.getElementsByTagName('form')[0];
 +
frm.parentNode.insertBefore(document.createTextNode(' | '), frm);
 +
var lnk = document.createElement('a');
 +
lnk.appendChild(document.createTextNode('Unwatch…'));
 +
lnk.href = 'javascript:importScript("User:Alex_Smotrov/wlunwatch.js")';
 +
frm.parentNode.insertBefore(lnk, frm);
 +
})
708

edits

Navigation menu