Made the popup appear when you skip a sponsor and made it disappear after 2.5 seconds

This commit is contained in:
Ajay Ramachandran
2019-07-09 21:31:21 -04:00
parent 8710fdab22
commit 4d4103f053

View File

@@ -84,13 +84,18 @@ function sponsorCheck(sponsorTimes) { // Video skipping
if (Math.abs(v.currentTime - lastTime) < 1 && sponsorTime[0] >= lastTime && sponsorTime[0] <= v.currentTime) {
//skip it
v.currentTime = sponsorTime[1];
//send out the message saying that a sponsor message was skipped
openSkipNotice();
setTimeout(closeSkipNotice, 2500);
}
lastTime = v.currentTime;
});
}
//The notice that tells the user that a sponsor was just skipped
//Opens the notice that tells the user that a sponsor was just skipped
function openSkipNotice(){
var noticeElement = document.createElement("div");
@@ -120,6 +125,11 @@ function openSkipNotice(){
referenceNode.prepend(noticeElement);
}
//Closes the notice that tells the user that a sponsor was just skipped
function closeSkipNotice(){
document.getElementById("sponsorSkipNotice").remove();
}
function sponsorMessageStarted() {
let v = document.querySelector('video');