Catatan: Setelah menyimpan, Anda harus memintas tembolok (cache) peramban Anda untuk melihat perubahannya. Google Chrome, Firefox, Microsoft Edge dan Safari: Tahan tombol Shift dan klik Muat ulang (Reload) di tombol bilah alat. Untuk detail dan instruksi tentang peramban lain, lihat halaman menghapus singgahan (Inggris).

/**
 * Instalasi:
 * 1. Buka [[Special:Mypage/vector.js]]
 * 2. Tambahkan kode `importScript("Pengguna:Kenrick95/online.js");`
 * 3. Simpan halaman
 * 
 * apparentlyOnline
 * - get RCFeed
 * - get list of admin
 * - see which admin is listed on RCFeed, report to a list, show as "apparently online"
 */
function apparentlyOnline() {
	var online_sysops = [], online_sysops_msg = "Tidak ada", last_seen = [];
	function loadNow() {
		mw.loader.using("mediawiki.api", function () {
			var api = new mw.Api();
			api.get({
				action: "query",
				list: "allusers|recentchanges",
				format: "json",
				rclimit: 500,
				rcprop: "user|userid|timestamp",
				rcshow: "!bot|!anon",
				augroup: "sysop",
				aulimit: 500
			})
			.done(function (data) {
				// console.log(data);
				var rc = data.query.recentchanges;
				var sysops = data.query.allusers;
				var is_sysop = {};
				for (var i = 0; i < sysops.length; i++) {
					is_sysop[sysops[i].userid] = true;
				}
				for (var i = 0; i < rc.length; i++) {
					if (is_sysop[rc[i].userid]) {
						if (online_sysops.indexOf(rc[i].user) < 0) {
							online_sysops.push(rc[i].user);
							last_seen.push(rc[i].timestamp);
						}
					}
				}
				// console.log(online_sysops);
				online_sysops_msg = "";
				if (online_sysops.length === 0) {
					online_sysops_msg = "Tidak ada";
				}
				for (var i = 0; i < online_sysops.length; i++) {
					var time = new Date(last_seen[i].timestamp);
					online_sysops_msg += "<li><a href=\"" + mw.config.get("wgServer") + "/wiki/User:" + online_sysops[i] + "\">"
						+ online_sysops[i]
						+ "</a>("
						+ time.toLocaleString()
						+ ")</li>";
				}
				document.getElementById("online_sysops_msg").innerHTML = online_sysops_msg;
			});
		});
	}
	var link = mw.util.addPortletLink(
		'p-cactions', //p-cactions, p-tb, p-views
		'#',
		'Pengurus daring',
		't-prettylinkwidget',
		'Perlihatkan daftar pengurus yang daring',
		null,
		'#t-whatlinkshere'
	);
	
	mw.loader.using('jquery.ui.dialog', function() {
		$dialog = $("<div></div>")
			.html("Pengurus yang daring berdasarkan 500 suntingan terakhir di perubahan terbaru:"
			+ "<br><div id=\"online_sysops_msg\">" + online_sysops_msg + "</div>")
			.dialog({
				autoOpen: false,
				title: "Pengurus Daring",
				width: '500px',
				modal: true
			});
	});
	$(link).click(function (e) {
		e.preventDefault();
		online_sysops_msg = "Memuat...";
		loadNow();
		$dialog.dialog("open");
	});
}

$(apparentlyOnline);