User:Spang/autowatch.js

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes.

  • Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
  • Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
  • Opera, Konqueror and Safari users can just click the Reload button.
  • Chrome: press Ctrl+F5 or Shift+F5
function getXmlHttpObject(){var xmlHttp;try{xmlHttp=new XMLHttpRequest()}catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){xmlHttp=false}}};return xmlHttp};function changeTab(){if(xmlHttp.readyState<2){if(watchAction=='watch'){watchLink.innerHTML='watching...'}else if(watchAction=='unwatch'){watchLink.innerHTML='unwatching...'}};if(xmlHttp.readyState!=2)return;if(watchAction=='watch'){watchLink.innerHTML='unwatch';watchAction='unwatch'}else if(watchAction=='unwatch'){watchLink.innerHTML='watch';watchAction='watch'}};function setWatch(action){xmlHttp=getXmlHttpObject();if(xmlHttp==false)return;xmlHttp.onreadystatechange=changeTab;xmlHttp.open('GET','/index.php?title='+wgPageName+'&action='+action,true);xmlHttp.send(null)};function setWatchTab(){if(document.getElementById('ca-watch')||document.getElementById('ca-unwatch')){if(document.getElementById('ca-watch')){watchLink=document.getElementById('ca-watch').getElementsByTagName('a')[0];watchAction='watch'}else if(document.getElementById('ca-unwatch')){watchLink=document.getElementById('ca-unwatch').getElementsByTagName('a')[0];watchAction='unwatch'};watchUrl=watchLink.href;watchLink.href='javascript:setWatch(watchAction);'};window.removeEventListener("load",wgAjaxWatch.onLoad,false);if(window.addEventListener){window.removeEventListener("load",wgAjaxWatch.onLoad,false)}else if(window.attachEvent){window.detachEvent("onload",wgAjaxWatch.onLoad)}};YAHOO.util.Event.onDOMReady(setWatchTab);