From 1b2d1107560c901297823421f9c8acf8f6ddf828 Mon Sep 17 00:00:00 2001 From: MagicJinn Date: Wed, 5 Jul 2023 15:38:31 +0200 Subject: [PATCH] moved code blocks around and added comments --- mrbeastify.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mrbeastify.js b/mrbeastify.js index c3bd8b2..2c2b882 100644 --- a/mrbeastify.js +++ b/mrbeastify.js @@ -46,8 +46,14 @@ function applyOverlayToThumbnails() { }); } +// Get a random image URL from a directory +function getRandomImageFromDirectory() { + const randomIndex = Math.floor(Math.random() * images.length); + return images[randomIndex]; +} + +// Checks for all images in the images folder instead of using a preset array, making the extension infinitely scalable function checkImageExistence(index = 1) { - // Checks for all images in the images folder instead of using a preset array, making the extension infinitely scalable const testedURL = chrome.runtime.getURL(`${imagesPath}${index}.png`); fetch(testedURL) .then((response) => { @@ -56,7 +62,7 @@ function checkImageExistence(index = 1) { // Check the next image in the directory checkImageExistence(index + 1); }) - .catch((error) => { + .catch((error) => { // The function encountered a missing image. Start applying overlays setInterval(applyOverlayToThumbnails, 100); console.log( "MrBeastify Loaded Successfully, " + (index - 1) + " images detected." @@ -64,10 +70,4 @@ function checkImageExistence(index = 1) { }); } -checkImageExistence(); - -// Get a random image URL from a directory -function getRandomImageFromDirectory() { - const randomIndex = Math.floor(Math.random() * images.length); - return images[randomIndex]; -} \ No newline at end of file +checkImageExistence(); \ No newline at end of file