Refractor popup infoFound() empty message detection

This commit is contained in:
HanYaodong
2024-03-09 23:47:48 +08:00
parent 25b53754ba
commit a1505bcf20

View File

@@ -460,14 +460,13 @@ 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");
@@ -491,9 +490,6 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
PageElements.issueReporterImportExport.classList.remove("hidden");
}
} else {
displayNoVideo();
}
//see if whitelist button should be swapped
const response = await sendTabMessageAsync({ message: 'isChannelWhitelisted' }) as IsChannelWhitelistedResponse;