Skip to content

Commit

Permalink
Merge pull request #59 from MagicJinn/58-endscreen-images-are-not-aff…
Browse files Browse the repository at this point in the history
…ected-by-flip-percentage

58 endscreen images are not affected by flip percentage
  • Loading branch information
MagicJinn authored Jul 1, 2024
2 parents 56fcd72 + 7c2c8ee commit 505938a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion manifest v3.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "YouTube MrBeastify",
"version": "1.6.2",
"version": "1.7.0",
"icons": {
"96": "icon.png"
},
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "YouTube MrBeastify",
"version": "1.6.2",
"version": "1.7.0",
"icons": {
"96": "icon.png"
},
Expand Down
27 changes: 15 additions & 12 deletions mrbeastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const imagesPath = "images/";
var useAlternativeImages
var flipBlacklist // Stores flipBlackList.js
var blacklistStatus
var extensionName = chrome.runtime.getManifest().name;

// Config
var extensionIsDisabled = false
Expand All @@ -12,6 +13,7 @@ var flipChance = 0.25//%
function applyOverlay(thumbnailElement, overlayImageURL, flip = false) {
// Create a new img element for the overlay
const overlayImage = document.createElement("img");
overlayImage.id = extensionName;
overlayImage.src = overlayImageURL;
overlayImage.style.position = "absolute";
overlayImage.style.top = overlayImage.style.left = "50%";
Expand All @@ -22,7 +24,7 @@ function applyOverlay(thumbnailElement, overlayImageURL, flip = false) {
};

function FindThumbnails() {
var thumbnailImages = document.querySelectorAll("ytd-thumbnail:not(.ytd-video-preview, .ytd-rich-grid-slim-media) a > yt-image > img.yt-core-image:only-child:not(.yt-core-attributed-string__image-element)");
var thumbnailImages = document.querySelectorAll("ytd-thumbnail a > yt-image > img.yt-core-image");
var notificationImages = document.querySelectorAll('img.style-scope.yt-img-shadow[width="86"]');

const allImages = [ // Put all the selected images into an array
Expand All @@ -46,7 +48,7 @@ function FindThumbnails() {
});

// Select all images from the recommended video screen
var videowallImages = document.querySelectorAll(".ytp-videowall-still-image:not([style*='extension:'])"); // Because youtube video wall images are not properly classified as images
var videowallImages = document.querySelectorAll(".ytp-videowall-still-image"); // Because youtube video wall images are not properly classified as images

listAllThumbnails = listAllThumbnails.concat(Array.from(videowallImages));

Expand All @@ -59,13 +61,17 @@ function FindThumbnails() {
// Checks whether it's a chapter thumbnail
const isChapter = parent.closest("#endpoint") !== null


// Check if thumbnails have already been processed
const processed = Array.from(parent.children).filter(child => {
const alreadyHasAThumbnail =
child.id && // Child has ID
child.id.includes(extensionName);

return (
child.src &&
child.src.includes("extension") ||
isVideoPreview || isChapter)
alreadyHasAThumbnail
|| isVideoPreview
|| isChapter
)
});

return processed.length == 0;
Expand Down Expand Up @@ -230,30 +236,27 @@ async function LoadConfig() {
}
)
}
} catch (error) { console.error("Error loading configuration:", error); }

} catch (error) { console.error("Guhh?? Error loading configuration:", error); }
}

async function Main() {
await LoadConfig()
const extensionName = chrome.runtime.getManifest().name;

if (extensionIsDisabled) {
console.log(`${extensionName} is disabled.`)
return // Exit the function if MrBeastify is disabled
}


GetFlipBlocklist()
console.log(`${extensionName} will now detect the amount of images. Ignore all the following errors.`)
getHighestImageIndex()
.then(() => {
setInterval(applyOverlayToThumbnails, 100);
console.log(
`${extensionName} Loaded Successfully. ${highestImageIndex} images detected. Blacklist status: ${blacklistStatus}.`
`${extensionName} Loaded Successfully. ${highestImageIndex} images detected. ${blacklistStatus}.`
);

})

}

Main()

0 comments on commit 505938a

Please sign in to comment.