Allow not counting time in private tabs

Closes https://github.com/ajayyy/SponsorBlock/issues/703
This commit is contained in:
Ajay Ramachandran
2021-06-11 18:17:40 -04:00
parent 29b29e3f6e
commit 8cb212a77b
5 changed files with 29 additions and 2 deletions

View File

@@ -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"
},

View File

@@ -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">

View File

@@ -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,

View File

@@ -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);

View File

@@ -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));
}