aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2020-02-08 22:45:22 -0500
committerGitHub <[email protected]>2020-02-08 22:45:22 -0500
commit22cc51734fe23cfd1c6eeb85d8c18a3d6770eec0 (patch)
treeb6600b792e144d7ee12c84ba418904b9c3dd3921
parentcd5adc1b824e1f58b574736b976a74ae8e7085fc (diff)
parentb7e83a0efe267c470333681f5ff499b3adf965d6 (diff)
downloadSponsorBlock-22cc51734fe23cfd1c6eeb85d8c18a3d6770eec0.tar.gz
SponsorBlock-22cc51734fe23cfd1c6eeb85d8c18a3d6770eec0.zip
Merge pull request #264 from ajayyy/privacy-confirm
Added privacy confirmation for unlisted videos
-rw-r--r--public/_locales/en/messages.json9
-rw-r--r--public/options/options.html17
-rw-r--r--src/config.ts6
-rw-r--r--src/content.ts41
4 files changed, 70 insertions, 3 deletions
diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json
index 12625d80..db260eb0 100644
--- a/public/_locales/en/messages.json
+++ b/public/_locales/en/messages.json
@@ -419,5 +419,14 @@
},
"areYouSureReset": {
"message": "Are you sure you would like to reset this?"
+ },
+ "confirmPrivacy": {
+ "message": "The video has been detected as unlisted. Click cancel if you do not want to check for sponsors."
+ },
+ "unlistedCheck": {
+ "message": "Ignore Unlisted Videos"
+ },
+ "whatUnlistedCheck": {
+ "message": "This setting will significantly slow down SponsorBlock. Sponsor lookups require sending the video ID to the server. If you are concerned about unlisted video IDs being sent over the internet, enable this option."
}
}
diff --git a/public/options/options.html b/public/options/options.html
index 52530d36..72916c3a 100644
--- a/public/options/options.html
+++ b/public/options/options.html
@@ -261,6 +261,23 @@
<div class="small-description">__MSG_whatViewTracking__</div>
</div>
+
+ <br/>
+ <br/>
+
+ <div option-type="toggle" sync-option="checkForUnlistedVideos">
+ <label class="switch-container" label-name="__MSG_unlistedCheck__">
+ <label class="switch">
+ <input type="checkbox">
+ <span class="slider round"></span>
+ </label>
+ </label>
+
+ <br/>
+ <br/>
+
+ <div class="small-description">__MSG_whatUnlistedCheck__</div>
+ </div>
<br/>
<br/>
diff --git a/src/config.ts b/src/config.ts
index cbb8d40f..7ad653cd 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -24,7 +24,8 @@ interface SBConfig {
autoUpvote: boolean,
supportInvidious: boolean,
serverAddress: string,
- minDuration: number
+ minDuration: number,
+ checkForUnlistedVideos: boolean
}
interface SBObject {
@@ -119,7 +120,8 @@ var Config: SBObject = {
autoUpvote: true,
supportInvidious: false,
serverAddress: CompileConfig.serverAddress,
- minDuration: 0
+ minDuration: 0,
+ checkForUnlistedVideos: false
},
localConfig: null,
config: null
diff --git a/src/content.ts b/src/content.ts
index 4ca4f1e5..dba13c35 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -230,7 +230,7 @@ function resetValues() {
sponsorDataFound = false;
}
-function videoIDChange(id) {
+async function videoIDChange(id) {
//if the id has not changed return
if (sponsorVideoID === id) return;
@@ -242,6 +242,19 @@ function videoIDChange(id) {
//id is not valid
if (!id) return;
+ // Wait for options to be ready
+ await utils.wait(() => Config.config !== null, 5000, 1);
+
+ // If enabled, it will check if this video is private or unlisted and double check with the user if the sponsors should be looked up
+ if (Config.config.checkForUnlistedVideos) {
+ await utils.wait(isPrivacyInfoAvailable);
+
+ if (isUnlisted()) {
+ let shouldContinue = confirm(chrome.i18n.getMessage("confirmPrivacy"));
+ if(!shouldContinue) return;
+ }
+ }
+
// TODO: Use a better method here than using type any
// This is done to be able to do channelIDPromise.isFulfilled and channelIDPromise.isRejected
let channelIDPromise: any = utils.wait(getChannelID);
@@ -1121,6 +1134,32 @@ function getSponsorTimesMessage(sponsorTimes) {
return sponsorTimesMessage;
}
+// Privacy utils
+function isPrivacyInfoAvailable(): boolean {
+ if(document.location.pathname.startsWith("/embed/")) return true;
+ return document.getElementsByClassName("style-scope ytd-badge-supported-renderer").length >= 2;
+}
+
+/**
+ * What privacy level is this YouTube video?
+ */
+function getPrivacy(): string {
+ if(document.location.pathname.startsWith("/embed/")) return "Public";
+
+ let privacyElement = <HTMLElement> document.getElementsByClassName("style-scope ytd-badge-supported-renderer")[2];
+ return privacyElement.innerText;
+}
+
+/**
+ * Is this an unlisted YouTube video.
+ * Assumes that the the privacy info is available.
+ */
+function isUnlisted(): boolean {
+ let privacyElement = <HTMLElement> document.getElementsByClassName("style-scope ytd-badge-supported-renderer")[2];
+
+ return privacyElement.innerText.toLocaleLowerCase() === "unlisted";
+}
+
/**
* Adds the CSS to the page if needed. Required on optional sites with Chrome.
*/