From 4d4103f053092c2b020333a8df7d1fda0f518270 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 9 Jul 2019 21:31:21 -0400 Subject: [PATCH] Made the popup appear when you skip a sponsor and made it disappear after 2.5 seconds --- content.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/content.js b/content.js index f16dfbe0..09d1d978 100644 --- a/content.js +++ b/content.js @@ -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');