aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2020-04-20 15:48:47 -0400
committerAjay Ramachandran <[email protected]>2020-04-20 15:48:47 -0400
commit0cfe0dc90f653a5e7a2670a492fb97bcd0a3d630 (patch)
tree209aa80ddfcaea2e16717708e22bda4ddfcb0fbd
parent9a70599e6011999a4e1ed06b1eef27c3df458d99 (diff)
downloadSponsorBlock-0cfe0dc90f653a5e7a2670a492fb97bcd0a3d630.tar.gz
SponsorBlock-0cfe0dc90f653a5e7a2670a492fb97bcd0a3d630.zip
Fix submission count not being counted
-rw-r--r--src/background.ts62
-rw-r--r--src/content.ts3
2 files changed, 3 insertions, 62 deletions
diff --git a/src/background.ts b/src/background.ts
index 1582327c..b204b64c 100644
--- a/src/background.ts
+++ b/src/background.ts
@@ -31,11 +31,6 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
case "openConfig":
chrome.runtime.openOptionsPage();
return
- case "submitTimes":
- submitTimes(request.videoID, callback);
-
- //this allows the callback to be called later by the submitTimes function
- return true;
case "addSponsorTime":
addSponsorTime(request.time, request.videoID, callback);
@@ -182,61 +177,4 @@ function submitVote(type, UUID, callback) {
}
});
-}
-
-async function submitTimes(videoID: string, callback) {
- //get the video times from storage
- let sponsorTimes = Config.config.sponsorTimes.get(videoID);
- let userID = Config.config.userID;
-
- if (sponsorTimes != undefined && sponsorTimes.length > 0) {
- let durationResult = <Types.VideoDurationResponse> await new Promise((resolve, reject) => {
- chrome.tabs.query({
- active: true,
- currentWindow: true
- }, function(tabs) {
- chrome.tabs.sendMessage(tabs[0].id, {
- message: "getVideoDuration"
- }, (response) => resolve(response));
- });
- });
-
- //check if a sponsor exceeds the duration of the video
- for (let i = 0; i < sponsorTimes.length; i++) {
- if (sponsorTimes[i][1] > durationResult.duration) {
- sponsorTimes[i][1] = durationResult.duration;
- }
- }
-
- //submit these times
- for (let i = 0; i < sponsorTimes.length; i++) {
- //to prevent it from happeneing twice
- let increasedContributionAmount = false;
-
- //submit the sponsorTime
- utils.sendRequestToServer("GET", "/api/postVideoSponsorTimes?videoID=" + videoID + "&startTime=" + sponsorTimes[i][0] + "&endTime=" + sponsorTimes[i][1]
- + "&userID=" + userID, function(xmlhttp, error) {
- if (xmlhttp.readyState == 4 && !error) {
- callback({
- statusCode: xmlhttp.status,
- responseText: xmlhttp.responseText
- });
-
-
-
- if (xmlhttp.status == 200) {
- //save the amount contributed
- if (!increasedContributionAmount) {
- increasedContributionAmount = true;
- Config.config.sponsorTimesContributed = Config.config.sponsorTimesContributed + sponsorTimes.length;
- }
- }
- } else if (error) {
- callback({
- statusCode: -1
- });
- }
- });
- }
- }
} \ No newline at end of file
diff --git a/src/content.ts b/src/content.ts
index 09fca172..6c1e3755 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -1490,6 +1490,9 @@ async function sendSubmitMessage(){
sponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting);
+ // Increase contribution count
+ Config.config.sponsorTimesContributed = Config.config.sponsorTimesContributed + sponsorTimesSubmitting.length;
+
// Empty the submitting times
sponsorTimesSubmitting = [];