document.querySelectorAll(".card__cover-container").forEach((picture) => {
const sources = picture.querySelectorAll("source");
const img = picture.querySelector("img");
sources.forEach((source) => {
source.srcset = source.srcset.replace(/width=\d+&height=\d+/g, (match) => {
const w = match.match(/width=(\d+)/)[1];
return `width=${w}&height=${w}`;
});
});
if (img) {
img.src = img.src.replace(
/width=(\d+)&height=\d+/,
(_, w) => `width=${w}&height=${w}`,
);
}
});