-
Notifications
You must be signed in to change notification settings - Fork 1
/
remove-yt-volumebar-focus.user.js
38 lines (33 loc) · 1.37 KB
/
remove-yt-volumebar-focus.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// ==UserScript==
// @name Remove yt volumebar focus
// @description Sets focus to video element after using volume bar, so that left/right arrow keys can be used for video seeking instead of volume change
// @license MIT
// @version 1.3
// @grant none
// @match https://www.youtube.com/*
// @namespace https://greasyfork.org/users/847699
// ==/UserScript==
const getVideoElem = () => document.querySelector("video.html5-main-video");
const elementToObserve = document.querySelector("body");
const observer = new MutationObserver(function(mutations_list) {
mutations_list.forEach(function(mutation) {
mutation.addedNodes.forEach(function(added_node) {
if(added_node.id == 'movie_player') {
const volumeArea = document.querySelector(".ytp-volume-area");
const videoProgressBar = document.querySelector(".ytp-progress-bar-container");
volumeArea.addEventListener("click", (_) => {
setTimeout(() => {
getVideoElem().focus();
}, 50);
});
videoProgressBar.addEventListener("click", (_) => {
setTimeout(() => {
getVideoElem().focus();
}, 50);
});
observer.disconnect();
}
});
});
});
observer.observe(elementToObserve, {subtree: true, childList: true});