mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-09-20 13:03:45 +02:00
parent
6b4da25847
commit
b92132bf47
3 changed files with 17 additions and 6 deletions
|
@ -65,8 +65,8 @@ const videosWithEventListeners: HTMLVideoElement[] = [];
|
||||||
const controlsWithEventListeners: HTMLElement[] = []
|
const controlsWithEventListeners: HTMLElement[] = []
|
||||||
|
|
||||||
// This misleading variable name will be fixed soon
|
// This misleading variable name will be fixed soon
|
||||||
let onInvidious;
|
let onInvidious: boolean;
|
||||||
let onMobileYouTube;
|
let onMobileYouTube: boolean;
|
||||||
|
|
||||||
//the video id of the last preview bar update
|
//the video id of the last preview bar update
|
||||||
let lastPreviewBarUpdate;
|
let lastPreviewBarUpdate;
|
||||||
|
@ -117,6 +117,9 @@ let submissionNotice: SubmissionNotice = null;
|
||||||
// If there is an advert playing (or about to be played), this is true
|
// If there is an advert playing (or about to be played), this is true
|
||||||
let isAdPlaying = false;
|
let isAdPlaying = false;
|
||||||
|
|
||||||
|
// last response status
|
||||||
|
let lastResponseStatus: number;
|
||||||
|
|
||||||
// Contains all of the functions and variables needed by the skip notice
|
// Contains all of the functions and variables needed by the skip notice
|
||||||
const skipNoticeContentContainer: ContentContainer = () => ({
|
const skipNoticeContentContainer: ContentContainer = () => ({
|
||||||
vote,
|
vote,
|
||||||
|
@ -163,6 +166,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
||||||
//send the sponsor times along with if it's found
|
//send the sponsor times along with if it's found
|
||||||
sendResponse({
|
sendResponse({
|
||||||
found: sponsorDataFound,
|
found: sponsorDataFound,
|
||||||
|
status: lastResponseStatus,
|
||||||
sponsorTimes: sponsorTimes,
|
sponsorTimes: sponsorTimes,
|
||||||
onMobileYouTube
|
onMobileYouTube
|
||||||
});
|
});
|
||||||
|
@ -204,6 +208,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
||||||
case "refreshSegments":
|
case "refreshSegments":
|
||||||
sponsorsLookup(false).then(() => sendResponse({
|
sponsorsLookup(false).then(() => sendResponse({
|
||||||
found: sponsorDataFound,
|
found: sponsorDataFound,
|
||||||
|
status: lastResponseStatus,
|
||||||
sponsorTimes: sponsorTimes,
|
sponsorTimes: sponsorTimes,
|
||||||
onMobileYouTube
|
onMobileYouTube
|
||||||
}));
|
}));
|
||||||
|
@ -904,9 +909,12 @@ async function sponsorsLookup(keepOldSubmissions = true) {
|
||||||
//otherwise the listener can handle it
|
//otherwise the listener can handle it
|
||||||
updatePreviewBar();
|
updatePreviewBar();
|
||||||
}
|
}
|
||||||
} else if (response?.status === 404) {
|
} else {
|
||||||
|
lastResponseStatus = response?.status;
|
||||||
|
if (lastResponseStatus === 404) {
|
||||||
retryFetch();
|
retryFetch();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Config.config.isVip) {
|
if (Config.config.isVip) {
|
||||||
lockedCategoriesLookup();
|
lockedCategoriesLookup();
|
||||||
|
|
|
@ -63,6 +63,7 @@ export type Message = BaseMessage & (DefaultMessage | BoolValueMessage | IsInfoF
|
||||||
|
|
||||||
export interface IsInfoFoundMessageResponse {
|
export interface IsInfoFoundMessageResponse {
|
||||||
found: boolean;
|
found: boolean;
|
||||||
|
status: number;
|
||||||
sponsorTimes: SponsorTime[];
|
sponsorTimes: SponsorTime[];
|
||||||
onMobileYouTube: boolean;
|
onMobileYouTube: boolean;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +90,7 @@ export type MessageResponse =
|
||||||
| GetChannelIDResponse
|
| GetChannelIDResponse
|
||||||
| SponsorStartResponse
|
| SponsorStartResponse
|
||||||
| IsChannelWhitelistedResponse
|
| IsChannelWhitelistedResponse
|
||||||
| Record<string, never>
|
| Record<never, never> // empty object response {}
|
||||||
| VoteResponse;
|
| VoteResponse;
|
||||||
|
|
||||||
export interface VoteResponse {
|
export interface VoteResponse {
|
||||||
|
|
|
@ -367,8 +367,10 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
||||||
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound");
|
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound");
|
||||||
|
|
||||||
displayDownloadedSponsorTimes(request);
|
displayDownloadedSponsorTimes(request);
|
||||||
} else {
|
} else if (request.status == 404) {
|
||||||
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404");
|
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404");
|
||||||
|
} else {
|
||||||
|
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("connectionError") + request.status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue