Compare commits

...

5 Commits
4.4.1 ... 4.4.2

Author SHA1 Message Date
Ajay
97e30e4001 bump version 2022-05-20 04:19:20 -04:00
Ajay
6763fd3b4b Allow more channel IDs
Help with #753
2022-05-20 04:01:50 -04:00
Ajay
a39ec76340 Fix skip to highlight option on mobile 2022-05-19 19:28:26 -04:00
Ajay
f68282decc Add more verbose logging to hidden variable 2022-05-19 19:22:59 -04:00
Ajay
160de56a71 Fix icon on android firefox 2022-05-19 13:07:44 -04:00
4 changed files with 34 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "__MSG_fullName__", "name": "__MSG_fullName__",
"short_name": "SponsorBlock", "short_name": "SponsorBlock",
"version": "4.4.1", "version": "4.4.2",
"default_locale": "en", "default_locale": "en",
"description": "__MSG_Description__", "description": "__MSG_Description__",
"homepage_url": "https://sponsor.ajay.app", "homepage_url": "https://sponsor.ajay.app",
@@ -64,7 +64,12 @@
], ],
"browser_action": { "browser_action": {
"default_title": "SponsorBlock", "default_title": "SponsorBlock",
"default_popup": "popup.html" "default_popup": "popup.html",
"default_icon": {
"16": "icons/IconSponsorBlocker16px.png",
"32": "icons/IconSponsorBlocker32px.png",
"64": "icons/LogoSponsorBlocker64px.png"
}
}, },
"background": { "background": {
"scripts":[ "scripts":[

View File

@@ -20,6 +20,7 @@ import { isSafari, keybindEquals } from "./utils/configUtils";
import { CategoryPill } from "./render/CategoryPill"; import { CategoryPill } from "./render/CategoryPill";
import { AnimationUtils } from "./utils/animationUtils"; import { AnimationUtils } from "./utils/animationUtils";
import { GenericUtils } from "./utils/genericUtils"; import { GenericUtils } from "./utils/genericUtils";
import { logDebug } from "./utils/logger";
// Hack to get the CSS loaded on permission-based sites (Invidious) // Hack to get the CSS loaded on permission-based sites (Invidious)
utils.wait(() => Config.config !== null, 5000, 10).then(addCSS); utils.wait(() => Config.config !== null, 5000, 10).then(addCSS);
@@ -448,6 +449,8 @@ function videoOnReadyListener(): void {
} }
function cancelSponsorSchedule(): void { function cancelSponsorSchedule(): void {
logDebug("Pausing skipping");
if (currentSkipSchedule !== null) { if (currentSkipSchedule !== null) {
clearTimeout(currentSkipSchedule); clearTimeout(currentSkipSchedule);
currentSkipSchedule = null; currentSkipSchedule = null;
@@ -470,11 +473,13 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
// Reset lastCheckVideoTime // Reset lastCheckVideoTime
lastCheckVideoTime = -1; lastCheckVideoTime = -1;
lastCheckTime = 0; lastCheckTime = 0;
console.warn("[SB] Ad playing, pausing skipping"); logDebug("[SB] Ad playing, pausing skipping");
return; return;
} }
logDebug(`Considering to start skipping: ${!video}, ${video?.paused}`);
if (!video || video.paused) return; if (!video || video.paused) return;
if (currentTime === undefined || currentTime === null) { if (currentTime === undefined || currentTime === null) {
const virtualTime = lastTimeFromWaitingEvent ?? (lastKnownVideoTime.videoTime ? const virtualTime = lastTimeFromWaitingEvent ?? (lastKnownVideoTime.videoTime ?
@@ -506,6 +511,7 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
const skipInfo = getNextSkipIndex(currentTime, includeIntersectingSegments, includeNonIntersectingSegments); const skipInfo = getNextSkipIndex(currentTime, includeIntersectingSegments, includeNonIntersectingSegments);
logDebug(`Ready to start skipping: ${skipInfo.index} at ${currentTime}`);
if (skipInfo.index === -1) return; if (skipInfo.index === -1) return;
const currentSkip = skipInfo.array[skipInfo.index]; const currentSkip = skipInfo.array[skipInfo.index];
@@ -526,6 +532,8 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
} }
} }
logDebug(`Next step in starting skipping: ${!shouldSkip(currentSkip)}, ${!sponsorTimesSubmitting?.some((segment) => segment.segment === currentSkip.segment)}`);
// Don't skip if this category should not be skipped // Don't skip if this category should not be skipped
if (!shouldSkip(currentSkip) && !sponsorTimesSubmitting?.some((segment) => segment.segment === currentSkip.segment)) return; if (!shouldSkip(currentSkip) && !sponsorTimesSubmitting?.some((segment) => segment.segment === currentSkip.segment)) return;
@@ -691,7 +699,7 @@ function setupVideoListeners() {
if (startedWaiting) { if (startedWaiting) {
startedWaiting = false; startedWaiting = false;
console.warn(`[SB] Starting schedule after buffering: ${Math.abs(lastCheckVideoTime - video.currentTime) > 0.3 logDebug(`[SB] Playing event after buffering: ${Math.abs(lastCheckVideoTime - video.currentTime) > 0.3
|| (lastCheckVideoTime !== video.currentTime && Date.now() - lastCheckTime > 2000)}`); || (lastCheckVideoTime !== video.currentTime && Date.now() - lastCheckTime > 2000)}`);
} }
@@ -734,7 +742,7 @@ function setupVideoListeners() {
}; };
video.addEventListener('pause', () => paused()); video.addEventListener('pause', () => paused());
video.addEventListener('waiting', () => { video.addEventListener('waiting', () => {
console.warn("[SB] Not skipping due to buffering"); logDebug("[SB] Not skipping due to buffering");
startedWaiting = true; startedWaiting = true;
paused(); paused();
@@ -1134,7 +1142,7 @@ async function whitelistCheck() {
?? document.querySelector("a.ytp-title-channel-logo") // YouTube Embed ?? document.querySelector("a.ytp-title-channel-logo") // YouTube Embed
?? document.querySelector(".channel-profile #channel-name")?.parentElement.parentElement // Invidious ?? document.querySelector(".channel-profile #channel-name")?.parentElement.parentElement // Invidious
?? document.querySelector("a.slim-owner-icon-and-title")) // Mobile YouTube ?? document.querySelector("a.slim-owner-icon-and-title")) // Mobile YouTube
?.getAttribute("href")?.match(/\/channel\/(UC[a-zA-Z0-9_-]{22})/)?.[1]; ?.getAttribute("href")?.match(/\/channel\/(UC[a-zA-Z0-9_-]{22})|\/c\/([a-zA-Z0-9_-]+)/)?.[1];
try { try {
await utils.wait(() => !!getChannelID(), 6000, 20); await utils.wait(() => !!getChannelID(), 6000, 20);

View File

@@ -172,10 +172,10 @@ export class SkipButtonControlBar {
const overlay = document.getElementById("player-control-overlay"); const overlay = document.getElementById("player-control-overlay");
if (overlay && this.enabled) { if (overlay && this.enabled) {
if (overlay?.classList?.contains("pointer-events-off")) { if (overlay?.classList?.contains("fadein")) {
this.hideButton();
} else {
this.showButton(); this.showButton();
} else {
this.hideButton();
} }
} }
} }

12
src/utils/logger.ts Normal file
View File

@@ -0,0 +1,12 @@
window["SBLogs"] = {
debug: [],
warn: []
};
export function logDebug(message: string) {
window["SBLogs"].debug.push(message);
}
export function logWarn(message: string) {
window["SBLogs"].warn.push(message);
}