User:Alexsanderson83/monobook.js

From Wikipedia, the free encyclopedia
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.
<source lang="javascript">
//Auto page watcher, activates the ajax-watch function after 1 second delay
//Note that a delay is required as the ajax watchlist setup script loads after addOnloadHooks.
//If you want to watch *all* namespaces, change wgNamespaceNumber==0 to wgNamespaceNumber!=-1

if(wgNamespaceNumber!=-1 addOnloadHook(function() {
  var foo = setTimeout('watchThis()',1000); //milliseconds. Increase if on a slow connection.
})
function watchThis() {
  var wli = document.getElementById('ca-watch');
  if(!wli) return;
  var wlink = wli.getElementsByTagName('a')[0];
  //we can't .click() an href, and the .onclick is a mess, so lets clone it
  var wbutt = document.createElement('button');
  wbutt.onclick = wlink.onclick;
  wbutt.style.display = 'none';
  wlink.parentNode.appendChild(wbutt);
  wbutt.click();
}
</source>