Fixed sponsor times not properly saving

This commit is contained in:
Ajay Ramachandran
2019-08-12 12:05:16 -04:00
parent 012a36b931
commit e281b90699

View File

@@ -209,7 +209,9 @@ function runThePopup() {
function onTabs(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {message: 'getVideoID'}, function(result) {
if (result != undefined && result.videoID) {
loadTabData(tabs, result.videoID);
currentVideoID = result.videoID;
loadTabData(tabs);
} else if (result == undefined && chrome.runtime.lastError) {
//this isn't a YouTube video then, or at least the content script is not loaded
displayNoVideo();
@@ -217,15 +219,15 @@ function runThePopup() {
});
}
function loadTabData(tabs, videoID) {
if (!videoID) {
function loadTabData(tabs) {
if (!currentVideoID) {
//this isn't a YouTube video then
displayNoVideo();
return;
}
//load video times for this video
let sponsorTimeKey = "sponsorTimes" + videoID;
let sponsorTimeKey = "sponsorTimes" + currentVideoID;
chrome.storage.sync.get([sponsorTimeKey], function(result) {
let sponsorTimesStorage = result[sponsorTimeKey];
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {