User:AstonishingTunesAdmirer/resize-covers.js

// I really don't like the default size of album covers function resizeCovers { const categories = [ { regEx: /\d{4}(\w|\s)*songs/g, type: "songs" }, { regEx: /\d{4}(\w|\s)*albums/g, type: "albums" }, { regEx: /\d{4}(\w|\s)*singles/g, type: "singles" }, { regEx: /\d{4}(\w|\s)*soundtracks/g, type: "soundtracks" }, { regEx: /\d{4}(\w|\s)*EPs/g, type: "EPs" }, { regEx: /\d{4}(\w|\s)*mixtape albums/g, type: "mixtape albums" } ];

$(".catlinks a").each(function(index, element) {   const string = $(element).text;    const matchingCategory = categories.find(({      regEx    }) => regEx.test(string));    if (matchingCategory) {      $(".infobox.vevent").find("a.mw-file-description,a.image").children("img").each(function { const img = $(this); const aspectRatio = img[0].naturalHeight / img[0].naturalWidth; if ((aspectRatio >= 0.95) && (aspectRatio <= 1.15)) { img.attr("src", function(i, e) {           return e.replace("/thumb", "")              .replace(/\.jpg\/\S*\.(jpg)/i, ".$1")              .replace(/\.jpeg\/\S*\.(jpeg)/i, ".$1")              .replace(/\.png\/\S*\.(png)/i, ".$1")              .replace(/\.gif\/\S*\.(gif)/i, ".$1")              .replace(/\.webp\/\S*\.(webp).png/i, ".$1")              .replace(/(.*wikipedia\/en\/)(.*\.svg)\/\S*\.png/i, "$1$2");          }).attr("width", 250).attr("height", 250);

if ($(img).is("[srcset]")) { img.attr("srcset", function(i, e) {             return e.replace("svg.png 2x", "svg.png 1x");            }) }       }      });    }  }); }

$(resizeCovers);