User:Rutilant/Sandbox/Qwatch.js

addOnloadHook(function { var one=document.getElementById("ca-unwatch"); var two=document.getElementById("ca-watch"); if (one!==null){ document.getElementById("ca-unwatch").innerHTML="Q.Unwatch"; }else{ document.getElementById("ca-watch").innerHTML="Q.Watch"; }});

function Watch{ var one1=document.getElementById("ca-unwatch"); $.ajax({		url: mw.util.wikiScript( 'api' ),		type: 'POST',		dataType: 'json',		data: {			format: 'json',			action: 'watch',			title: wgPageName,			token: mw.user.tokens.get( 'watchToken' )		}	}); mw.notify(wgPageName+' has been added to your watchlist.'); if (one1!==null){ document.getElementById("ca-unwatch").innerHTML="Q.Unwatch"; }else{ document.getElementById("ca-watch").innerHTML="Q.Unwatch"; }

}

function Unwatch{ var one2=document.getElementById("ca-unwatch"); $.ajax({		url: mw.util.wikiScript( 'api' ),		type: 'POST',		dataType: 'json',		data: {			format: 'json',			action: 'watch',			title: wgPageName,			unwatch:1,			token: mw.user.tokens.get( 'watchToken' )		}	}); mw.notify(wgPageName+' has been removed from your watchlist.'); if (one2!==null){ document.getElementById("ca-unwatch").innerHTML="Q.Watch"; }else{ document.getElementById("ca-watch").innerHTML="Q.Watch"; }}