diff options
author | Ajay Ramachandran <[email protected]> | 2019-08-13 13:06:10 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-13 13:06:10 -0400 |
commit | 137ba895bb43ee1097d657a9e36192cdf320735f (patch) | |
tree | 91ebcbae5bacda158b96e7c490dceed59536796f /background.js | |
parent | 5347340c1c3cb75d8f2aa5e6e5e903997bd7bf83 (diff) | |
parent | ecc48de396e58b6b24068ad02860bd0ac4ebc96d (diff) | |
download | SponsorBlock-137ba895bb43ee1097d657a9e36192cdf320735f.tar.gz SponsorBlock-137ba895bb43ee1097d657a9e36192cdf320735f.zip |
Merge pull request #110 from ajayyy/experimental1.0.35
Update master
Diffstat (limited to 'background.js')
-rw-r--r-- | background.js | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/background.js b/background.js index c8d7d593..6cd14ee5 100644 --- a/background.js +++ b/background.js @@ -5,38 +5,39 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { }); chrome.runtime.onMessage.addListener(function (request, sender, callback) { - if (request.message == "submitTimes") { - submitTimes(request.videoID, callback); - - //this allows the callback to be called later by the submitTimes function - return true; - } else if (request.message == "addSponsorTime") { - addSponsorTime(request.time, request.videoID, callback); - - //this allows the callback to be called later - return true; - } else if (request.message == "getSponsorTimes") { - getSponsorTimes(request.videoID, function(sponsorTimes) { - callback({ - sponsorTimes: sponsorTimes - }) - }); - - //this allows the callback to be called later - return true; - } else if (request.message == "submitVote") { - submitVote(request.type, request.UUID, callback); - - //this allows the callback to be called later - return true; - } else if (request.message == "alertPrevious") { - chrome.notifications.create("stillThere" + Math.random(), { - type: "basic", - title: "Do you want to submit the sponsor times for video id " + request.previousVideoID + "?", - message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).", - iconUrl: "./icons/LogoSponsorBlocker256px.png" - }); - } + switch(request.message) { + 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); + + //this allows the callback to be called later + return true; + case "getSponsorTimes": + getSponsorTimes(request.videoID, function(sponsorTimes) { + callback({ + sponsorTimes: sponsorTimes + }) + }); + + //this allows the callback to be called later + return true; + case "submitVote": + submitVote(request.type, request.UUID, callback); + + //this allows the callback to be called later + return true; + case "alertPrevious": + chrome.notifications.create("stillThere" + Math.random(), { + type: "basic", + title: "Do you want to submit the sponsor times for video id " + request.previousVideoID + "?", + message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).", + iconUrl: "./icons/LogoSponsorBlocker256px.png" + }); + } }); //add help page on install |