Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamlinerm committed Nov 9, 2024
1 parent cfdcfdd commit 6e37b9b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 33 deletions.
2 changes: 1 addition & 1 deletion AuthorHours.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"time":"493h53m40s"}
{"time":"496h31m13s"}
3 changes: 1 addition & 2 deletions chrome/popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ <h2 class="title" data-i18n>pageTitle</h2>
<a target="_blank" class="flex-center flex-col" style="text-align: center; text-decoration: none"
href="https://chrome.google.com/webstore/detail/netflixprime-auto-skip/akaimhgappllmlkadblbdknhbfghdgle">
<p style="font-size: 1em" data-i18n>rateNow</p>
<img src="https://img.shields.io/chrome-web-store/stars/akaimhgappllmlkadblbdknhbfghdgle?color=e60010"
alt="rating">
<img src="https://img.shields.io/chrome-web-store/stars/akaimhgappllmlkadblbdknhbfghdgle?color=e60010" alt="rating">
</a>
<div class="flex flex-row">
<a class="flex flex-center" style="font-size: 1.5em;"
Expand Down
13 changes: 8 additions & 5 deletions chrome/popup/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ <h2 class="title" data-i18n>pageTitle</h2>
<a target="_blank" class="flex-center flex-col" style="text-align: center; text-decoration: none"
href="https://chrome.google.com/webstore/detail/netflixprime-auto-skip/akaimhgappllmlkadblbdknhbfghdgle">
<p style="font-size: 1em" data-i18n>rateNow</p>
<img src="https://img.shields.io/chrome-web-store/stars/akaimhgappllmlkadblbdknhbfghdgle?color=e60010"
alt="rating">
<img src="https://img.shields.io/chrome-web-store/stars/akaimhgappllmlkadblbdknhbfghdgle?color=e60010" alt="rating">
</a>
</div>
<div class="flex flex-col MenuButtons" style="flex-wrap: wrap">
Expand Down Expand Up @@ -738,17 +737,21 @@ <h2>Changelog</h2>
<div class="line flex">
<h2>1.1.47</h2>
<ul>
<li>Fixed, Disney TMDB rating postions and more accurate ratings</li>
<li>TMDB show low votes ratings in grey</li>
<li>Improved TMDB correct lang</li>
<li>Fixed, Disney TMDB rating postions and more accurate title extraction</li>
<li>Better prime TMDB title extraction</li>
<li>Removed Search, Suggested Page from Ratings</li>
</ul>
</div>
<div class="line flex">
<p>1.1.47</p>
<p>1.1.46</p>
<ul>
<li>Linked TMDB website when click on rating</li>
</ul>
</div>
<div class="line flex">
<p>1.1.47</p>
<p>1.1.45</p>
<ul>
<li>Fix Disney bug: Remove "Continue watching after ad" text when ad is not running.</li>
</ul>
Expand Down
78 changes: 53 additions & 25 deletions chrome/skipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// matches all amazon urls under https://en.wikipedia.org/wiki/Amazon_(company)#Website
const hostname = window.location.hostname;
const title = document.title;
const url = window.location.href;
let url = window.location.href;
const ua = navigator.userAgent;
// only on prime video pages
const isPrimeVideo = /amazon|primevideo/i.test(hostname) && (/video/i.test(title) || /video/i.test(url));
Expand Down Expand Up @@ -254,10 +254,7 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
async function getMovieInfo(title, card, year = null) {
// justwatch api
// const url = `https://apis.justwatch.com/content/titles/${locale}/popular?language=en&body={"page_size":1,"page":1,"query":"${title}","content_types":["show","movie"]}`;
let locale = "en-US";
if (navigator?.language) {
locale = navigator?.language;
}
let locale = htmlLang || navigator?.language || "en-US";
let url = `https://api.themoviedb.org/3/search/multi?query=${encodeURI(title)}&include_adult=false&language=${locale}&page=1`;
if (year) url += `&year=${year}`;
// const response = await fetch(encodeURI(url));
Expand All @@ -278,6 +275,20 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
date: today,
db: "tmdb",
};
// if (
// compiledData?.title &&
// !compiledData.title
// .toLowerCase()
// .replace(":", "")
// .replace("-", "")
// .replace(",", "")
// .includes(title.toLowerCase().replace(":", "").replace("-", "").replace(",", ""))
// ) {
// console.log(
// "Title mismatch",
// title.replace(":", "").replace("-", "").replace(",", "") + "><" + compiledData.title.replace(":", "").replace("-", "").replace(",", "")
// );
// }
DBCache[title] = compiledData;
setRatingOnCard(card, compiledData, title);
}
Expand All @@ -295,8 +306,27 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
const config = { attributes: true, childList: true, subtree: true };
// #region Shared funcs
// shared functions
// show rating depending on page
const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/g;
function showRating() {
if (isDisney) {
url = window.location.href;
// disable search and suggested movies
if (url.includes("search")) return false;
if (url.includes("entity")) {
return uuidRegex.test(document.querySelector('[aria-selected="true"]')?.id.split("_control")[0]);
}
return true;
} else if (isPrimeVideo) {
// suggested movies
if (window.location.href.includes("detail")) {
return document.querySelector('[data-testid="btf-related-tab"]')?.tabIndex == 0;
}
return true;
} else return true;
}
async function startShowRatingInterval() {
addRating();
if (showRating()) addRating();
let RatingInterval = setInterval(function () {
if (
(isNetflix && !settings.Netflix?.showRating) ||
Expand All @@ -308,7 +338,7 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
clearInterval(RatingInterval);
return;
}
addRating();
if (showRating()) addRating();
}, 1000);
}
function getDiffInDays(firstDate, secondDate) {
Expand Down Expand Up @@ -363,6 +393,7 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
else if (type == 1) card?.parentElement?.classList.add("imdb");
}
let title;

if (isNetflix) title = card?.parentElement?.getAttribute("aria-label").split(" – ")[0];
// S2: E3 remove this part
else if (isDisney) {
Expand All @@ -376,14 +407,13 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
.split("Staffel")[0]
.split(" Neue")[0]
.split(" Alle")[0]
// comment means did not find translation
.split(" Jeden")[0]
//
.split(" Demnächst")[0]
.split(" Premiere")[0]
.split(" Altersfreigabe")[0]
//
.split(" Noch")[0];
.split(" Mach dich bereit")[0] // deadpool
//did not find translation
.split(" Jeden")[0]
.split(" Noch")[0]
.split(" Premiere")[0];
} else if (htmlLang == "en") {
title = title
?.replace(/Number \d* /, "")
Expand All @@ -392,12 +422,14 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
.split("Season")[0]
.split(" New ")[0]
.split(" All Episodes")[0]
//
.split(" Streaming ")[0]
//
.split(" Coming Soon")[0]
.split(" Coming")[0]
.split(" Two-Episode")[0]
.split(" Rated")[0];
.split(" Rated")[0]
.split(" Prepare for")[0] // deadpool
//did not find translation
.split(" Streaming ")[0]
//did not find translation
.replace(/ \d+ minutes remaining/g, "");
}
} else if (isHotstar) title = card?.getAttribute("alt")?.replace(/(S\d+\sE\d+)/g, "");
// amazon
Expand All @@ -408,13 +440,12 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
title
?.split(" - ")[0]
?.split(" – ")[0]
?.split(", ")[0]
?.replace(/(S\d+)/g, "")
?.replace(/ \[dt\.\/?O?V?\]/g, "")
?.replace(/\[OV\]/g, "")
?.replace(/ \[.*\]/g, "")
?.replace(/\s\(.*\)/g, "")
?.replace(/:?\sStaffel-?\s\d+/g, "")
?.replace(/:?\sSeason-?\s\d+/g, "")
?.replace(/ \/ \d/g, "")
?.split(": Die komplette")[0]
// nicht sicher
?.split(": The complete")[0]
Expand Down Expand Up @@ -475,12 +506,9 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
(isMobile ? "font-size: 4vw;" : "font-size: 1vw;");

// div.id = "imdb";
if (data?.score && vote_count >= 50) {
if (data?.score >= 0) {
div.textContent = data.score?.toFixed(1);
div.setAttribute("alt", data?.title + ", OG title: " + title + ", Vote count: " + vote_count);
} else if (data?.title) {
div.textContent = "N/A";
div.setAttribute("alt", data?.title + ", OG title: " + title + ", Vote count: " + vote_count);
} else {
div.textContent = "?";
div.setAttribute("alt", title);
Expand Down

0 comments on commit 6e37b9b

Please sign in to comment.