Jump to content

User:Colin M/scripts/HideZeroSumEdits.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.
/* Mark watchlist entries with garish teal bg if:
- their net delta is 0
- they involve at least one edit tagged undo or rollback

Can also hide the entries entirely if desired (I'm using the colored bg for now for debugging)
*/
if (mw.config.values.wgCanonicalSpecialPageName === 'Watchlist') {
	const watchlist_container = document.querySelector('.mw-changeslist');
	const nulls = watchlist_container.querySelectorAll('tbody > tr.mw-tag-mw-undo:first-child .mw-plusminus-null,tbody > tr.mw-tag-mw-rollback:first-child .mw-plusminus-null');
	nulls.forEach(span => {
		const row = span.closest('table'); // neat
		row.style.backgroundColor = '#99ffee';
		// Alternatives...
		// Faded out
		//row.style.opacity = 0.5;
		// Hidden entirely
		//row.style.display = 'none';
	});
	console.log('Marked ', nulls.length, ' watchlist entries as zero-sum');
}