Jump to content

User:Panamitsu/script/Watchlist User Mute.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.
// Mute a certain user from watchlist. Backlink: [[User:Panamitsu/script/watchlistmute.js]]

// NOTE: Future changes to the Wikipedia layout may break this script.

// Get username (WARNING: Document.currentScript does not work on Internet Explorer)
const USERNAME = new URLSearchParams(document.currentScript.src).get("username");

$( document ).ready( function () {
   // Make sure the watchlist is opened
   if (window.location.href.split('?')[0] == "https://en.wikipedia.org/wiki/Special:Watchlist") {
   	console.log("Blocking user " + USERNAME + " from the watchlist.");
      // Find user's contributions in watchlist, and hide them.
      bdiTags = document.getElementsByTagName("bdi");
      for (var i = bdiTags.length-1; i >= 0; i--) {
         var tag = bdiTags[i];
         if (tag.textContent.toLowerCase() == USERNAME.toLowerCase()) {
             tag.parentNode.parentNode.parentNode.remove();
         }
       } 
    }
} );