From 35c3b5b97f7b3742c962dbfa8bdb194e48f6238c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 31 Jul 2019 23:47:04 -0400 Subject: [PATCH] Made it only count a contribution if it was uploaded successfully. --- background.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/background.js b/background.js index 96e5a309..cbc268b9 100644 --- a/background.js +++ b/background.js @@ -147,6 +147,20 @@ function submitTimes(videoID, callback) { callback({ statusCode: xmlhttp.status }); + + if (xmlhttp.status == 200) { + //add these to the storage log + chrome.storage.sync.get(["sponsorTimesContributed"], function(result) { + let currentContributionAmount = 0; + if (result.sponsorTimesContributed != undefined) { + //current contribution amount is known + currentContributionAmount = result.sponsorTimesContributed; + } + + //save the amount contributed + chrome.storage.sync.set({"sponsorTimesContributed": currentContributionAmount + sponsorTimes.length}); + }); + } } else if (error) { callback({ statusCode: -1 @@ -155,18 +169,6 @@ function submitTimes(videoID, callback) { }); }); } - - //add these to the storage log - chrome.storage.sync.get(["sponsorTimesContributed"], function(result) { - let currentContributionAmount = 0; - if (result.sponsorTimesContributed != undefined) { - //current contribution amount is known - currentContributionAmount = result.sponsorTimesContributed; - } - - //save the amount contributed - chrome.storage.sync.set({"sponsorTimesContributed": currentContributionAmount + sponsorTimes.length}); - }); } }); }