mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 11:37:02 +03:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97e30e4001 | ||
|
|
6763fd3b4b | ||
|
|
a39ec76340 | ||
|
|
f68282decc | ||
|
|
160de56a71 |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "__MSG_fullName__",
|
||||
"short_name": "SponsorBlock",
|
||||
"version": "4.4.1",
|
||||
"version": "4.4.2",
|
||||
"default_locale": "en",
|
||||
"description": "__MSG_Description__",
|
||||
"homepage_url": "https://sponsor.ajay.app",
|
||||
@@ -64,7 +64,12 @@
|
||||
],
|
||||
"browser_action": {
|
||||
"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": {
|
||||
"scripts":[
|
||||
|
||||
@@ -20,6 +20,7 @@ import { isSafari, keybindEquals } from "./utils/configUtils";
|
||||
import { CategoryPill } from "./render/CategoryPill";
|
||||
import { AnimationUtils } from "./utils/animationUtils";
|
||||
import { GenericUtils } from "./utils/genericUtils";
|
||||
import { logDebug } from "./utils/logger";
|
||||
|
||||
// Hack to get the CSS loaded on permission-based sites (Invidious)
|
||||
utils.wait(() => Config.config !== null, 5000, 10).then(addCSS);
|
||||
@@ -448,6 +449,8 @@ function videoOnReadyListener(): void {
|
||||
}
|
||||
|
||||
function cancelSponsorSchedule(): void {
|
||||
logDebug("Pausing skipping");
|
||||
|
||||
if (currentSkipSchedule !== null) {
|
||||
clearTimeout(currentSkipSchedule);
|
||||
currentSkipSchedule = null;
|
||||
@@ -470,11 +473,13 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
|
||||
// Reset lastCheckVideoTime
|
||||
lastCheckVideoTime = -1;
|
||||
lastCheckTime = 0;
|
||||
console.warn("[SB] Ad playing, pausing skipping");
|
||||
logDebug("[SB] Ad playing, pausing skipping");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
logDebug(`Considering to start skipping: ${!video}, ${video?.paused}`);
|
||||
|
||||
if (!video || video.paused) return;
|
||||
if (currentTime === undefined || currentTime === null) {
|
||||
const virtualTime = lastTimeFromWaitingEvent ?? (lastKnownVideoTime.videoTime ?
|
||||
@@ -506,6 +511,7 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
|
||||
|
||||
const skipInfo = getNextSkipIndex(currentTime, includeIntersectingSegments, includeNonIntersectingSegments);
|
||||
|
||||
logDebug(`Ready to start skipping: ${skipInfo.index} at ${currentTime}`);
|
||||
if (skipInfo.index === -1) return;
|
||||
|
||||
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
|
||||
if (!shouldSkip(currentSkip) && !sponsorTimesSubmitting?.some((segment) => segment.segment === currentSkip.segment)) return;
|
||||
|
||||
@@ -691,7 +699,7 @@ function setupVideoListeners() {
|
||||
|
||||
if (startedWaiting) {
|
||||
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)}`);
|
||||
}
|
||||
|
||||
@@ -734,7 +742,7 @@ function setupVideoListeners() {
|
||||
};
|
||||
video.addEventListener('pause', () => paused());
|
||||
video.addEventListener('waiting', () => {
|
||||
console.warn("[SB] Not skipping due to buffering");
|
||||
logDebug("[SB] Not skipping due to buffering");
|
||||
startedWaiting = true;
|
||||
|
||||
paused();
|
||||
@@ -1134,7 +1142,7 @@ async function whitelistCheck() {
|
||||
?? document.querySelector("a.ytp-title-channel-logo") // YouTube Embed
|
||||
?? document.querySelector(".channel-profile #channel-name")?.parentElement.parentElement // Invidious
|
||||
?? 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 {
|
||||
await utils.wait(() => !!getChannelID(), 6000, 20);
|
||||
|
||||
@@ -172,10 +172,10 @@ export class SkipButtonControlBar {
|
||||
const overlay = document.getElementById("player-control-overlay");
|
||||
|
||||
if (overlay && this.enabled) {
|
||||
if (overlay?.classList?.contains("pointer-events-off")) {
|
||||
this.hideButton();
|
||||
} else {
|
||||
if (overlay?.classList?.contains("fadein")) {
|
||||
this.showButton();
|
||||
} else {
|
||||
this.hideButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
src/utils/logger.ts
Normal file
12
src/utils/logger.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user