diff options
-rw-r--r-- | public/_locales/en/messages.json | 12 | ||||
-rw-r--r-- | src/content.ts | 28 | ||||
-rw-r--r-- | src/popup.ts | 3 |
3 files changed, 18 insertions, 25 deletions
diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index e5320d68..a4a48b9a 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -424,10 +424,10 @@ "message": "The video has been detected as unlisted. Click cancel if you do not want to check for sponsors." }, "unlistedCheck": { - "message": "Ignore Unlisted Videos" + "message": "Ignore Unlisted/Private 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." + "message": "This setting will slightly 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." }, "mobileUpdateInfo": { "message": "m.youtube.com is now supported" @@ -542,6 +542,12 @@ "message": "hidden: too short" }, "channelDataNotFound": { - "message": "Channel ID not loaded yet" + "message": "Channel ID not loaded yet." + }, + "adblockerIssue": { + "message": "It seems that something is blocking SponsorBlock's ability to get video data. This is probably uBlock. Please check https://github.com/ajayyy/SponsorBlock/wiki/Fix-uBlock-Origin-Blocking-YouTube-Requests" + }, + "itCouldBeAdblockerIssue": { + "message": "If this keeps occuring, it could be caused by uBlock. Please check https://github.com/ajayyy/SponsorBlock/wiki/Fix-uBlock-Origin-Blocking-YouTube-Requests" } } diff --git a/src/content.ts b/src/content.ts index a2a1a5ab..a8f89589 100644 --- a/src/content.ts +++ b/src/content.ts @@ -301,7 +301,11 @@ async function videoIDChange(id) { // 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); + try { + await utils.wait(() => !!videoInfo, 5000, 10); + } catch (err) { + alert(chrome.i18n.getMessage("adblockerIssue")); + } if (isUnlisted()) { let shouldContinue = confirm(chrome.i18n.getMessage("confirmPrivacy")); @@ -310,7 +314,7 @@ async function videoIDChange(id) { } // Update whitelist data when the video data is loaded - utils.wait(() => !!videoInfo).then(whitelistCheck); + utils.wait(() => !!videoInfo, 5000, 10).then(whitelistCheck); //setup the preview bar if (previewBar === null) { @@ -1486,30 +1490,12 @@ function getSegmentsMessage(segments: number[][]): string { 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"; + return videoInfo.microformat.playerMicroformatRenderer.isUnlisted || videoInfo.videoDetails.isPrivate; } /** diff --git a/src/popup.ts b/src/popup.ts index 0df67c40..93ab75ca 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -922,7 +922,8 @@ async function runThePopup(messageListener?: MessageListener) { {message: 'getChannelID'}, function(response) { if (!response.channelID) { - alert(chrome.i18n.getMessage("channelDataNotFound")); + alert(chrome.i18n.getMessage("channelDataNotFound") + "\n\n" + + chrome.i18n.getMessage("itCouldBeAdblockerIssue")); return; } |