Skip to content

Commit

Permalink
Refractor not on video page in popup
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Mar 3, 2024
1 parent 6413c35 commit 0237af4
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,38 +441,34 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
stopLoadingAnimation = null;
}

if (chrome.runtime.lastError) {
//This page doesn't have the injected content script, or at least not yet
if (chrome.runtime.lastError || request.found == undefined) {
// This page doesn't have the injected content script, or at least not yet
// or if request is undefined, then the page currently being browsed is not Bilibili
displayNoVideo();
return;
}

// if request is undefined, then the page currently being browsed is not Bilibili
if (request.found != undefined) {
//remove loading text
PageElements.mainControls.style.display = "block";
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";
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
Expand Down

0 comments on commit 0237af4

Please sign in to comment.