Auto ad skipper

Auto-skips ads on youtube!

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Auto ad skipper
// @namespace    http://tampermonkey.net/
// @version      0.9
// @description  Auto-skips ads on youtube!
// @author       Wapplee (qrco)
// @match        *://*.youtube.com/*
// @license MIT
// ==/UserScript==

(function() {
	'use strict';

	setInterval(function(){
		["ytp-ad-skip-button-modern","ytp-ad-skip-button"].forEach((a)=>{
			Object.values(document.getElementsByClassName(a)).forEach((a)=>a.click())
		})
		let isad = document.getElementsByClassName("ytp-ad-text")[0];
		if (isad) {
			let video = document.getElementsByClassName("video-stream html5-main-video")[0];
			if (video) {
				video.play();
				video.pause();
				video.currentTime = video.duration;
			}
		}
		[
			"yt-simple-endpoint style-scope ytd-action-companion-ad-renderer",
			"ytd-in-feed-ad-layout-renderer"
		].forEach((delstr)=>{
			Array.from(document.getElementsByClassName(delstr)).forEach((element)=>element.remove());
		});
	}, 1);

})();