From 684cd676e57340a34b0d59cf67ca410320dd20a0 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 4 Jul 2020 15:34:29 -0400 Subject: [PATCH 01/11] Delete empty unsubmitted submissions when delete is called --- src/config.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index fb771545..537f4b11 100644 --- a/src/config.ts +++ b/src/config.ts @@ -109,7 +109,15 @@ class SBMap extends Map { delete(key) { const result = super.delete(key); - this.update(); + // Make sure there are no empty elements + for (const entry of this.entries()) { + if (entry[1].length === 0) { + super.delete(entry[0]); + } + } + + this.update(); + return result; } From dea9dac20a77e9bc753c08cc9030b0e84df0307c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 5 Jul 2020 00:03:52 -0400 Subject: [PATCH 02/11] Fix crashing on mobile youtube --- src/js-components/previewBar.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index bef397c1..e9b52002 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -30,6 +30,8 @@ class PreviewBar { } setupHoverText() { + if (this.onMobileYouTube) return; + let seekBar = document.querySelector(".ytp-progress-bar-container"); // Create label placeholder From 59c5b7eefe78046153c1d8bddd4226f5f6e56807 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 5 Jul 2020 00:05:36 -0400 Subject: [PATCH 03/11] Remove unused function --- src/content.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/content.ts b/src/content.ts index d6a16c39..ead25383 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1011,8 +1011,6 @@ function unskipSponsorTime(segment: SponsorTime) { if (sponsorTimes != null) { //add a tiny bit of time to make sure it is not skipped again video.currentTime = segment.segment[0] + 0.001; - - checkIfInsideSegment(); } } @@ -1020,16 +1018,6 @@ function reskipSponsorTime(segment: SponsorTime) { video.currentTime = segment.segment[1]; } -/** - * Checks if currently inside a segment and will trigger - * a skip schedule if true. - * - * This is used for when a manual skip is finished or a reskip is complete - */ -function checkIfInsideSegment() { - // for -} - function createButton(baseID, title, callback, imageName, isDraggable=false): boolean { if (document.getElementById(baseID + "Button") != null) return false; From 0b9df8a45cd986df0796be6773e809b5d9394898 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 5 Jul 2020 00:07:10 -0400 Subject: [PATCH 04/11] Remove submitting on mobile --- src/content.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/content.ts b/src/content.ts index ead25383..7acf45c6 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1026,18 +1026,10 @@ function createButton(baseID, title, callback, imageName, isDraggable=false): bo newButton.draggable = isDraggable; newButton.id = baseID + "Button"; newButton.classList.add("playerButton"); - if (!onMobileYouTube) { - newButton.classList.add("ytp-button"); - } else { - newButton.classList.add("icon-button"); - newButton.style.padding = "0"; - } + newButton.classList.add("ytp-button"); newButton.setAttribute("title", chrome.i18n.getMessage(title)); newButton.addEventListener("click", (event: Event) => { callback(); - - // Prevents the contols from closing when clicked - if (onMobileYouTube) event.stopPropagation(); }); // Image HTML @@ -1079,6 +1071,8 @@ function getControls(): HTMLElement | boolean { //adds all the player controls buttons async function createButtons(): Promise { + if (onMobileYouTube) return; + let result = await utils.wait(getControls).catch(); //set global controls variable From 87f3cf3881676c7e4bfabd9ffe4cd635353603a3 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 5 Jul 2020 00:09:18 -0400 Subject: [PATCH 05/11] Fixed invidious preview bar --- src/content.ts | 2 +- src/js-components/previewBar.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/content.ts b/src/content.ts index 7acf45c6..c443077b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -418,7 +418,7 @@ function createPreviewBar(): void { const el = document.querySelectorAll(selector); if (el && el.length && el[0]) { - previewBar = new PreviewBar(el[0], onMobileYouTube); + previewBar = new PreviewBar(el[0], onMobileYouTube, onInvidious); updatePreviewBar(); diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index e9b52002..f91e9a58 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -13,16 +13,18 @@ class PreviewBar { container: HTMLUListElement; parent: any; onMobileYouTube: boolean; + onInvidious: boolean; timestamps: number[][]; types: string; - constructor(parent, onMobileYouTube) { + constructor(parent, onMobileYouTube, onInvidious) { this.container = document.createElement('ul'); this.container.id = 'previewbar'; this.parent = parent; this.onMobileYouTube = onMobileYouTube; + this.onInvidious = onInvidious; this.updatePosition(parent); @@ -30,7 +32,7 @@ class PreviewBar { } setupHoverText() { - if (this.onMobileYouTube) return; + if (this.onMobileYouTube || this.onInvidious) return; let seekBar = document.querySelector(".ytp-progress-bar-container"); From fe8f25fe2342dfa3b2a1c0ac7ecb8d7abef6c117 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 5 Jul 2020 00:11:29 -0400 Subject: [PATCH 06/11] Hide submit button on invidious --- src/content.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content.ts b/src/content.ts index c443077b..9b824001 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1199,9 +1199,9 @@ async function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) { ( document.getElementById("startSponsorImage")).src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png"); document.getElementById("startSponsorButton").setAttribute("title", chrome.i18n.getMessage("sponsorStart")); - if (document.getElementById("startSponsorImage").style.display != "none" && uploadButtonVisible && !Config.config.hideUploadButtonPlayerControls) { + if (document.getElementById("startSponsorImage").style.display != "none" && uploadButtonVisible && !Config.config.hideUploadButtonPlayerControls && !onInvidious) { document.getElementById("submitButton").style.display = "unset"; - } else if (!uploadButtonVisible) { + } else if (!uploadButtonVisible || onInvidious) { //disable submit button document.getElementById("submitButton").style.display = "none"; } From bd60875c66010d59270b9abeb53572e1eed6e807 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 5 Jul 2020 00:17:54 -0400 Subject: [PATCH 07/11] Fix invidious css issues --- public/content.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/content.css b/public/content.css index 95009d26..651136fd 100644 --- a/public/content.css +++ b/public/content.css @@ -140,6 +140,7 @@ color: rgb(235, 235, 235); border: none; display: inline-block; + font-size: 13.3333px !important; cursor: pointer; @@ -179,6 +180,7 @@ .sponsorSkipNoticeCloseButton { height: 10px; width: 10px; + box-sizing: unset; padding: 2px 5px; From 48861439b7ed4b27e77a684c98f456489de6fc58 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 5 Jul 2020 00:21:26 -0400 Subject: [PATCH 08/11] Don't run time without skips on mobile or invidious --- src/content.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index 9b824001..7a74ddc3 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1574,6 +1574,8 @@ function updateAdFlag() { } function showTimeWithoutSkips(allSponsorTimes): void { + if (onMobileYouTube || onInvidious) return; + let skipDuration = 0; // Calculate skipDuration based from the segments in the preview bar @@ -1587,7 +1589,7 @@ function showTimeWithoutSkips(allSponsorTimes): void { // YouTube player time display let display = document.getElementsByClassName("ytp-time-display notranslate")[0]; - if (display === undefined) return + if (!display) return; let formatedTime = utils.getFormattedTime(video.duration - skipDuration); From 2d74ce209351118216a4fc3af3e2c99119e3f05f Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 12 Jul 2020 18:52:36 -0400 Subject: [PATCH 09/11] Added hours to time with skips --- src/utils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index ceaefeda..53e4d694 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -331,9 +331,10 @@ class Utils { return seconds % 60; } - getFormattedTime(seconds: number, precise?: boolean) { - let minutes = Math.floor(seconds / 60); - let secondsNum: number = seconds - minutes * 60; + getFormattedTime(seconds: number, precise?: boolean): string { + let hours = Math.floor(seconds / 60 / 60); + let minutes = Math.floor(seconds / 60) % 60; + let secondsNum = seconds % 60; if (!precise) { secondsNum = Math.floor(secondsNum); } @@ -345,7 +346,7 @@ class Utils { secondsDisplay = "0" + secondsDisplay; } - let formatted = minutes + ":" + secondsDisplay; + let formatted = (hours ? hours + ":" : "") + minutes + ":" + secondsDisplay; return formatted; } From 3dc6563048155a9012ad2f2d905d945ae12350af Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 12 Jul 2020 20:59:35 -0400 Subject: [PATCH 10/11] Default to blank category when submitting --- public/_locales/en/messages.json | 6 ++++++ src/components/SponsorTimeEditComponent.tsx | 7 ++++++- src/components/SubmissionNoticeComponent.tsx | 9 ++++++++- src/config.ts | 7 +++++++ src/content.ts | 3 +-- src/popup.ts | 2 +- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 862d69bc..7d9a496e 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -571,6 +571,12 @@ "moreCategories": { "message": "More Categories" }, + "chooseACategory": { + "message": "Choose a Category" + }, + "youMustSelectACategory": { + "message": "You must select a category for all segments you are submitting!" + }, "bracketEnd": { "message": "(End)" }, diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index efcf595a..396bfba8 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -230,7 +230,12 @@ class SponsorTimeEditComponent extends React.Component + {chrome.i18n.getMessage("chooseACategory")} + + )]; for (const category of Config.config.categorySelections) { elements.push( diff --git a/src/components/SubmissionNoticeComponent.tsx b/src/components/SubmissionNoticeComponent.tsx index a545c340..aa59b3c2 100644 --- a/src/components/SubmissionNoticeComponent.tsx +++ b/src/components/SubmissionNoticeComponent.tsx @@ -167,9 +167,16 @@ class SubmissionNoticeComponent extends React.Component, segmentTimes: SBMap, + defaultCategory: string, whitelistedChannels: string[], forceChannelCheck: boolean, startSponsorKeybind: string, @@ -40,6 +41,7 @@ interface SBConfig { // Preview bar barTypes: { + "preview-chooseACategory": PreviewBarOption, "sponsor": PreviewBarOption, "preview-sponsor": PreviewBarOption, "intro": PreviewBarOption, @@ -137,6 +139,7 @@ var Config: SBObject = { defaults: { userID: null, segmentTimes: new SBMap("segmentTimes"), + defaultCategory: "chooseACategory", whitelistedChannels: [], forceChannelCheck: false, startSponsorKeybind: ";", @@ -171,6 +174,10 @@ var Config: SBObject = { // Preview bar barTypes: { + "preview-chooseACategory": { + color: "#ffffff", + opacity: "0.7" + }, "sponsor": { color: "#00d400", opacity: "0.7" diff --git a/src/content.ts b/src/content.ts index 7a74ddc3..7e4c190e 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1150,8 +1150,7 @@ function startSponsorClicked() { sponsorTimesSubmitting.push({ segment: [getRealCurrentTime()], UUID: null, - // Default to sponsor - category: "sponsor" + category: Config.config.defaultCategory }); } diff --git a/src/popup.ts b/src/popup.ts index 239fefbd..68f208c7 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -338,7 +338,7 @@ async function runThePopup(messageListener?: MessageListener) { if (sponsorTimes[sponsorTimesIndex] == undefined) { sponsorTimes[sponsorTimesIndex] = { segment: [], - category: "sponsor", + category: Config.config.defaultCategory, UUID: null }; } From 896120d311568abe54f2af45c41471b3c16a3f7e Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 12 Jul 2020 23:07:55 -0400 Subject: [PATCH 11/11] Update version number --- manifest/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest/manifest.json b/manifest/manifest.json index d2626d74..c947341f 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "SponsorBlock", - "version": "2.0.3", + "version": "2.0.4", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [{