Merge pull request #103 from OfficialNoob/patch-20

Added switch for chrome.runtime.onMessage
This commit is contained in:
Ajay Ramachandran
2019-08-13 00:32:43 -04:00
committed by GitHub

View File

@@ -5,17 +5,18 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
}); });
chrome.runtime.onMessage.addListener(function (request, sender, callback) { chrome.runtime.onMessage.addListener(function (request, sender, callback) {
if (request.message == "submitTimes") { switch(request.message) {
case "submitTimes":
submitTimes(request.videoID, callback); submitTimes(request.videoID, callback);
//this allows the callback to be called later by the submitTimes function //this allows the callback to be called later by the submitTimes function
return true; return true;
} else if (request.message == "addSponsorTime") { case "addSponsorTime":
addSponsorTime(request.time, request.videoID, callback); addSponsorTime(request.time, request.videoID, callback);
//this allows the callback to be called later //this allows the callback to be called later
return true; return true;
} else if (request.message == "getSponsorTimes") { case "getSponsorTimes":
getSponsorTimes(request.videoID, function(sponsorTimes) { getSponsorTimes(request.videoID, function(sponsorTimes) {
callback({ callback({
sponsorTimes: sponsorTimes sponsorTimes: sponsorTimes
@@ -24,12 +25,12 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
//this allows the callback to be called later //this allows the callback to be called later
return true; return true;
} else if (request.message == "submitVote") { case "submitVote":
submitVote(request.type, request.UUID, callback); submitVote(request.type, request.UUID, callback);
//this allows the callback to be called later //this allows the callback to be called later
return true; return true;
} else if (request.message == "alertPrevious") { case "alertPrevious":
chrome.notifications.create("stillThere" + Math.random(), { chrome.notifications.create("stillThere" + Math.random(), {
type: "basic", type: "basic",
title: "Do you want to submit the sponsor times for video id " + request.previousVideoID + "?", title: "Do you want to submit the sponsor times for video id " + request.previousVideoID + "?",