diff options
author | Ajay Ramachandran <[email protected]> | 2021-06-11 18:17:40 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2021-06-11 18:17:40 -0400 |
commit | 8cb212a77bc4cb88dcbd9e841d5397c5b6443609 (patch) | |
tree | bdb8ae94216e5fb4dd9d8e173b927367d86053e2 /src | |
parent | 29b29e3f6e817f8cce2ccc2c9177ccc2779c2ddd (diff) | |
download | SponsorBlock-8cb212a77bc4cb88dcbd9e841d5397c5b6443609.tar.gz SponsorBlock-8cb212a77bc4cb88dcbd9e841d5397c5b6443609.zip |
Allow not counting time in private tabs
Closes https://github.com/ajayyy/SponsorBlock/issues/703
Diffstat (limited to 'src')
-rw-r--r-- | src/config.ts | 2 | ||||
-rw-r--r-- | src/content.ts | 4 | ||||
-rw-r--r-- | src/options.ts | 9 |
3 files changed, 13 insertions, 2 deletions
diff --git a/src/config.ts b/src/config.ts index a80d667d..5cb58a2a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -21,6 +21,7 @@ interface SBConfig { showTimeWithSkips: boolean, disableSkipping: boolean, trackViewCount: boolean, + trackViewCountInPrivate: boolean, dontShowNotice: boolean, hideVideoPlayerControls: boolean, hideInfoButtonPlayerControls: boolean, @@ -154,6 +155,7 @@ const Config: SBObject = { showTimeWithSkips: true, disableSkipping: false, trackViewCount: true, + trackViewCountInPrivate: true, dontShowNotice: false, hideVideoPlayerControls: false, hideInfoButtonPlayerControls: false, diff --git a/src/content.ts b/src/content.ts index ac517c72..c65ff20e 100644 --- a/src/content.ts +++ b/src/content.ts @@ -987,8 +987,8 @@ function previewTime(time: number, unpause = true) { //send telemetry and count skip function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped: number, fullSkip: boolean) { - if (!Config.config.trackViewCount) return; - + if (!Config.config.trackViewCount || (!Config.config.trackViewCountInPrivate && chrome.extension.inIncognitoContext)) return; + let counted = false; for (const segment of skippingSegments) { const index = sponsorTimes.indexOf(segment); diff --git a/src/options.ts b/src/options.ts index 815aff02..20a5d244 100644 --- a/src/options.ts +++ b/src/options.ts @@ -31,6 +31,11 @@ async function init() { const optionsElements = optionsContainer.querySelectorAll("*"); for (let i = 0; i < optionsElements.length; i++) { + if (optionsElements[i].getAttribute("private-mode-only") === "true" && !(await isIncognitoAllowed())) { + optionsElements[i].classList.add("hidden"); + continue; + } + switch (optionsElements[i].getAttribute("option-type")) { case "toggle": { const option = optionsElements[i].getAttribute("sync-option"); @@ -540,3 +545,7 @@ function copyDebugOutputToClipboard() { alert(chrome.i18n.getMessage("copyDebugInformationFailed")); }); } + +function isIncognitoAllowed(): Promise<boolean> { + return new Promise((resolve) => chrome.extension.isAllowedIncognitoAccess(resolve)); +}
\ No newline at end of file |