mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
Content.js messageListener switch
This commit is contained in:
parent
f0888faf78
commit
871ba63f67
1 changed files with 53 additions and 66 deletions
119
content.js
119
content.js
|
@ -90,99 +90,86 @@ chrome.runtime.onMessage.addListener(messageListener);
|
||||||
|
|
||||||
function messageListener(request, sender, sendResponse) {
|
function messageListener(request, sender, sendResponse) {
|
||||||
//messages from popup script
|
//messages from popup script
|
||||||
|
switch(request.message){
|
||||||
if (request.message == "update") {
|
case "update":
|
||||||
videoIDChange(getYouTubeVideoID(document.URL));
|
videoIDChange(getYouTubeVideoID(document.URL));
|
||||||
}
|
return
|
||||||
|
case "sponsorStart":
|
||||||
if (request.message == "sponsorStart") {
|
sponsorMessageStarted(sendResponse);
|
||||||
sponsorMessageStarted(sendResponse);
|
return
|
||||||
}
|
case "sponsorDataChanged":
|
||||||
|
updateSponsorTimesSubmitting();
|
||||||
if (request.message == "sponsorDataChanged") {
|
return
|
||||||
updateSponsorTimesSubmitting();
|
//send the sponsor times along with if it's found
|
||||||
}
|
case "isInfoFound":
|
||||||
|
|
||||||
if (request.message == "isInfoFound") {
|
|
||||||
//send the sponsor times along with if it's found
|
|
||||||
sendResponse({
|
sendResponse({
|
||||||
found: sponsorDataFound,
|
found: sponsorDataFound,
|
||||||
sponsorTimes: sponsorTimes,
|
sponsorTimes: sponsorTimes,
|
||||||
hiddenSponsorTimes: hiddenSponsorTimes,
|
hiddenSponsorTimes: hiddenSponsorTimes,
|
||||||
UUIDs: UUIDs
|
UUIDs: UUIDs
|
||||||
});
|
});
|
||||||
|
|
||||||
if (popupInitialised && document.getElementById("sponsorBlockPopupContainer") != null) {
|
if (popupInitialised && document.getElementById("sponsorBlockPopupContainer") != null) {
|
||||||
//the popup should be closed now that another is opening
|
//the popup should be closed now that another is opening
|
||||||
closeInfoMenu();
|
closeInfoMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
popupInitialised = true;
|
popupInitialised = true;
|
||||||
}
|
return
|
||||||
|
case "getVideoID":
|
||||||
if (request.message == "getVideoID") {
|
|
||||||
sendResponse({
|
sendResponse({
|
||||||
videoID: sponsorVideoID
|
videoID: sponsorVideoID
|
||||||
})
|
})
|
||||||
}
|
return
|
||||||
|
case "getVideoDuration":
|
||||||
if (request.message == "getVideoDuration") {
|
|
||||||
sendResponse({
|
sendResponse({
|
||||||
duration: v.duration
|
duration: v.duration
|
||||||
});
|
});
|
||||||
}
|
return
|
||||||
|
case "skipToTime":
|
||||||
if (request.message == "skipToTime") {
|
v.currentTime = request.time;
|
||||||
v.currentTime = request.time;
|
return
|
||||||
}
|
case "getCurrentTime":
|
||||||
|
|
||||||
if (request.message == "getCurrentTime") {
|
|
||||||
sendResponse({
|
sendResponse({
|
||||||
currentTime: v.currentTime
|
currentTime: v.currentTime
|
||||||
});
|
});
|
||||||
}
|
return
|
||||||
|
case "getChannelURL":
|
||||||
if (request.message == "getChannelURL") {
|
|
||||||
sendResponse({
|
sendResponse({
|
||||||
channelURL: channelURL
|
channelURL: channelURL
|
||||||
})
|
})
|
||||||
}
|
return
|
||||||
|
case "isChannelWhitelisted":
|
||||||
if (request.message == "isChannelWhitelisted") {
|
|
||||||
sendResponse({
|
sendResponse({
|
||||||
value: channelWhitelisted
|
value: channelWhitelisted
|
||||||
})
|
})
|
||||||
}
|
return
|
||||||
|
case "whitelistChange":
|
||||||
if (request.message == "whitelistChange") {
|
|
||||||
channelWhitelisted = request.value;
|
channelWhitelisted = request.value;
|
||||||
sponsorsLookup(sponsorVideoID);
|
sponsorsLookup(sponsorVideoID);
|
||||||
}
|
return
|
||||||
|
case "dontShowNotice":
|
||||||
if (request.message == "showNoticeAgain") {
|
dontShowNotice = false;
|
||||||
dontShowNotice = false;
|
return
|
||||||
}
|
case "changeStartSponsorButton":
|
||||||
|
changeStartSponsorButton(request.showStartSponsor, request.uploadButtonVisible);
|
||||||
if (request.message == "changeStartSponsorButton") {
|
return
|
||||||
changeStartSponsorButton(request.showStartSponsor, request.uploadButtonVisible);
|
case "showNoticeAgain":
|
||||||
}
|
dontShowNotice = false;
|
||||||
|
return
|
||||||
if (request.message == "changeVideoPlayerControlsVisibility") {
|
case "changeVideoPlayerControlsVisibility":
|
||||||
hideVideoPlayerControls = request.value;
|
hideVideoPlayerControls = request.value;
|
||||||
|
|
||||||
updateVisibilityOfPlayerControlsButton();
|
updateVisibilityOfPlayerControlsButton();
|
||||||
} else if (request.message == "changeInfoButtonPlayerControlsVisibility") {
|
return
|
||||||
|
case "changeInfoButtonPlayerControlsVisibility":
|
||||||
hideInfoButtonPlayerControls = request.value;
|
hideInfoButtonPlayerControls = request.value;
|
||||||
|
|
||||||
updateVisibilityOfPlayerControlsButton();
|
updateVisibilityOfPlayerControlsButton();
|
||||||
} else if (request.message == "changeDeleteButtonPlayerControlsVisibility") {
|
return
|
||||||
|
case "changeDeleteButtonPlayerControlsVisibility":
|
||||||
hideDeleteButtonPlayerControls = request.value;
|
hideDeleteButtonPlayerControls = request.value;
|
||||||
|
|
||||||
updateVisibilityOfPlayerControlsButton();
|
updateVisibilityOfPlayerControlsButton();
|
||||||
}
|
return
|
||||||
|
case "trackViewCount":
|
||||||
if (request.message == "trackViewCount") {
|
|
||||||
trackViewCount = request.value;
|
trackViewCount = request.value;
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue