From a64deb2e1811129d4f812d02651bde282e041735 Mon Sep 17 00:00:00 2001 From: Tad Wohlrapp Date: Tue, 8 Mar 2022 19:57:09 +0100 Subject: [PATCH 1/7] Fix minor typos and inconsistencies --- public/_locales/en/messages.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 1d3e9f15..a8511bad 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -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" @@ -353,7 +353,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 " @@ -407,7 +407,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" @@ -496,7 +496,7 @@ "incorrectlyFormattedOptions": { "message": "This JSON is not formatted correctly. Your options have not been changed." }, - "confirmNoticeTitle" : { + "confirmNoticeTitle": { "message": "Submit Segment" }, "submit": { From 463ce258bf611074fc80445c2ded6155cb0f4f88 Mon Sep 17 00:00:00 2001 From: Alec Rust Date: Sat, 19 Mar 2022 14:39:09 +0000 Subject: [PATCH 2/7] Fix @typescript-eslint/no-unused-vars lint warnings --- .eslintrc.js | 1 + src/components/SkipNoticeComponent.tsx | 38 +++++++++++------------ src/components/TooltipComponent.tsx | 2 -- src/config.ts | 22 ++++++------- src/content.ts | 26 ---------------- src/js-components/skipButtonControlBar.ts | 8 ++--- 6 files changed, 33 insertions(+), 64 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 96035c76..622e66ad 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,6 +21,7 @@ module.exports = { }, plugins: ["react", "@typescript-eslint"], rules: { + '@typescript-eslint/no-unused-vars': 'error', // TODO: Remove warn rules when not needed anymore "no-self-assign": "off", "@typescript-eslint/no-empty-interface": "off", diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index 67facd3a..a972b325 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import * as CompileConfig from "../../config.json"; import Config from "../config" -import { Category, ContentContainer, SponsorHideType, SponsorTime, NoticeVisbilityMode, ActionType, SponsorSourceType, SegmentUUID } from "../types"; +import { Category, ContentContainer, SponsorTime, NoticeVisbilityMode, ActionType, SponsorSourceType, SegmentUUID } from "../types"; import NoticeComponent from "./NoticeComponent"; import NoticeTextSelectionComponent from "./NoticeTextSectionComponent"; import Utils from "../utils"; @@ -72,7 +72,7 @@ class SkipNoticeComponent extends React.Component; @@ -105,7 +105,7 @@ class SkipNoticeComponent extends React.Component 1) { this.segments.sort((a, b) => a.segment[0] - b.segment[0]); } - + // This is the suffix added at the end of every id for (const segment of this.segments) { this.idSuffix += segment.UUID; @@ -168,7 +168,7 @@ class SkipNoticeComponent extends React.Component= NoticeVisbilityMode.FadedForAll + startFaded={Config.config.noticeVisibilityMode >= NoticeVisbilityMode.FadedForAll || (Config.config.noticeVisibilityMode >= NoticeVisbilityMode.FadedForAutoSkip && this.autoSkip)} timed={true} maxCountdownTime={this.state.maxCountdownTime} @@ -205,7 +205,7 @@ class SkipNoticeComponent extends React.Component {/* Vote Button Container */} - {!this.state.thanksForVotingText ? + {!this.state.thanksForVotingText ? @@ -268,7 +268,7 @@ class SkipNoticeComponent extends React.Component @@ -379,7 +379,7 @@ class SkipNoticeComponent extends React.Component this.performAction(i)} key={"submission" + i + this.segments[i].category + this.idSuffix}> @@ -404,7 +404,7 @@ class SkipNoticeComponent extends React.Component { @@ -723,7 +723,7 @@ class SkipNoticeComponent extends React.Component = { set(obj: SBConfig, prop: K, value: SBConfig[K]) { Config.cachedSyncConfig[prop] = value; @@ -327,10 +327,10 @@ function configProxy(): { sync: SBConfig, local: SBStorage } { return obj[prop] || data; }, - + deleteProperty(obj: SBConfig, prop: keyof SBConfig) { chrome.storage.sync.remove( prop); - + return true; } @@ -352,10 +352,10 @@ function configProxy(): { sync: SBConfig, local: SBStorage } { return obj[prop] || data; }, - + deleteProperty(obj: SBStorage, prop: keyof SBStorage) { chrome.storage.local.remove( prop); - + return true; } @@ -379,7 +379,7 @@ function forceLocalUpdate(prop: string): void { }); } -async function fetchConfig(): Promise { +async function fetchConfig(): Promise { await Promise.all([new Promise((resolve) => { chrome.storage.sync.get(null, function(items) { Config.cachedSyncConfig = items; @@ -387,7 +387,7 @@ async function fetchConfig(): Promise { }); }), new Promise((resolve) => { chrome.storage.local.get(null, function(items) { - Config.cachedLocalStorage = items; + Config.cachedLocalStorage = items; resolve(); }); })]); @@ -431,9 +431,9 @@ function migrateOldSyncFormats(config: SBConfig) { if (!config["autoSkipOnMusicVideosUpdate"]) { config["autoSkipOnMusicVideosUpdate"] = true; for (const selection of config.categorySelections) { - if (selection.name === "music_offtopic" + if (selection.name === "music_offtopic" && selection.option === CategorySkipOption.AutoSkip) { - + config.autoSkipOnMusicVideos = true; break; } diff --git a/src/content.ts b/src/content.ts index 655259ef..c6b8ba9f 100644 --- a/src/content.ts +++ b/src/content.ts @@ -318,9 +318,6 @@ async function videoIDChange(id) { } } - // Get new video info - // getVideoInfo(); // Seems to have been replaced - // Update whitelist data when the video data is loaded whitelistCheck(); @@ -898,12 +895,10 @@ function startSkipScheduleCheckingForStartSponsors() { // See if there are any starting sponsors let startingSegmentTime = getStartTimeFromUrl(document.URL) || -1; let found = false; - let startingSegment: SponsorTime = null; for (const time of sponsorTimes) { if (time.segment[0] <= video.currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > video.currentTime && time.actionType !== ActionType.Poi) { startingSegmentTime = time.segment[0]; - startingSegment = time; found = true; break; } @@ -913,7 +908,6 @@ function startSkipScheduleCheckingForStartSponsors() { if (time.segment[0] <= video.currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > video.currentTime && time.actionType !== ActionType.Poi) { startingSegmentTime = time.segment[0]; - startingSegment = time; found = true; break; } @@ -951,26 +945,6 @@ function startSkipScheduleCheckingForStartSponsors() { } } -/** - * Get the video info for the current tab from YouTube - * - * TODO: Replace - */ -async function getVideoInfo(): Promise { - const result = await utils.asyncRequestToCustomServer("GET", "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID + "&html5=1&c=TVHTML5&cver=7.20190319"); - - if (result.ok) { - const decodedData = decodeURIComponent(result.responseText).match(/player_response=([^&]*)/)[1]; - if (!decodedData) { - console.error("[SB] Failed at getting video info from YouTube."); - console.error("[SB] Data returned from YouTube: " + result.responseText); - return; - } - - videoInfo = JSON.parse(decodedData); - } -} - function getYouTubeVideoID(document: Document): string | boolean { const url = document.URL; // clips should never skip, going from clip to full video has no indications. diff --git a/src/js-components/skipButtonControlBar.ts b/src/js-components/skipButtonControlBar.ts index 62f572f0..95ed81f8 100644 --- a/src/js-components/skipButtonControlBar.ts +++ b/src/js-components/skipButtonControlBar.ts @@ -2,10 +2,7 @@ import Config from "../config"; import { SponsorTime } from "../types"; import { getSkippingText } from "../utils/categoryUtils"; import { keybindToString } from "../utils/configUtils"; - -import Utils from "../utils"; import { AnimationUtils } from "../utils/animationUtils"; -const utils = new Utils(); export interface SkipButtonControlBarProps { skip: (segment: SponsorTime) => void; @@ -53,7 +50,7 @@ export class SkipButtonControlBar { this.skipIcon.id = "sbSkipIconControlBarImage"; this.textContainer = document.createElement("div"); - + this.container.appendChild(this.skipIcon); this.container.appendChild(this.textContainer); this.container.addEventListener("click", () => this.toggleSkip()); @@ -73,7 +70,7 @@ export class SkipButtonControlBar { attachToPage(): void { const mountingContainer = this.getMountingContainer(); this.chapterText = document.querySelector(".ytp-chapter-container"); - + if (mountingContainer && !mountingContainer.contains(this.container)) { if (this.onMobileYouTube) { mountingContainer.appendChild(this.container); @@ -220,4 +217,3 @@ export class SkipButtonControlBar { this.container.style.left = this.left + "px"; } } - From 3007cddce92f68cbcb8ee0726bba4d23c62caba3 Mon Sep 17 00:00:00 2001 From: Argn0 Date: Tue, 24 May 2022 10:04:56 +0200 Subject: [PATCH 3/7] add reset settings option --- public/_locales/en/messages.json | 9 +++++++++ public/options/options.html | 8 ++++++++ src/config.ts | 8 +++++++- src/options.ts | 20 +++++++++++++++----- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index c2782048..11a3d609 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -947,5 +947,14 @@ }, "openOptionsPage": { "message": "Open options page" + }, + "resetToDefault": { + "message": "Reset to default" + }, + "confirmResetToDefault": { + "message": "Are you sure you want to reset all settings to their default values? This cannot be undone." + }, + "whatResetToDefault": { + "message": "This resets all settings to their default values." } } diff --git a/public/options/options.html b/public/options/options.html index 4f2bd730..2d6885bb 100644 --- a/public/options/options.html +++ b/public/options/options.html @@ -368,6 +368,14 @@ +
+
+ __MSG_resetToDefault__ +
+ +
__MSG_whatResetToDefault__
+
+ From d992cc7a3c621f435ac01544697ed57f77eccc60 Mon Sep 17 00:00:00 2001 From: Ajay Date: Tue, 24 May 2022 12:55:17 -0400 Subject: [PATCH 5/7] Don't reset everything --- src/config.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 52c9f45a..03ebbaf0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -525,7 +525,13 @@ function addDefaults() { } function resetToDefault() { - chrome.storage.sync.set(Config.syncDefaults); + chrome.storage.sync.set({ + ...Config.syncDefaults, + userID: Config.config.userID, + minutesSaved: Config.config.minutesSaved, + skipCount: Config.config.skipCount, + sponsorTimesContributed: Config.config.sponsorTimesContributed + }); } // Sync config From 2d59f3825cba97ef012eec6672867485f42fb35e Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 24 May 2022 13:09:34 -0400 Subject: [PATCH 6/7] New translations messages.json (Swedish) (#1326) --- public/_locales/sv/messages.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/_locales/sv/messages.json b/public/_locales/sv/messages.json index 37ab100e..0b8e4e06 100644 --- a/public/_locales/sv/messages.json +++ b/public/_locales/sv/messages.json @@ -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\"." From e2da0717618de2e64a9ef041eee5fad9c15f310b Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 24 May 2022 13:16:04 -0400 Subject: [PATCH 7/7] bump version --- manifest/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest/manifest.json b/manifest/manifest.json index 2bf69841..734d6a15 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "SponsorBlock", - "version": "4.4.2", + "version": "4.4.3", "default_locale": "en", "description": "__MSG_Description__", "homepage_url": "https://sponsor.ajay.app",