0x48piraj / fadblock

Friendly Adblock for YouTube: A fast, lightweight, and undetectable YouTube Ads Blocker for Chrome, Opera and Firefox.
2.39k stars 110 forks source link

Feature Request: Skip Current Video Segment in Video Player (Ad or Video) via Hotkeys #117

Open eliezercazares opened 9 months ago

eliezercazares commented 9 months ago

Hello Piraj,

I hope you're doing super good.

I was looking at the repo, and I was wondering if we could call the next block of code via hot keys (i.e. "A" + "S")..

function skipCurrentVideoSegment() {
        videoPlayer.muted = true; // videoPlayer.volume = 0;
        videoPlayer.currentTime = videoPlayer.duration - 0.1;
        videoPlayer.paused && videoPlayer.play()

        // CLICK ON THE SKIP AD BTN
        document.querySelector(".ytp-ad-skip-button")?.click();
        document.querySelector(".ytp-ad-skip-button-modern")?.click();
}

addEventListener("keydown", (event) => {
  if (event.key === "a") {
    keys.a = true;
  }
  if (event.key === "s") {
    keys.s = true;
  }

if(keys.a && keys.s){
  skipCurrentVideoSegment();
}
});

I think doing it this way would at least suppress the current video ad regardless of finding the cssAttributes for an ad or not.

Once the user presses the hotkeys we do this:

    videoPlayer.muted = true; // videoPlayer.volume = 0;
    videoPlayer.currentTime = videoPlayer.duration - 0.1;
    videoPlayer.paused && videoPlayer.play()

It can leverage the pain while the extension catches up with new youtube's countermeasures.

Let me know if I can be a help.

eliezercazares commented 9 months ago

Update: New version fixes the issues :P