Skip to content

Commit

Permalink
for each is not going in order on chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamlinerm committed Oct 28, 2023
1 parent 5fe5f00 commit 363a083
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions chrome/skipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,23 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
else if (isDisney) titleCards = document.querySelectorAll(".basic-card div div img:not(.imdb)");
// amazon
else titleCards = document.querySelectorAll("li:not(.imdb) [data-card-title]");
// on disney there are multiple images for the same title so only use the first one
let lastTitle = "";
titleCards.forEach((card) => {
// for each is not going in order on chrome
for (let i = 0; i < titleCards.length; i++) {
let card = titleCards[i];
// add seeen class
if (isNetflix || isDisney) card.classList.add("imdb");
//Amazon
else card.parentElement.classList.add("imdb");
// let card = document.querySelectorAll(".title-card .boxart-container:not(.imdb)");
let title;
if (isNetflix) title = card?.children?.[1]?.firstChild?.textContent.split(" – ")[0];
// S2: E3 remove this part
else if (isDisney) title = card?.getAttribute("alt").replace(/(S\d+:\sE\d+\s)/g, "");
// amazon
// remove everything after - in the title
else title = card.getAttribute("data-card-title").split(" - ")[0].split(" – ")[0]; //Amazon
// add seeen class
if (isNetflix || isDisney) card.classList.add("imdb");
else card.parentElement.classList.add("imdb");
else title = card.getAttribute("data-card-title").split(" - ")[0].split(" – ")[0];
if (title && lastTitle != title && !title.includes("Netflix") && !title.includes("Prime Video")) {
// sometimes more than one image is loaded for the same title
lastTitle = title;
Expand Down Expand Up @@ -316,7 +320,7 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
}
}
}
});
}
}
// deprecated justwatch api
async function setAlternativesOnCard(card, data) {
Expand Down
16 changes: 10 additions & 6 deletions firefox/skipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,23 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
else if (isDisney) titleCards = document.querySelectorAll(".basic-card div div img:not(.imdb)");
// amazon
else titleCards = document.querySelectorAll("li:not(.imdb) [data-card-title]");
// on disney there are multiple images for the same title so only use the first one
let lastTitle = "";
titleCards.forEach((card) => {
// for each is not going in order on chrome
for (let i = 0; i < titleCards.length; i++) {
let card = titleCards[i];
// add seeen class
if (isNetflix || isDisney) card.classList.add("imdb");
//Amazon
else card.parentElement.classList.add("imdb");
// let card = document.querySelectorAll(".title-card .boxart-container:not(.imdb)");
let title;
if (isNetflix) title = card?.children?.[1]?.firstChild?.textContent.split(" – ")[0];
// S2: E3 remove this part
else if (isDisney) title = card?.getAttribute("alt").replace(/(S\d+:\sE\d+\s)/g, "");
// amazon
// remove everything after - in the title
else title = card.getAttribute("data-card-title").split(" - ")[0].split(" – ")[0]; //Amazon
// add seeen class
if (isNetflix || isDisney) card.classList.add("imdb");
else card.parentElement.classList.add("imdb");
else title = card.getAttribute("data-card-title").split(" - ")[0].split(" – ")[0];
if (title && lastTitle != title && !title.includes("Netflix") && !title.includes("Prime Video")) {
// sometimes more than one image is loaded for the same title
lastTitle = title;
Expand Down Expand Up @@ -316,7 +320,7 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
}
}
}
});
}
}
// deprecated justwatch api
async function setAlternativesOnCard(card, data) {
Expand Down

0 comments on commit 363a083

Please sign in to comment.