🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

[youtube.com] Arrow buttons constant binding

The arrow buttons don't depend on slider/seekbar focus. Left/Right - always playback, Down/Up - always sound volume.

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

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

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            [youtube.com] Arrow buttons constant binding
// @name:ru         [youtube.com] Неизменные действия для клавиш стрелок
// @description     The arrow buttons don't depend on slider/seekbar focus. Left/Right - always playback, Down/Up - always sound volume.
// @description:ru  Клавиши стрелок не зависят от фокуса ползунков. Влево/Вправо - всегда перемотка, Вниз/Вверх - всегда громкость.
// @namespace       youtube.com/arrows.constant.binding
// @author          Zaytsev Artem
// @version         0.0.1.4
// @match           *://*.youtube.com/*
// @run-at          document-end
// ==/UserScript==

var acb_debug = false;
var acb_logstr = "";

//Debug console logging.
function acb_log(msg) {
	if (acb_debug) {
		console.log("debug | " + msg);
	}
}

//Debug console logging.
function acb_log1(msg) {
	if (acb_debug) {
		acb_logstr = "debug | " + msg;
		//window.stdout.write(acb_logstr);
	}
}

//Debug console logging.
function acb_log2(msg) {
	if (acb_debug) {
		acb_logstr = acb_logstr + msg;
		console.log(acb_logstr);
		acb_logstr = "";
	}
}

if (acb_debug) {
	document.addEventListener('focusin', (event) => {
		acb_log("Focusin class: " + event.target.className + "; id: " + event.target.id + "; tag: " + event.target.tagName);
	});
}

//Sound volume panel.
acb_log1("Quering the .ytp-volume-panel...");
var q_vp = document.getElementsByClassName("ytp-volume-panel")[0];
if (q_vp) {
	acb_log2(" - ok.");
	q_vp.addEventListener('focus', (event) => {
		acb_log(".ytp-volume-panel tried to get focus.");
		//event.target.focusout();
		//event.target.blur();
		document.getElementsByClassName("html5-video-player")[0].focus({preventScroll:true});
	});
	window.setTimeout(function(){
		q_vp.setAttribute("tabindex", "-1");
		acb_log("Have set .ytp-volume-panel's tabindex to -1.");
	}, 3000)
} else acb_log2(" - not found.");

//Somehow the slider also wants to get the focus although it doesn't have a tabindex set.
acb_log1("Quering the .ytp-volume-slider-handle...");
var q_vsh = document.getElementsByClassName("ytp-volume-slider-handle")[0];
if (q_vsh) {
	acb_log2(" - ok.");
	q_vsh.addEventListener('focus', (event) => {
		acb_log(".ytp-volume-slider-handle tried to get focus.");
		document.getElementsByClassName("html5-video-player")[0].focus({preventScroll:true});
	});
	window.setTimeout(function(){
		q_vsh.setAttribute("tabindex", "-1");
		acb_log("Have set .ytp-volume-slider-handle's tabindex to -1.");
	}, 3000)
} else acb_log2(" - not found.");

//The player playback seekbar.
acb_log1("Quering the .ytp-progress-bar...");
var q_pb = document.getElementsByClassName("ytp-progress-bar")[0];
if (q_pb) {
	acb_log2(" - ok.");
	q_pb.addEventListener('focus', (event) => {
		acb_log(".ytp-progress-bar tried to get focus.");
		document.getElementsByClassName("html5-video-player")[0].focus({preventScroll:true});
	});
	window.setTimeout(function(){
		q_pb.setAttribute("tabindex", "-1");
		acb_log("Have set .ytp-progress-bar's tabindex to -1.");
	}, 3000)
} else acb_log2(" - not found.");