Add new channel ID detection logic

This commit is contained in:
Ajay Ramachandran
2021-05-19 16:08:09 -04:00
parent 995ed929ca
commit ac6cd2cec1
3 changed files with 38 additions and 50 deletions

View File

@@ -410,15 +410,6 @@
"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 skip segments."
},
"unlistedCheck": {
"message": "Ignore Unlisted/Private Videos"
},
"whatUnlistedCheck": {
"message": "This setting will slightly slow down SponsorBlock. Skip segment 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."
},
"mobileUpdateInfo": {
"message": "m.youtube.com is now supported"
},
@@ -609,9 +600,6 @@
"permissionRequestFailed": {
"message": "Permission request failed, did you click deny?"
},
"adblockerIssueUnlistedVideosInfo": {
"message": "If you are unable to resolve this, then disable the setting 'Ignore unlisted/private videos', as SponsorBlock is unable to retrieve the visibility information for this video"
},
"adblockerIssueWhitelist": {
"message": "If you are unable to resolve this, then disable the setting 'Force Channel Check Before Skipping', as SponsorBlock is unable to retrieve the channel information for this video"
},

View File

@@ -343,23 +343,6 @@
<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/>
<div option-type="private-text-change" sync-option="userID" confirm-message="userIDChangeWarning">
<div class="option-button trigger-button">
__MSG_changeUserID__

View File

@@ -253,29 +253,25 @@ async function videoIDChange(id) {
// Wait for options to be ready
await utils.wait(() => Config.config !== null, 5000, 1);
// Get new video info
getVideoInfo();
// 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) {
try {
await utils.wait(() => !!videoInfo, 5000, 1);
} catch (err) {
await videoInfoFetchFailed("adblockerIssueUnlistedVideosInfo");
}
if (isUnlisted()) {
const shouldContinue = confirm(chrome.i18n.getMessage("confirmPrivacy"));
if(!shouldContinue) return;
const shouldContinue = confirm("SponsorBlock: You have the setting 'Ignore Unlisted/Private Videos' enabled."
+ " Due to a change in how segment fetching works, this setting is not needed anymore as it cannot leak your video ID to the server."
+ " It instead sends just the first 4 characters of a longer hash of the videoID to the server, and filters through a subset of the database."
+ " More info about this implementation can be found here: https://github.com/ajayyy/SponsorBlockServer/issues/25"
+ "\n\nPlease click okay to confirm that you acknowledge this and continue using SponsorBlock.");
if (shouldContinue) {
Config.config.checkForUnlistedVideos = false;
} else {
return;
}
}
// Get new video info
getVideoInfo();
// Update whitelist data when the video data is loaded
utils.wait(() => !!videoInfo, 5000, 10).then(whitelistCheck).catch(() => {
if (Config.config.forceChannelCheck) {
videoInfoFetchFailed("adblockerIssueWhitelist");
}
});
whitelistCheck();
//setup the preview bar
if (previewBar === null) {
@@ -833,8 +829,31 @@ function updatePreviewBar(): void {
}
//checks if this channel is whitelisted, should be done only after the channelID has been loaded
function whitelistCheck() {
channelID = videoInfo?.videoDetails?.channelId;
async function whitelistCheck() {
const whitelistedChannels = Config.config.whitelistedChannels;
const getChannelID = () => videoInfo?.videoDetails?.channelId
?? document.querySelector(".ytd-channel-name a")?.getAttribute("href")?.replace(/\/.+\//, "") // YouTube
?? document.querySelector(".ytp-title-channel-logo")?.getAttribute("href")?.replace(/https:\/.+\//, "") // YouTube Embed
?? document.querySelector("a > .channel-profile")?.parentElement?.getAttribute("href")?.replace(/\/.+\//, ""); // Invidious
try {
await utils.wait(() => !!getChannelID(), 6000, 20);
} catch {
if (Config.config.forceChannelCheck) {
// treat as not whitelisted
channelID = "";
// Don't warn for Invidious embeds
if (!(onInvidious && document.URL.includes("/embed/"))) {
videoInfoFetchFailed("adblockerIssueWhitelist");
}
}
return;
}
channelID = getChannelID();
if (!channelID) {
channelID = null;
@@ -842,8 +861,6 @@ function whitelistCheck() {
}
//see if this is a whitelisted channel
const whitelistedChannels = Config.config.whitelistedChannels;
if (whitelistedChannels != undefined && whitelistedChannels.includes(channelID)) {
channelWhitelisted = true;
}