Remove hash prefix option (always uses hash prefix)

This commit is contained in:
Ajay Ramachandran
2021-05-19 16:11:07 -04:00
parent ac6cd2cec1
commit 3ef2673bfc
3 changed files with 11 additions and 49 deletions

View File

@@ -309,23 +309,6 @@
<br/>
<br/>
<div option-type="toggle" sync-option="hashPrefix">
<label class="switch-container" label-name="__MSG_enableQueryByHashPrefix__">
<label class="switch">
<input type="checkbox" checked>
<span class="slider round"></span>
</label>
</label>
<br/>
<br/>
<div class="small-description">__MSG_whatQueryByHashPrefix__</div>
</div>
<br/>
<br/>
<div option-type="toggle" sync-option="refetchWhenNotFound">
<label class="switch-container" label-name="__MSG_enableRefetchWhenNotFound__">
<label class="switch">

View File

@@ -35,7 +35,6 @@ interface SBConfig {
audioNotificationOnSkip,
checkForUnlistedVideos: boolean,
testingServer: boolean,
hashPrefix: boolean,
refetchWhenNotFound: boolean,
ytInfoPermissionGranted: boolean,
@@ -169,7 +168,6 @@ const Config: SBObject = {
audioNotificationOnSkip: false,
checkForUnlistedVideos: false,
testingServer: false,
hashPrefix: true,
refetchWhenNotFound: true,
ytInfoPermissionGranted: false,

View File

@@ -564,33 +564,22 @@ async function sponsorsLookup(id: string) {
}
// Check for hashPrefix setting
let getRequest;
if (Config.config.hashPrefix) {
const hashPrefix = (await utils.getHash(id, 1)).substr(0, 4);
getRequest = utils.asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, {
categories
});
} else {
getRequest = utils.asyncRequestToServer('GET', "/api/skipSegments", {
videoID: id,
categories
});
}
getRequest.then(async (response: FetchResponse) => {
const hashPrefix = (await utils.getHash(id, 1)).substr(0, 4);
utils.asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, {
categories
}).then(async (response: FetchResponse) => {
if (response?.ok) {
let result = JSON.parse(response.responseText);
if (Config.config.hashPrefix) {
result = result.filter((video) => video.videoID === id);
if (result.length > 0) {
result = result[0].segments;
if (result.length === 0) { // return if no segments found
retryFetch(id);
return;
}
} else { // return if no video found
result = result.filter((video) => video.videoID === id);
if (result.length > 0) {
result = result[0].segments;
if (result.length === 0) { // return if no segments found
retryFetch(id);
return;
}
} else { // return if no video found
retryFetch(id);
return;
}
const recievedSegments: SponsorTime[] = result;
@@ -1594,14 +1583,6 @@ function hotkeyListener(e: KeyboardEvent): void {
}
}
/**
* Is this an unlisted YouTube video.
* Assumes that the the privacy info is available.
*/
function isUnlisted(): boolean {
return videoInfo?.microformat?.playerMicroformatRenderer?.isUnlisted || videoInfo?.videoDetails?.isPrivate;
}
/**
* Adds the CSS to the page if needed. Required on optional sites with Chrome.
*/