From 664d75e6534d227dbcc447ef6f182befc6c5a1b2 Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 22 Sep 2022 23:27:10 -0400 Subject: [PATCH] Add notice about chapters for free users --- public/_locales/en/messages.json | 3 +++ src/content.ts | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 753992e3..34402632 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -1174,6 +1174,9 @@ "message": "New Feature: Crowd-sourced custom chapters. These are custom-named sections in videos that can be stacked to get more and more precise. Purchase a license to view the chapters submitted on this video such as: ", "description": "After the comma, a list of chapters for this video will appear" }, + "chapterNewFeature2": { + "message": "New Feature: Crowd-sourced custom chapters. These are custom-named sections in videos that can be stacked to get more and more precise. You have access for free, enable in options." + }, "unsubmittedSegmentCounts": { "message": "You currently have {0} on {1}", "description": "Example: You currently have 12 unsubmitted segments on 5 videos" diff --git a/src/content.ts b/src/content.ts index d472c23c..05e23904 100644 --- a/src/content.ts +++ b/src/content.ts @@ -950,6 +950,26 @@ async function sponsorsLookup(keepOldSubmissions = true) { && Config.config.skipCount > 200 && Math.random() > 0.8; + if (!showChapterMessage + && Config.config.showChapterInfoMessage + && Config.config.payments.freeAccess + && !utils.getCategorySelection("chapter")) { + Config.config.showChapterInfoMessage = false; + const prependElement = document.querySelector(".ytp-chrome-bottom") as HTMLElement; + if (prependElement) { + Config.config.showChapterInfoMessage = false; + new Tooltip({ + text: chrome.i18n.getMessage("chapterNewFeature2"), + linkOnClick: () => void chrome.runtime.sendMessage({ "message": "openConfig" }), + referenceNode: prependElement.parentElement, + prependElement, + timeout: 1500, + leftOffset: "20px", + positionRealtive: false + }); + } + } + const categories: string[] = Config.config.categorySelections.map((category) => category.name); if (showChapterMessage && !categories.includes("chapter")) categories.push("chapter"); @@ -999,7 +1019,6 @@ async function sponsorsLookup(keepOldSubmissions = true) { positionRealtive: false }); } - } recievedSegments = recievedSegments.filter((s) => s.actionType !== ActionType.Chapter);