From e126b59078b18624915dcf8213fa4132fc0e0580 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 18 Aug 2021 02:07:24 -0400 Subject: [PATCH] Added skip button in control bar instead of using skip notice --- manifest/manifest.json | 1 + public/content.css | 13 ++++ .../PlayerCancelSegmentIconSponsorBlocker.svg | 7 +- public/icons/skipIcon.svg | 71 +++++++++++++++++++ .../CategorySkipOptionsComponent.tsx | 5 +- src/components/SkipNoticeComponent.tsx | 22 ++---- src/components/SponsorTimeEditComponent.tsx | 13 ++-- src/content.ts | 50 +++++++++---- src/js-components/skipButtonControlBar.ts | 70 ++++++++++++++++++ src/utils.ts | 12 +--- src/utils/categoryUtils.ts | 23 ++++++ 11 files changed, 237 insertions(+), 50 deletions(-) create mode 100644 public/icons/skipIcon.svg create mode 100644 src/js-components/skipButtonControlBar.ts create mode 100644 src/utils/categoryUtils.ts diff --git a/manifest/manifest.json b/manifest/manifest.json index e0565a39..3ac8ee6f 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -41,6 +41,7 @@ "icons/help.svg", "icons/report.png", "icons/close.png", + "icons/skipIcon.svg", "icons/refresh.svg", "icons/beep.ogg", "icons/pause.svg", diff --git a/public/content.css b/public/content.css index 55e4b63e..7494d7fb 100644 --- a/public/content.css +++ b/public/content.css @@ -501,4 +501,17 @@ input::-webkit-inner-spin-button { .sbChatClose { height: 14px; cursor: pointer; +} + +.skipButtonControlBarContainer { + cursor: pointer; + display: flex; +} + +#sbSkipIconControlBarImage { + height: 60%; + top: 0px; + bottom: 0px; + display: block; + margin: auto; } \ No newline at end of file diff --git a/public/icons/PlayerCancelSegmentIconSponsorBlocker.svg b/public/icons/PlayerCancelSegmentIconSponsorBlocker.svg index 6b48b6d0..619b4b04 100644 --- a/public/icons/PlayerCancelSegmentIconSponsorBlocker.svg +++ b/public/icons/PlayerCancelSegmentIconSponsorBlocker.svg @@ -41,12 +41,13 @@ id="namedview18" showgrid="false" inkscape:zoom="0.83098592" - inkscape:cx="-238.41697" - inkscape:cy="258.22009" + inkscape:cx="220.07455" + inkscape:cy="308.76246" inkscape:window-x="477" inkscape:window-y="961" inkscape:window-maximized="1" - inkscape:current-layer="svg16" /> + inkscape:current-layer="svg16" + inkscape:pagecheckerboard="true" /> + + LogoSponsorBlocker2 + + + + diff --git a/src/components/CategorySkipOptionsComponent.tsx b/src/components/CategorySkipOptionsComponent.tsx index 9a134a5e..370e1bb0 100644 --- a/src/components/CategorySkipOptionsComponent.tsx +++ b/src/components/CategorySkipOptionsComponent.tsx @@ -4,6 +4,7 @@ import Config from "../config" import { Category, CategorySkipOption } from "../types"; import Utils from "../utils"; +import { getCategoryActionType } from "../utils/categoryUtils"; const utils = new Utils(); export interface CategorySkipOptionsProps { @@ -152,12 +153,12 @@ class CategorySkipOptionsComponent extends React.Component - {chrome.i18n.getMessage(optionName !== "disable" ? optionName + utils.getCategoryActionType(this.props.category) + {chrome.i18n.getMessage(optionName !== "disable" ? optionName + getCategoryActionType(this.props.category) : optionName)} ); diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index 63a53165..a98e2f4d 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -5,8 +5,7 @@ import { Category, ContentContainer, CategoryActionType, SponsorHideType, Sponso import NoticeComponent from "./NoticeComponent"; import NoticeTextSelectionComponent from "./NoticeTextSectionComponent"; -import Utils from "../utils"; -const utils = new Utils(); +import { getCategoryActionType, getSkippingText } from "../utils/categoryUtils"; export enum SkipNoticeAction { None, @@ -82,18 +81,7 @@ class SkipNoticeComponent extends React.Component 1 ? "multipleSegments" - : "category_" + this.segments[0].category + "_short") || chrome.i18n.getMessage("category_" + this.segments[0].category); - let noticeTitle = ""; - if (this.autoSkip) { - const messageId = utils.getCategoryActionType(this.segments[0].category) === CategoryActionType.Skippable - ? "skipped" : "skipped_to_category"; - noticeTitle = chrome.i18n.getMessage(messageId).replace("{0}", categoryName); - } else { - const messageId = utils.getCategoryActionType(this.segments[0].category) === CategoryActionType.Skippable - ? "skip_category" : "skip_to_category"; - noticeTitle = chrome.i18n.getMessage(messageId).replace("{0}", categoryName); - } + const noticeTitle = getSkippingText(this.segments, this.props.autoSkip); const previousSkipNotices = document.getElementsByClassName("sponsorSkipNoticeParent"); this.amountOfPreviousNotices = previousSkipNotices.length; @@ -308,7 +296,7 @@ class SkipNoticeComponent extends React.Component 1 - || utils.getCategoryActionType(this.segments[0].category) !== CategoryActionType.POI + || getCategoryActionType(this.segments[0].category) !== CategoryActionType.POI || this.props.unskipTime) { return ( @@ -451,7 +439,7 @@ class SkipNoticeComponent extends React.Component utils.getCategoryActionType(cat as Category) === CategoryActionType.Skippable)); + const categories = CompileConfig.categoryList.filter((cat => getCategoryActionType(cat as Category) === CategoryActionType.Skippable)); for (const category of categories) { elements.push(