mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 04:27:15 +03:00
Added better error checking
This commit is contained in:
14
popup.js
14
popup.js
@@ -208,22 +208,24 @@ function runThePopup() {
|
||||
|
||||
function onTabs(tabs) {
|
||||
chrome.tabs.sendMessage(tabs[0].id, {message: 'getVideoID'}, function(result) {
|
||||
if (result.videoID) {
|
||||
loadTabData(tabs, result.videoid);
|
||||
if (result != undefined && 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) {
|
||||
|
||||
if (!currentVideoID) {
|
||||
function loadTabData(tabs, videoID) {
|
||||
if (!videoID) {
|
||||
//this isn't a YouTube video then
|
||||
displayNoVideo();
|
||||
return;
|
||||
}
|
||||
|
||||
//load video times for this video
|
||||
let sponsorTimeKey = "sponsorTimes" + currentVideoID;
|
||||
let sponsorTimeKey = "sponsorTimes" + videoID;
|
||||
chrome.storage.sync.get([sponsorTimeKey], function(result) {
|
||||
let sponsorTimesStorage = result[sponsorTimeKey];
|
||||
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user