Youtube Embed Skip Buttons Mod

Skip buttons for embeded youtube iframes.

Fra og med 30.10.2022. Se den nyeste version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name            Youtube Embed Skip Buttons Mod
// @namespace       userscript
// @include         *.youtube.com/embed/*
// @include         *.youtube-nocookie.com/embed/*
// @version         2017.8.22
// @description     Skip buttons for embeded youtube iframes.
// @author          copypastetada ttbbzz
// @homepageURL     https://greatest.deepsurf.us/en/users/2617
// @grant       none
// ==/UserScript==

document.addEventListener("DOMContentLoaded",function(){
	function seekVDO(interval){
		interval += Math.floor(vdo_player.getCurrentTime());
		vdo_player.seekTo(interval);
	}
	var vdo_player = document.querySelector(".html5-video-player"),
		skip_buttons = [{text:"-5s",interval:-5},
						{text:"+5s",interval:5},
						{text:"+15s",interval:15}];
	var timer0 = setInterval(function(){
		if(vdo_player) {
			skip_container = document.querySelector('.ytp-left-controls');
			check_existing_skipbtn = document.querySelector('.skip');
			if (!check_existing_skipbtn && skip_container) {
				skip_buttons.forEach(function(b){ 
					sb = document.createElement('button');
					sb.setAttribute('class', 'ytp-button skip');
					sb.addEventListener('click',function(){seekVDO(b.interval)});
					sb.innerHTML = '<span>'+b.text+'</span>';
					sb.style.verticalAlign = "top";
					sb.style.textAlign = "center";
					skip_container.appendChild(sb);
				});
			} else { console.log("%cplayer control div.ytp-left-controls not found","color:maroon;"); }
			clearInterval(timer0);
		} else {
			console.log("%clooking for div.html5-video-player","color:teal;");
			vdo_player = document.querySelector(".html5-video-player");
		}
	},100);
},false);