Skip to content

Commit

Permalink
moved code blocks around and added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicJinn committed Jul 5, 2023
1 parent 832a5db commit 1b2d110
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions mrbeastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -56,18 +62,12 @@ 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."
);
});
}

checkImageExistence();

// Get a random image URL from a directory
function getRandomImageFromDirectory() {
const randomIndex = Math.floor(Math.random() * images.length);
return images[randomIndex];
}
checkImageExistence();

0 comments on commit 1b2d110

Please sign in to comment.