Skip to content

Commit

Permalink
Disney_skipAd fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamlinerm committed Nov 21, 2024
1 parent 0befee8 commit f100637
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions firefox/popup/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ <h2>Changelog</h2>
<div class="line flex">
<h2>1.1.52</h2>
<ul>
<li>Disney improved ad skip</li>
<li>Disney fixed Bug first ad is not skipped</li>
<li>TMDB refresh new movie ratings every day</li>
</ul>
</div>
Expand Down
24 changes: 14 additions & 10 deletions firefox/skipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
else if (isDisney || isHotstar) {
if (isHotstar) Hotstar_doubleClick();
DisneyObserver.observe(document, config);
setInterval(function () {
let video = Array.from(document.querySelectorAll("video")).find((v) => v.checkVisibility());
if (settings.Disney?.skipAd) Disney_skipAd(video);
}, 300);
} else if (isCrunchyroll) startCrunchyroll(settings.Crunchyroll);
else if (isHBO) HBOObserver.observe(document, config);
if (settings?.Video?.playOnFullScreen) startPlayOnFullScreen();
Expand Down Expand Up @@ -579,8 +583,8 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
// Disney Observers
const DisneyObserver = new MutationObserver(Disney);
function Disney() {
let video = document.querySelector("video");
if (!video) video = document.querySelector("disney-web-player")?.shadowRoot?.firstChild?.firstChild;
// first ad not first video
let video = Array.from(document.querySelectorAll("video")).find((v) => v.checkVisibility());
const time = video?.currentTime;
if (settings.Disney?.skipIntro) Disney_Intro(video, time);
Disney_skipCredits(time);
Expand All @@ -591,22 +595,22 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar || isCrunchyroll || isHBO
if (settings.Disney?.selfAd) Disney_selfAd(video, time);
}
if (settings.Video?.scrollVolume) Disney_scrollVolume(video);
if (settings.Disney?.skipAd) Disney_skipAd(video);
}
async function Disney_skipAd(video) {
if (video) {
const adTimeText = document.querySelector("div.overlay_interstitials__content_time_display");
if (adTimeText) {
const adTime = parseAdTime(adTimeText.textContent);
if (adTime >= 1 && !lastAdTimeText) {
lastAdTimeText = adTime;
resetLastATimeText(100);
if (adTime >= 1 && lastAdTimeText != video.currentTime) {
if (lastAdTimeText == 0) {
log("Disney Ad skipped, length:", adTime, "s");
settings.Statistics.DisneyAdTimeSkipped += adTime;
increaseBadge();
}
lastAdTimeText = video.currentTime;
video.currentTime += adTime;
log("Disney Ad skipped, length:", adTime, "s");
settings.Statistics.DisneyAdTimeSkipped += adTime;
increaseBadge();
}
}
} else lastAdTimeText = 0;
// remove das video wird nach der pause fortgesetzt text after skipping ad
const continueText = document.querySelector("p.toast-notification__text[aria-hidden='true']");
if (continueText?.checkVisibility()) {
Expand Down

0 comments on commit f100637

Please sign in to comment.