aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormini-bomba <[email protected]>2024-06-13 01:18:02 +0200
committermini-bomba <[email protected]>2024-06-13 01:18:02 +0200
commit0b946d5ef724cae59347ac089cca9f7f3615062c (patch)
treeb40386a4ea8a98395526705499af93790ecf8324 /src
parentf48c57b1c5368aa29d04ac0b37cd427f96206583 (diff)
downloadSponsorBlock-0b946d5ef724cae59347ac089cca9f7f3615062c.tar.gz
SponsorBlock-0b946d5ef724cae59347ac089cca9f7f3615062c.zip
Don't fetch segments when videoID is null
Also log an error to the console if we ever try to do this in the future
Diffstat (limited to 'src')
-rw-r--r--src/content.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/content.ts b/src/content.ts
index 226caba7..2218aa61 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -264,7 +264,9 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
// it will assume the page is not a video page and stop the refresh animation
sendResponse({ hasVideo: getVideoID() != null });
// fetch segments
- sponsorsLookup(false);
+ if (getVideoID()) {
+ sponsorsLookup(false);
+ }
break;
case "unskip":
@@ -1115,7 +1117,12 @@ async function sponsorsLookup(keepOldSubmissions = true) {
const hashParams = getHashParams();
if (hashParams.requiredSegment) extraRequestData.requiredSegment = hashParams.requiredSegment;
- const hashPrefix = (await getHash(getVideoID(), 1)).slice(0, 4) as VideoID & HashedValue;
+ const videoID = getVideoID()
+ if (!videoID) {
+ console.error("[SponsorBlock] Attempted to fetch segments with a null/undefined videoID.");
+ return;
+ }
+ const hashPrefix = (await getHash(videoID, 1)).slice(0, 4) as VideoID & HashedValue;
const response = await asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, {
categories,
actionTypes: getEnabledActionTypes(),
@@ -2733,4 +2740,4 @@ function checkForMiniplayerPlaying() {
}
}
}
-} \ No newline at end of file
+}