User:Blue/scripts/watchuser.js

From RationalWiki
Jump to navigation Jump to search

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

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
function watchuser() {
	if (wgPageName == "Special:RecentChanges") {
		if (window.XMLHttpRequest) {
			var req = new XMLHttpRequest();
		} else {
			var req = new ActiveXObject("Microsoft.XMLHTTP");
		}
		req.onreadystatechange = function() {
			if (req.readyState == 4 && req.status == 200) {
				var watchusers = req.responseText.split("\n");
				var reflinks = getElementsByClassName(document.getElementById('bodyContent'),"*","mw-userlink");
				for (var ref in reflinks) {
					if (watchusers.indexOf(reflinks[ref].innerHTML) > -1) reflinks[ref].style.fontWeight = "bold";
				}
			}
		}
		req.open("GET", wgServer + wgScriptPath + "/index.php?title=User:Blue/userstowatch&action=raw", true);
		req.send(null);
	}
}