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.
// This is a very epic script.
// What it does is give you two buttons at the top of the page, which let you:
// a) format all timestamps on the page to color-code by how recent they are
// b) remove all timestamps altogether.
// - JPxG, 2021 08 31
$( function() {
	
	timestampTextColor = "#00141a";
	
	ranges = [];			// Range of dates to measure
	ranges.push(0);         // <30m
	ranges.push(1800000);      // 30m
	ranges.push(3600000);      // 1h
	ranges.push(7200000);      // 2h
	ranges.push(10800000);     // 3h
	ranges.push(14400000);     // 4h
	ranges.push(18000000);     // 5h
	ranges.push(21600000);     // 6h
	ranges.push(43200000);     // 12h
	ranges.push(64800000);     // 18h
	ranges.push(86400000);     // 24h
	ranges.push(129600000);    // 36h
	ranges.push(172800000);    // 2d
	ranges.push(259200000);    // 3d
	ranges.push(345600000);    // 4d
	ranges.push(432000000);    // 5d
	ranges.push(518400000);    // 6d
	ranges.push(604800000);    // 1w
	ranges.push(1209600000);   // 2w
	ranges.push(1814400000);   // 3w
	ranges.push(2592000000);   // 1m
	ranges.push(5184000000);   // 2m
	ranges.push(7776000000);   // 3m
	ranges.push(10368000000);  // 4m
	ranges.push(12960000000);  // 5m
	ranges.push(15552000000);  // 6m
	ranges.push(31536000000);  // 1y
	ranges.push(63072000000);  // 2y
	ranges.push(94608000000);  // 3y
	ranges.push(126144000000); // 4y

	// Color range is as follows, using the Solarized palette:
	// 1-15:   LCH gradient from #d33682 (magenta) to #b58900 (yellow)
	// 15-30:  RGB gradient from #b58900 (yellow)  to #2aa198 (cyan)
	colors = [];
	colors.push("#d33682");  // <30m
	colors.push("#d83778");  // 30m
	colors.push("#dc396e");  // 1h
	colors.push("#df3e64");  // 2h
	colors.push("#e0435a");  // 3h
	colors.push("#e04950");  // 4h
	colors.push("#df5046");  // 5h
	colors.push("#dd583d");  // 6h
	colors.push("#d95f34");  // 12h
	colors.push("#d5662b");  // 18h
	colors.push("#d06e22");  // 24h
	colors.push("#cb7519");  // 36h
	colors.push("#c47c10");  // 2d
	colors.push("#bd8306");  // 3d
	colors.push("#b58900");  // 4d
	colors.push("#ac8b0a");  // 5d
	colors.push("#a28c14");  // 6d
	colors.push("#998e1e");  // 1w
	colors.push("#908f29");  // 2w
	colors.push("#879133");  // 3w
	colors.push("#7d933d");  // 1m
	colors.push("#749447");  // 2m
	colors.push("#6b9651");  // 3m
	colors.push("#62975b");  // 4m
	colors.push("#589965");  // 5m
	colors.push("#4f9b6f");  // 6m
	colors.push("#469c7a");  // 1y
	colors.push("#3d9e84");  // 2y
	colors.push("#339f8e");  // 3y
	colors.push("#2aa198");  // 4y
	
	backgroundcolor = getComputedStyle(document.getElementsByClassName("mw-parser-output")[0])['background-color']

	if( (window.location.href.indexOf("alk:" ) >= 0 ) || ( window.location.href.indexOf("Wikipedia:" ) >= 0 )) {
		$('#firstHeading').append('&nbsp;&nbsp;<small><small>shade:</small></small>&nbsp;<button id="shadeTimes">recent</button>');
		$('#firstHeading').append('&nbsp;&nbsp;<button id="shadeRemove">remove</button>');
		document.getElementById("shadeTimes").style = "font-family: monospace; font-size: 50%; padding: 1px; border: 1px; background:#B58900; color:#002b36";
		document.getElementById("shadeRemove").style = "font-family: monospace; font-size: 50%; padding: 1px; border: 1px; background:#B58900; color:#002b36";
		
		function getAllComments() {

			
			//document.querySelectorAll('h2')[7].innerHTML
				// "<span class=\"mw-headline\" id=\"Poggers\" data-mw-comment=\"{&quot;type&quot;:&quot;heading&quot;,&quot;level&quot;:0,&quot;id&quot;:&quot;h-Poggers-2021-12-01T10:01:00.000Z&quot;,&quot;replies&quot;:[&quot;c-Example-2021-12-01T10:01:00.000Z-Poggers&quot;],&quot;headingLevel&quot;:2,&quot;placeholderHeading&quot;:false}\"><span data-mw-comment-start=\"\" id=\"h-Poggers-2021-12-01T10:01:00.000Z\"></span>Poggers<span data-mw-comment-end=\"h-Poggers-2021-12-01T10:01:00.000Z\"></span></span><span class=\"mw-editsection\"><span class=\"mw-editsection-bracket\">[</span><a href=\"/w/index.php?title=User_talk:JPxG/Test_page&amp;action=edit&amp;section=7\" title=\"Edit section: Poggers\">edit</a><span class=\"mw-editsection-bracket\">]</span></span><!--__DTSUBSCRIBE__h-Example-2021-12-01T10:01:00.000Z--> <div style=\"font-size: 0.6em; font-weight: bold; float: right;\"> | <a id=\"7\" href=\"#archiverLink\" class=\"archiverLink\" title=\"Archive to: &quot;User talk:JPxG/Archive 1&quot;\">Archive</a></div>"
			//document.querySelectorAll('p')[18].innerHTML 
				// "<span data-mw-comment-start=\"\" id=\"c-Example-2021-12-01T10:01:00.000Z-Poggers\"></span>Comment. <a href=\"/wiki/User:Example\" title=\"User:Example\" class=\"userlink\">Example</a> (<a href=\"/wiki/User_talk:Example\" title=\"User talk:Example\" class=\"userlink\">talk</a><span class=\"before-localcomments\">) </span><span class=\"localcomments\" style=\"font-size: 95%; white-space: nowrap;\" timestamp=\"1638352886527\" title=\"10:01, 1 December 2021 (UTC)\">2:01 am, 1 December 2021, Wednesday (10 days ago) (UTC−8)</span><span class=\"after-localcomments\"></span><span class=\"ext-discussiontools-init-replylink-buttons\"><span class=\"ext-discussiontools-init-replylink-bracket\"><!--__DTREPLYBRACKETOPEN__--></span><a class=\"ext-discussiontools-init-replylink-reply\" role=\"button\" tabindex=\"0\" data-mw-comment=\"{&quot;type&quot;:&quot;comment&quot;,&quot;level&quot;:1,&quot;id&quot;:&quot;c-Example-2021-12-01T10:01:00.000Z-Poggers&quot;,&quot;replies&quot;:[&quot;c-Example2-2021-12-02T10:01:00.000Z-Example-2021-12-01T10:01:00.000Z&quot;],&quot;timestamp&quot;:&quot;2021-12-01T10:01:00.000Z&quot;,&quot;author&quot;:&quot;Example&quot;}\" href=\"\"><!--__DTREPLY__--></a><span class=\"ext-discussiontools-init-replylink-bracket\"><!--__DTREPLYBRACKETCLOSE__--></span></span><span data-mw-comment-end=\"c-Example-2021-12-01T10:01:00.000Z-Poggers\"></span>\n"
			// document.querySelectorAll('p')[18].parentElement		
				
				
		}
		
		
		$('#shadeTimes').click(function(e) {
			//alert("Clicked");
			console.log("Recents clicked");
		//	allComms = document.querySelectorAll('p');
		//	for (var c in allComms) {
		//		c.getElementsByTagName('span')[0].id
		//		// "c-221.118.156.36-2021-11-18T11:53:00.000Z-Simp"
		//	} // For all comments (i.e. <p>s).
			tsNow = Date.now()
			len = document.getElementsByClassName('localcomments').length;
			console.log(len);
			for (var i = 0; i < len; i++) {
				ts = Date.parse(document.getElementsByClassName('localcomments')[i].title)
				ts = parseInt(ts)
				console.log(ts);
				console.log(tsNow);
				
				for (var j = 0; j < ranges.length; j++) {
					if((tsNow - ts) > ranges[j]) {
						document.getElementsByClassName('localcomments')[i].style.backgroundColor = colors[j];
						//k = j + 15; 	if (k >= colors.length) { k = (k - colors.length); }
						//document.getElementsByClassName('localcomments')[i].style.color = colors[k]
						// Experimental thing that auto-selects a color distant from the background.
						document.getElementsByClassName('localcomments')[i].style.color = timestampTextColor;
						
					} // Set to whatever the color is for that range.
				} // Loop over all of the ranges.
			//	if((tsNow - ts) > 86400) {
			//		console.log("Older than a day.")
			//		document.getElementsByClassName('localcomments')[i].style.backgroundColor = "red";
			//	} // Test loop: if over 86400
				
			} // Simpler loop, with an increment, I suppose.
		}); // End of button listener.
		
		$('#shadeRemove').click(function(e) {
			//alert("Clicked");
			console.log("Remove clicked");
			tsNow = Date.now()
			len = document.getElementsByClassName('localcomments').length;
			console.log(len);
			for (var i = 0; i < len; i++) {
				ts = Date.parse(document.getElementsByClassName('localcomments')[i].title)
				ts = parseInt(ts)
				console.log(ts);
				console.log(tsNow);
				
				for (var j = 0; j < ranges.length; j++) {
					if((tsNow - ts) > ranges[j]) {
						document.getElementsByClassName('localcomments')[i].style = "display: none;";
					}
				} // Loop over all of the ranges.
			} // Simpler loop, with an increment, I suppose.
		}); // End of button listener.
	} // Add buttons and listeners if it's a talk page or a project page.
} ); // End of the line. That's all folks!