User:Panamitsu/script/Edit history user mute.js

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.
// Mute a certain user from a page's edit history.

// Get username (WARNING: Document.currentScript does not work on Internet Explorer)
// The odd variable name is to prevent name conflicts with other scripts.
const EDIT_HISTORY_USER_MUTE_USERNAME = new URLSearchParams(document.currentScript.src).get("username");

$( document ).ready( function () {
   // Make sure the edit history page is open
   if (mw.config.get('wgAction') == 'history') {
	   	console.log("Blocking user: " + EDIT_HISTORY_USER_MUTE_USERNAME);
	   	
    	// Find user's edits and hide them.
    	bdiTags = document.getElementsByTagName("bdi");
    	for (var i = bdiTags.length-1; i >= 0; i--) {
        	var tag = bdiTags[i];
        	if (tag.textContent.toLowerCase() == EDIT_HISTORY_USER_MUTE_USERNAME.toLowerCase()) {
            	tag.parentNode.parentNode.parentNode.style.display = "none";
        	}
    	} 
    }
} );