User:Tollens/subnetContribs.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$.when( mw.loader.using( ['mediawiki.util'] ), $.ready ).done( function() {
	var currentPage = mw.config.get("wgPageName");
	
	if (currentPage.startsWith("Special:Contributions/")) {
		var user = mw.config.get("wgRelevantUserName");
		
		if (mw.util.isIPv6Address(user)) {
			var fullAddition = document.createElement("span");
			var rangeLink = document.createElement("a");
			rangeLink.href = "https://en.wikipedia.org/wiki/" + currentPage + "/64";
			rangeLink.textContent = "/64";
			fullAddition.appendChild(document.createTextNode(" ("));
			fullAddition.appendChild(rangeLink);
			fullAddition.appendChild(document.createTextNode(")"));
			
			document.getElementById("firstHeading").appendChild(fullAddition);
		}
	}
});