A Bookmarklet example for skipping Ads in a Video
This bookmarklet is produced only for education purposes. It works as like a button in the bookmarks section. While you are in a video streaming platform like YouTube, you can click the bookmarklet. When you click the bookmarklet it speeds the video and clicks the "skip" button for you. If you click while normal video is playing (not while ads are playing) the current video will play very fast. To slow down the video back to normal playback speed just click the bookmarklet again.
Each tab /window or reloads needs new click again in the bookmark. But while in the same page you can just press 'Enter' key to skip the ads.
How to install?
To install the code just drag the following link to your browsers bookmarks bar.
----> 🎦 Skip Ads: Enter (Drag to bookmark) <----
Key combinations
Other key combinations are as follows:
- Ctrl + Enter : skips the ads (full screen or popup) and resets the player speed.
- "+" : increases the player speed.
- "-" : decreases the player speed.
- Ctrl + "0" : resets the player speed.
The JavaScript code used in this bookmarklet is as below:
javascript: function skipAds() {
const video = document.querySelector('video');
const skipAdsButton = document.querySelector('.ytp-ad-skip-button');
const smallAdsButton = document.querySelector('.ytp-ad-overlay-close-button');
if (skipAdsButton) {
video.playbackRate = video.playbackRate != 1 ? 1 : 5;
setTimeout(() => {
warnings.innerText = '';
}, 1000);
skipAdsButton.click();
}
if (smallAdsButton) {
smallAdsButton.click();
}
}
(function () {
skipAds();
document.onkeyup = function (event) {
const video = document.querySelector('video');
let e = event || window.event;
// ctrl + Enter to skip adds or reset video playbackRate
if (e.key === 'Enter' && e.ctrlKey) {
skipAds();
video.playbackRate = 1;
}
// + to decrease the video playback speed
if (e.key === '+') {
video.playbackRate += 0.25;
}
// - to decrease the video playback speed
if (e.key === '-' && video.playbackRate > 0.25) {
video.playbackRate -= 0.25;
}
// Ctrl + 0 to reset the video speed
if (e.key === '0' && e.ctrlKey) {
video.playbackRate = 1;
}
};
})();