aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/popup.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/popup.ts')
-rw-r--r--src/popup.ts48
1 files changed, 22 insertions, 26 deletions
diff --git a/src/popup.ts b/src/popup.ts
index b986a2ed..2f3a0d7a 100644
--- a/src/popup.ts
+++ b/src/popup.ts
@@ -460,39 +460,35 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
stopLoadingAnimation = null;
}
- if (chrome.runtime.lastError) {
+ if (chrome.runtime.lastError || request == undefined || request.found == undefined) {
//This page doesn't have the injected content script, or at least not yet
+ // Or if the request is empty, meaning the current page is not YouTube or a video page
displayNoVideo();
return;
}
- // if request has no field other than message, then the page currently being browsed is not YouTube
- if (request.found != undefined) {
- //remove loading text
- PageElements.mainControls.style.display = "block";
- if (request.onMobileYouTube) PageElements.mainControls.classList.add("hidden");
- PageElements.whitelistButton.classList.remove("hidden");
- PageElements.loadingIndicator.style.display = "none";
-
- downloadedTimes = request.sponsorTimes ?? [];
- displayDownloadedSponsorTimes(downloadedTimes, request.time);
- if (request.found) {
- PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound");
- PageElements.issueReporterImportExport.classList.remove("hidden");
- } else if (request.status == 404 || request.status == 200) {
- PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404");
- PageElements.issueReporterImportExport.classList.remove("hidden");
+ //remove loading text
+ PageElements.mainControls.style.display = "block";
+ if (request.onMobileYouTube) PageElements.mainControls.classList.add("hidden");
+ PageElements.whitelistButton.classList.remove("hidden");
+ PageElements.loadingIndicator.style.display = "none";
+
+ downloadedTimes = request.sponsorTimes ?? [];
+ displayDownloadedSponsorTimes(downloadedTimes, request.time);
+ if (request.found) {
+ PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound");
+ PageElements.issueReporterImportExport.classList.remove("hidden");
+ } else if (request.status == 404 || request.status == 200) {
+ PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404");
+ PageElements.issueReporterImportExport.classList.remove("hidden");
+ } else {
+ if (request.status) {
+ PageElements.videoFound.innerHTML = chrome.i18n.getMessage("connectionError") + request.status;
} else {
- if (request.status) {
- PageElements.videoFound.innerHTML = chrome.i18n.getMessage("connectionError") + request.status;
- } else {
- PageElements.videoFound.innerHTML = chrome.i18n.getMessage("segmentsStillLoading");
- }
-
- PageElements.issueReporterImportExport.classList.remove("hidden");
+ PageElements.videoFound.innerHTML = chrome.i18n.getMessage("segmentsStillLoading");
}
- } else {
- displayNoVideo();
+
+ PageElements.issueReporterImportExport.classList.remove("hidden");
}
//see if whitelist button should be swapped