mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 12:37:05 +03:00
Added switch for chrome.runtime.onMessage
This commit is contained in:
@@ -5,31 +5,22 @@ 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);
|
||||||
|
return true; //this allows the callback to be called later by the submitTimes function
|
||||||
//this allows the callback to be called later by the submitTimes function
|
case "addSponsorTime":
|
||||||
return true;
|
|
||||||
} else if (request.message == "addSponsorTime") {
|
|
||||||
addSponsorTime(request.time, request.videoID, callback);
|
addSponsorTime(request.time, request.videoID, callback);
|
||||||
|
return true; //this allows the callback to be called later
|
||||||
//this allows the callback to be called later
|
case "getSponsorTimes":
|
||||||
return true;
|
|
||||||
} else if (request.message == "getSponsorTimes") {
|
|
||||||
getSponsorTimes(request.videoID, function(sponsorTimes) {
|
getSponsorTimes(request.videoID, function(sponsorTimes) {
|
||||||
callback({
|
callback({sponsorTimes: sponsorTimes})
|
||||||
sponsorTimes: sponsorTimes
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
return true; //this allows the callback to be called later
|
||||||
//this allows the callback to be called later
|
case "submitVote":
|
||||||
return true;
|
|
||||||
} else if (request.message == "submitVote") {
|
|
||||||
submitVote(request.type, request.UUID, callback);
|
submitVote(request.type, request.UUID, callback);
|
||||||
|
|
||||||
//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 + "?",
|
||||||
|
|||||||
Reference in New Issue
Block a user