User:PhantomTech/scripts/PhantomBotMonitor.js

// This script notifies users if a PhantomBot (User:ThePhantomBot) page has been updated, // similar to how you are notified of new talk page messages. // To get notifications, the page must be on your watchlist and in the watchPages list

// This script is a modified version of a script by User:APerson // The original script is at testwiki:User:APerson/watchlist-box.js // Authors: APerson, PhantomTech mw.loader.using( 'mediawiki.util', function {	var watchPages = ["User:ThePhantomBot/log", "User:ThePhantomBot/Bot notice", "User:ThePhantomBot"];	var showNotice = function {		// Adds update notification		$("#pt-notifications").after( $("").append($("")       		.text("!")        		.css({ "background-color": "green", "color": "white", "border-radius": "2px", "padding": "0.25em 0.45em 0.2em", "cursor": "pointer", "font-weight": "bold" })       		.attr("href", "/wiki/Special:Watchlist")        	) );	};   $(document).ready( function  { $.getJSON(   		mw.util.wikiScript('api'),    		{    			format: "json",    			action: "query",    			list: "watchlist",    			wlshow: "unread",    			continue: "",    			wllimit: 50     		}).done(function(data) {    			if(!data.query) return;    			hasUpdates = false;    			for (i = 0; i < data.query.watchlist.length; i++) {    				if ($.inArray(data.query.watchlist[i].title, watchPages) != -1) {    					hasUpdates = true;    					break;    				}    			}    			//Checks 500 more entries if an update wasn't in the first 50    			if (!hasUpdates && data.query.watchlist.length == 50) {		    		$.getJSON(mw.util.wikiScript('api'), {		   			format: "json", action: "query", list: "watchlist", wlshow: "unread", wlcontinue: data.query.continue.wlcontinue, continue: "", wllimit: 500 }).done(function(data2) { if(!data2.query) return; for (i = 0; i < data2.query.watchlist.length; i++) { if ($.inArray(data2.query.watchlist[i].title, watchPages) != -1) { hasUpdates = true; break; }		   			}		    		});    			}    			if (hasUpdates == true) {    				showNotice;    			}    		}); } ); } );