move the snippet into a fn
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-24 15:59:29 +02:00
parent cfb21e7dcb
commit 40f038bfb9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,3 +1,6 @@
window.addEventListener("load", () => main());
const main = () => {
for (const item of document.getElementsByTagName("img")) {
// Check if we may need to resize the image
const possible_piece = item.alt.split(/\s?\|\s?/);
@ -19,7 +22,9 @@ for (const item of document.getElementsByTagName("img")) {
verif[1] == "x" &&
verif[2] == ""
) {
[item.width, item.height] = last_possible_piece.split("x");
[w, h] = last_possible_piece.split("x");
item.width = w;
item.height = h;
item.alt = possible_piece.join("");
}
} else {
@ -31,3 +36,4 @@ for (const item of document.getElementsByTagName("img")) {
}
}
}
};