mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 12:37:05 +03:00
Added better error checking
This commit is contained in:
16
popup.js
16
popup.js
@@ -208,22 +208,24 @@ function runThePopup() {
|
|||||||
|
|
||||||
function onTabs(tabs) {
|
function onTabs(tabs) {
|
||||||
chrome.tabs.sendMessage(tabs[0].id, {message: 'getVideoID'}, function(result) {
|
chrome.tabs.sendMessage(tabs[0].id, {message: 'getVideoID'}, function(result) {
|
||||||
if (result.videoID) {
|
if (result != undefined && result.videoID) {
|
||||||
loadTabData(tabs, result.videoid);
|
loadTabData(tabs, result.videoID);
|
||||||
}
|
} else if (result == undefined && chrome.runtime.lastError) {
|
||||||
|
//this isn't a YouTube video then, or at least the content script is not loaded
|
||||||
|
displayNoVideo();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadTabData(tabs, currentVideoID) {
|
function loadTabData(tabs, videoID) {
|
||||||
|
if (!videoID) {
|
||||||
if (!currentVideoID) {
|
|
||||||
//this isn't a YouTube video then
|
//this isn't a YouTube video then
|
||||||
displayNoVideo();
|
displayNoVideo();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//load video times for this video
|
//load video times for this video
|
||||||
let sponsorTimeKey = "sponsorTimes" + currentVideoID;
|
let sponsorTimeKey = "sponsorTimes" + videoID;
|
||||||
chrome.storage.sync.get([sponsorTimeKey], function(result) {
|
chrome.storage.sync.get([sponsorTimeKey], function(result) {
|
||||||
let sponsorTimesStorage = result[sponsorTimeKey];
|
let sponsorTimesStorage = result[sponsorTimeKey];
|
||||||
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
|
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user