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 | |
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
-rw-r--r-- | public/_locales/en/messages.json | 3 | ||||
-rw-r--r-- | public/options/options.html | 13 | ||||
-rw-r--r-- | src/config.ts | 2 | ||||
-rw-r--r-- | src/content.ts | 4 | ||||
-rw-r--r-- | src/options.ts | 9 |
5 files changed, 29 insertions, 2 deletions
diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index d2b49402..a48335e6 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -200,6 +200,9 @@ "whatViewTracking": { "message": "This feature tracks which segments you have skipped to let users know how much their submission has helped others and used as a metric along with upvotes to ensure that spam doesn't get into the database. The extension sends a message to the server each time you skip a segment. Hopefully most people don't change this setting so that the view numbers are accurate. :)" }, + "enableViewTrackingInPrivate": { + "message": "Enable Skip Count Tracking In Private/Incognito tabs" + }, "enableQueryByHashPrefix": { "message": "Query By Hash Prefix" }, diff --git a/public/options/options.html b/public/options/options.html index 5feb6ba9..6b5bb717 100644 --- a/public/options/options.html +++ b/public/options/options.html @@ -310,6 +310,19 @@ <br/> <br/> + <div option-type="toggle" sync-option="trackViewCountInPrivate" private-mode-only="true"> + <label class="switch-container" label-name="__MSG_enableViewTrackingInPrivate__"> + <label class="switch"> + <input type="checkbox" checked> + <span class="slider round"></span> + </label> + </label> + + <br/> + <br/> + <br/> + </div> + <div option-type="toggle" sync-option="refetchWhenNotFound"> <label class="switch-container" label-name="__MSG_enableRefetchWhenNotFound__"> <label class="switch"> 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 |