From 38b1dda20bfeb4b6058ba98615866f450921c42c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 18 Oct 2021 19:51:44 -0400 Subject: [PATCH] Add support for required segment parameter --- src/content.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index 5a4415c6..7a064561 100644 --- a/src/content.ts +++ b/src/content.ts @@ -676,12 +676,25 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) { categories.push(categorySelection.name); } + const extraRequestData: Record = {}; + const windowHash = window.location.hash.substr(1); + if (windowHash) { + const params: Record = windowHash.split('&').reduce((acc, param) => { + const [key, value] = param.split('='); + acc[key] = value; + return acc; + }, {}); + + if (params.requiredSegment) extraRequestData.requiredSegment = params.requiredSegment; + } + // Check for hashPrefix setting const hashPrefix = (await utils.getHash(id, 1)).substr(0, 4); const response = await utils.asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, { categories, actionTypes: Config.config.muteSegments ? [ActionType.Skip, ActionType.Mute] : [ActionType.Skip], - userAgent: `${chrome.runtime.id}` + userAgent: `${chrome.runtime.id}`, + ...extraRequestData }); if (response?.ok) {