Wikipedia:WikiProject User scripts/Scripts/Unwatch

This is an old revision of this page, as edited by Jnothman (talk | contribs) at 00:23, 5 January 2006 (fix syntax). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

// Add Unwatch to watch list
// from [[User:Matthewmayer/monobook.js]]
addOnloadHook( function () {
   if (window.___location.href.indexOf("Special:Watchlist")!=-1) {
      //correct page, so retrieve watchlist items
      var items=document.getElementById('bodyContent').getElementsByTagName('li');
      for (var i=0;i<items.length;i++) {
            //what is the title of this page?
            pagename=items[i].getElementsByTagName('a')[0].title;
            //create 'unwatch' element
            unwatchelt=document.createElement('a');
            unwatchelt.setAttribute('href','/w/index.php?title='+pagename+'&action=unwatch');
            unwatchelt.setAttribute('title','Unwatch '+pagename);
            unwatchelt.appendChild(document.createTextNode('(unwatch)'));
            //add the 'unwatch' element
            items[i].appendChild(unwatchelt);
      }
    }
 }
);