aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2019-07-10 11:55:09 -0400
committerAjay Ramachandran <[email protected]>2019-07-10 11:55:09 -0400
commit493fb3fc7219131040a369e7bb1f46928192cb3c (patch)
tree138fd139c21936413ae3a9266bd6b071977ba4f7
parent9218aed94efaa86491186ddcb446be0a44fe8010 (diff)
downloadSponsorBlock-493fb3fc7219131040a369e7bb1f46928192cb3c.tar.gz
SponsorBlock-493fb3fc7219131040a369e7bb1f46928192cb3c.zip
Changed the way it detects when a page is not YouTube and prevented lastError.
-rw-r--r--popup.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/popup.js b/popup.js
index 3b6d337c..93f60182 100644
--- a/popup.js
+++ b/popup.js
@@ -25,14 +25,6 @@ chrome.storage.local.get(["dontShowNoticeAgain"], function(result) {
}
});
-//if no response comes by this point, give up
-setTimeout(function() {
- if (!isYouTubeTab) {
- document.getElementById("loadingIndicator").innerHTML = "This probably isn't a YouTube tab, or you clicked too early. " +
- "If you know this is a YouTube tab, close this popup and open it again.";
- }
-}, 100);
-
chrome.tabs.query({
active: true,
currentWindow: true
@@ -72,6 +64,13 @@ function loadTabData(tabs) {
}
function infoFound(request) {
+ if(chrome.runtime.lastError) {
+ //This page doesn't have the injected content script, or at least not yet
+ document.getElementById("loadingIndicator").innerHTML = "This probably isn't a YouTube tab, or you clicked too early. " +
+ "If you know this is a YouTube tab, close this popup and open it again.";
+ return;
+ }
+
//if request is undefined, then the page currently being browsed is not YouTube
if (request != undefined) {
//this must be a YouTube video