init: mep
This commit is contained in:
29
yt-default-speed.js
Normal file
29
yt-default-speed.js
Normal file
@@ -0,0 +1,29 @@
|
||||
// ==UserScript==
|
||||
// @name Default Speed for YT Videos
|
||||
// @version 1.0.0
|
||||
// @description Speed up YouTube Videos
|
||||
// @author phga
|
||||
// @match *://*.youtube.com/*
|
||||
// @exclude *://*.youtube.com/subscribe_embed?*
|
||||
// ==/UserScript==
|
||||
const speed = 1.5;
|
||||
const timeout = 100;
|
||||
const waitAndRunSpeed = () => {
|
||||
setTimeout(setVideoSpeed, timeout);
|
||||
}
|
||||
const setVideoSpeed = () => {
|
||||
const ad = [...document.querySelectorAll('.ad-showing')][0];
|
||||
const video = document.querySelector('video');
|
||||
// If no ad is playing and the video has really started
|
||||
if (!ad && video.currentTime >= 1) {
|
||||
video.playbackRate = speed;
|
||||
console.log(`Set video speed to ${speed}`);
|
||||
} else {
|
||||
console.log("Ad is running. Retrying to set video speed...");
|
||||
setTimeout(setVideoSpeed, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
// So we do not have to constantly run the function with setInterval
|
||||
window.navigation.addEventListener("navigate", waitAndRunSpeed);
|
||||
waitAndRunSpeed();
|
||||
Reference in New Issue
Block a user