mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-16 08:27:03 +03:00
Made the popup appear when you skip a sponsor and made it disappear after 2.5 seconds
This commit is contained in:
12
content.js
12
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) {
|
if (Math.abs(v.currentTime - lastTime) < 1 && sponsorTime[0] >= lastTime && sponsorTime[0] <= v.currentTime) {
|
||||||
//skip it
|
//skip it
|
||||||
v.currentTime = sponsorTime[1];
|
v.currentTime = sponsorTime[1];
|
||||||
|
|
||||||
|
//send out the message saying that a sponsor message was skipped
|
||||||
|
openSkipNotice();
|
||||||
|
|
||||||
|
setTimeout(closeSkipNotice, 2500);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastTime = v.currentTime;
|
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(){
|
function openSkipNotice(){
|
||||||
var noticeElement = document.createElement("div");
|
var noticeElement = document.createElement("div");
|
||||||
|
|
||||||
@@ -120,6 +125,11 @@ function openSkipNotice(){
|
|||||||
referenceNode.prepend(noticeElement);
|
referenceNode.prepend(noticeElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Closes the notice that tells the user that a sponsor was just skipped
|
||||||
|
function closeSkipNotice(){
|
||||||
|
document.getElementById("sponsorSkipNotice").remove();
|
||||||
|
}
|
||||||
|
|
||||||
function sponsorMessageStarted() {
|
function sponsorMessageStarted() {
|
||||||
let v = document.querySelector('video');
|
let v = document.querySelector('video');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user