diff options
author | Ajay Ramachandran <[email protected]> | 2021-10-13 23:14:51 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2021-10-13 23:14:51 -0400 |
commit | ff5fa4c724fe292d9d05c6caf712ce910dec4db9 (patch) | |
tree | 8a257c9996b6121c0b1b81a40825e01d19b4a789 | |
parent | 93e440385f216b635606d270254df0d0bbaa9e1f (diff) | |
download | SponsorBlock-ff5fa4c724fe292d9d05c6caf712ce910dec4db9.tar.gz SponsorBlock-ff5fa4c724fe292d9d05c6caf712ce910dec4db9.zip |
Move config values and close notice
-rw-r--r-- | config.json.example | 12 | ||||
-rw-r--r-- | src/components/SkipNoticeComponent.tsx | 15 | ||||
-rw-r--r-- | src/config.ts | 30 | ||||
-rw-r--r-- | src/content.ts | 3 |
4 files changed, 35 insertions, 25 deletions
diff --git a/config.json.example b/config.json.example index ffc482a5..f6916065 100644 --- a/config.json.example +++ b/config.json.example @@ -12,5 +12,17 @@ "preview": ["skip"], "music_offtopic": ["skip"], "poi_highlight": ["skip"] + }, + "wikiLinks": { + "sponsor": "https://wiki.sponsor.ajay.app/w/Sponsor", + "selfpromo": "https://wiki.sponsor.ajay.app/w/Unpaid/Self_Promotion", + "interaction": "https://wiki.sponsor.ajay.app/w/Interaction_Reminder_(Subscribe)", + "intro": "https://wiki.sponsor.ajay.app/w/Intermission/Intro_Animation", + "outro": "https://wiki.sponsor.ajay.app/w/Endcards/Credits", + "preview": "https://wiki.sponsor.ajay.app/w/Preview/Recap", + "music_offtopic": "https://wiki.sponsor.ajay.app/w/Music:_Non-Music_Section", + "poi_highlight": "https://wiki.sponsor.ajay.app/w/Highlight", + "guidelines": "https://wiki.sponsor.ajay.app/w/Guidelines", + "mute": "https://wiki.sponsor.ajay.app/w/Mute_Segment" } } diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index fa61e339..4664ff76 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -116,9 +116,9 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta } this.idSuffix += this.amountOfPreviousNotices; - this.selectedColor = Config.config.colorPalette.get("SponsorBlockRed"); - this.unselectedColor = Config.config.colorPalette.get("SponsorBlockWhite"); - this.lockedColor = Config.config.colorPalette.get("SponsorBlockLocked"); + this.selectedColor = Config.config.colorPalette.red; + this.unselectedColor = Config.config.colorPalette.white; + this.lockedColor = Config.config.colorPalette.locked; // Setup state this.state = { @@ -627,26 +627,32 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta afterVote(segment: SponsorTime, type: number, category: Category): void { const index = utils.getSponsorIndexFromUUID(this.segments, segment.UUID); - const wikiLinkText = Config.config.wikiPages.get(segment.category); + const wikiLinkText = CompileConfig.wikiLinks[segment.category]; + switch (type) { case 0: this.setNoticeInfoMessageWithOnClick(() => window.open(wikiLinkText), chrome.i18n.getMessage("OpenCategoryWikiPage")); this.setState({ voted: utils.replaceArrayElement(this.state.voted, SkipNoticeAction.Downvote, index) }); + break; case 1: this.setState({ voted: utils.replaceArrayElement(this.state.voted, SkipNoticeAction.Upvote, index) }); + break; case 20: this.setState({ voted: utils.replaceArrayElement(this.state.voted, SkipNoticeAction.None, index) }); + break; } + this.addVoteButtonInfo(chrome.i18n.getMessage("voted")); + // Change the sponsor locally if (segment) { if (type === 0) { @@ -657,6 +663,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta } else if (type === 1) { segment.hidden = SponsorHideType.Visible; } + this.contentContainer().updatePreviewBar(); } } diff --git a/src/config.ts b/src/config.ts index f077d8eb..07a745c9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -46,8 +46,11 @@ interface SBConfig { autoHideInfoButton: boolean, autoSkipOnMusicVideos: boolean, highlightCategoryUpdate: boolean, - wikiPages: SBMap<string, string>, - colorPalette: SBMap<string, string> + colorPalette: { + red: string, + white: string, + locked: string + } // What categories should be skipped categorySelections: CategorySelection[], @@ -203,24 +206,11 @@ const Config: SBObject = { option: CategorySkipOption.AutoSkip }], - wikiPages: new SBMap("wikiLinks", [ - ["sponsor", "https://wiki.sponsor.ajay.app/w/Sponsor"], - ["selfpromo", "https://wiki.sponsor.ajay.app/w/Unpaid/Self_Promotion"], - ["interaction", "https://wiki.sponsor.ajay.app/w/Interaction_Reminder_(Subscribe)"], - ["intro", "https://wiki.sponsor.ajay.app/w/Intermission/Intro_Animation"], - ["outro", "https://wiki.sponsor.ajay.app/w/Endcards/Credits"], - ["preview", "https://wiki.sponsor.ajay.app/w/Preview/Recap"], - ["music_offtopic", "https://wiki.sponsor.ajay.app/w/Music:_Non-Music_Section"], - ["highlight_poi", "https://wiki.sponsor.ajay.app/w/Highlight"], - ["guidelines", "https://wiki.sponsor.ajay.app/w/Guidelines"], - ["mute", "https://wiki.sponsor.ajay.app/w/Mute_Segment"], - ]), - - colorPalette: new SBMap("colorPalette", [ - ["SponsorBlockRed", "#780303"], - ["SponsorBlockWhite", "#ffffff"], - ["SponsorBlockLocked", "#ffc83d"] - ]), + colorPalette: { + red: "#780303", + white: "#ffffff", + locked: "#ffc83d" + }, // Preview bar barTypes: { diff --git a/src/content.ts b/src/content.ts index 4d4c965e..c6694c3f 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1746,7 +1746,8 @@ function resetSponsorSubmissionNotice() { function submitSponsorTimes() { if (submissionNotice !== null){ - submissionNotice.noticeElement.style.display = (submissionNotice.noticeElement.style.display === "none") ? null : "none"; + submissionNotice.close(); + submissionNotice = null; return; } |