Merge pull request #1273 from mchangrh/miscFixes

Misc fixes
This commit is contained in:
Ajay Ramachandran 2022-04-08 23:39:34 -04:00 committed by GitHub
commit 9bea04dfc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -652,4 +652,10 @@ input::-webkit-inner-spin-button {
.sponsorBlockCategoryPill:hover .categoryPillClose {
display: inherit;
}
/* tweak for mobile duration */
#sponsorBlockDurationAfterSkips.ytm-time-display {
padding-left: 4px;
margin: 0px;
}

View file

@ -1003,10 +1003,10 @@ function getYouTubeVideoID(document: Document): string | boolean {
const url = document.URL;
// clips should never skip, going from clip to full video has no indications.
if (url.includes("youtube.com/clip/")) return false;
// skip to document and don't hide if on /embed/
if (url.includes("/embed/") && url.includes("youtube.com")) return getYouTubeVideoIDFromDocument(document, false);
// skip to URL if matches youtube watch or invidious or matches youtube pattern
if ((!url.includes("youtube.com")) || url.includes("/watch") || url.includes("/shorts/") || url.includes("playlist")) return getYouTubeVideoIDFromURL(url);
// skip to document and don't hide if on /embed/
if (url.includes("/embed/")) return getYouTubeVideoIDFromDocument(document, false);
// skip to document if matches pattern
if (url.includes("/channel/") || url.includes("/user/") || url.includes("/c/")) return getYouTubeVideoIDFromDocument(document);
// not sure, try URL then document
@ -2126,14 +2126,15 @@ function updateAdFlag(): void {
}
function showTimeWithoutSkips(skippedDuration: number): void {
if (onMobileYouTube || onInvidious) return;
if (onInvidious) return;
if (isNaN(skippedDuration) || skippedDuration < 0) {
skippedDuration = 0;
}
// YouTube player time display
const display = document.querySelector(".ytp-time-display.notranslate");
const displayClass = onMobileYouTube ? "ytm-time-display" : "ytp-time-display.notranslate"
const display = document.querySelector(`.${displayClass}`);
if (!display) return;
const durationID = "sponsorBlockDurationAfterSkips";
@ -2143,7 +2144,7 @@ function showTimeWithoutSkips(skippedDuration: number): void {
if (duration === null) {
duration = document.createElement('span');
duration.id = durationID;
duration.classList.add("ytp-time-duration");
duration.classList.add(displayClass);
display.appendChild(duration);
}