Compare commits

...

16 Commits
4.4.1 ... 4.4.3

Author SHA1 Message Date
Ajay Ramachandran
e2da071761 bump version 2022-05-24 13:16:04 -04:00
Ajay Ramachandran
c20c9ac64a Merge pull request #1220 from tadwohlrapp/patch-1
Fix minor typos and inconsistencies
2022-05-24 13:12:20 -04:00
Ajay Ramachandran
2d59f3825c New translations messages.json (Swedish) (#1326) 2022-05-24 13:09:34 -04:00
Ajay Ramachandran
fb8b7a7d19 Merge pull request #1327 from Argn0/branch1
Add reset settings option
2022-05-24 12:56:50 -04:00
Ajay
d992cc7a3c Don't reset everything 2022-05-24 12:55:17 -04:00
Ajay
f8fecf5174 Remove redundant explanation 2022-05-24 12:50:39 -04:00
Argn0
3007cddce9 add reset settings option 2022-05-24 10:04:56 +02:00
Ajay
2b3c812f8a Some more debug logs 2022-05-23 21:41:35 -04:00
Ajay
61535fac95 Add more logging for catching skip issues 2022-05-23 01:14:46 -04:00
Ajay
4182595436 Don't stop skipping if channel id fetch fails 2022-05-21 16:54:02 -04:00
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
Tad Wohlrapp
a64deb2e18 Fix minor typos and inconsistencies 2022-03-08 19:57:09 +01:00
9 changed files with 89 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "__MSG_fullName__",
"short_name": "SponsorBlock",
"version": "4.4.1",
"version": "4.4.3",
"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":[

View File

@@ -101,7 +101,7 @@
"message": "It seems the server is down. Contact the dev immediately."
},
"connectionError": {
"message": "A connection error has occured. Error code: "
"message": "A connection error has occurred. Error code: "
},
"clearTimes": {
"message": "Clear Segments"
@@ -356,7 +356,7 @@
"message": "Show Time With Skips Removed"
},
"showTimeWithSkipsDescription": {
"message": "This time appears in brackets next to the current time on below the seekbar. This shows the total video duration minus any segments. This includes segments marked as only \"Show In Seekbar\"."
"message": "This time appears in brackets next to the current time on below the Seek Bar. This shows the total video duration minus any segments. This includes segments marked as only \"Show In Seek Bar\"."
},
"youHaveSkipped": {
"message": "You've skipped "
@@ -410,7 +410,7 @@
"message": "Supported Sites: "
},
"optionsInfo": {
"message": "Enable Invidious support, disable autoskip, hide buttons and more."
"message": "Enable Invidious support, disable auto skip, hide buttons and more."
},
"addInvidiousInstance": {
"message": "Add 3rd-Party Client Instance"
@@ -499,7 +499,7 @@
"incorrectlyFormattedOptions": {
"message": "This JSON is not formatted correctly. Your options have not been changed."
},
"confirmNoticeTitle" : {
"confirmNoticeTitle": {
"message": "Submit Segment"
},
"submit": {
@@ -947,5 +947,11 @@
},
"openOptionsPage": {
"message": "Open options page"
},
"resetToDefault": {
"message": "Reset settings to default"
},
"confirmResetToDefault": {
"message": "Are you sure you want to reset all settings to their default values? This cannot be undone."
}
}

View File

@@ -186,7 +186,7 @@
"message": "Detta döljer knapparna på YouTube-spelaren som du kan skicka in segment med som ska hoppas över."
},
"showSkipButton": {
"message": "Behåll knappen hoppa till markerat på spelaren"
"message": "Behåll knappen hoppa till höjdpunkt på spelaren"
},
"showInfoButton": {
"message": "Visa Infoknapp På YouTube-spelaren"
@@ -613,7 +613,7 @@
"message": "Icke-musik"
},
"category_poi_highlight": {
"message": "Markera"
"message": "Höjdpunkt"
},
"category_poi_highlight_description": {
"message": "Den del av videon som de flesta letar efter. Liknande kommentarer \"Video börjar på x\"."

View File

@@ -368,6 +368,12 @@
</div>
</div>
<div data-type="button-press" data-sync="resetToDefault" data-confirm-message="confirmResetToDefault">
<div class="option-button trigger-button">
__MSG_resetToDefault__
</div>
</div>
</div>
<div id="advanced" class="option-group hidden">

View File

@@ -113,6 +113,7 @@ export interface SBObject {
local: SBStorage;
forceSyncUpdate(prop: string): void;
forceLocalUpdate(prop: string): void;
resetToDefault(): void;
}
const Config: SBObject = {
@@ -289,7 +290,8 @@ const Config: SBObject = {
config: null,
local: null,
forceSyncUpdate,
forceLocalUpdate
forceLocalUpdate,
resetToDefault
};
// Function setup
@@ -522,6 +524,16 @@ function addDefaults() {
}
}
function resetToDefault() {
chrome.storage.sync.set({
...Config.syncDefaults,
userID: Config.config.userID,
minutesSaved: Config.config.minutesSaved,
skipCount: Config.config.skipCount,
sponsorTimesContributed: Config.config.sponsorTimesContributed
});
}
// Sync config
setupConfig();

View File

@@ -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);
@@ -275,6 +276,7 @@ function resetValues() {
switchingVideos = false;
} else {
switchingVideos = true;
logDebug("Setting switching videos to true (reset data)");
}
firstEvent = true;
@@ -448,6 +450,8 @@ function videoOnReadyListener(): void {
}
function cancelSponsorSchedule(): void {
logDebug("Pausing skipping");
if (currentSkipSchedule !== null) {
clearTimeout(currentSkipSchedule);
currentSkipSchedule = null;
@@ -470,11 +474,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 +512,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 +533,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;
@@ -566,6 +575,8 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
// Use interval instead of timeout near the end to combat imprecise video time
const startIntervalTime = performance.now();
const startVideoTime = Math.max(currentTime, video.currentTime);
logDebug(`Starting setInterval skipping ${video.currentTime} to skip at ${skipTime[0]}`);
currentSkipInterval = setInterval(() => {
const intervalDuration = performance.now() - startIntervalTime;
if (intervalDuration >= delayTime || video.currentTime >= skipTime[0]) {
@@ -580,6 +591,8 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
}
}, 1);
} else {
logDebug(`Starting timeout to skip ${video.currentTime} to skip at ${skipTime[0]}`);
// Schedule for right before to be more precise than normal timeout
currentSkipSchedule = setTimeout(skippingFunction, Math.max(0, delayTime - 100));
}
@@ -669,6 +682,8 @@ function setupVideoListeners() {
if (switchingVideos) {
switchingVideos = false;
logDebug("Setting switching videos to false");
// If already segments loaded before video, retry to skip starting segments
if (sponsorTimes) startSkipScheduleCheckingForStartSponsors();
}
@@ -691,7 +706,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 +749,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 +1149,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);
@@ -1142,14 +1157,12 @@ async function whitelistCheck() {
channelIDInfo = {
status: ChannelIDStatus.Found,
id: getChannelID().match(/^\/?([^\s/]+)/)[0]
}
};
} catch (e) {
channelIDInfo = {
status: ChannelIDStatus.Failed,
id: null
}
return;
};
}
//see if this is a whitelisted channel

View File

@@ -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();
}
}
}

View File

@@ -232,12 +232,22 @@ async function init() {
}
case "button-press": {
const actionButton = optionsElements[i].querySelector(".trigger-button");
const confirmMessage = optionsElements[i].getAttribute("data-confirm-message");
switch(optionsElements[i].getAttribute("data-sync")) {
case "copyDebugInformation":
actionButton.addEventListener("click", copyDebugOutputToClipboard);
break;
}
actionButton.addEventListener("click", () => {
if (confirmMessage !== null && !confirm(chrome.i18n.getMessage(confirmMessage))) {
return;
}
switch (optionsElements[i].getAttribute("data-sync")) {
case "copyDebugInformation":
copyDebugOutputToClipboard();
break;
case "resetToDefault":
Config.resetToDefault();
window.location.reload();
break;
}
});
break;
}

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);
}