yerf.org audio controller

Unhides audio controls, adds hotkeys for said controls, adjusts some elements

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         yerf.org audio controller
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Unhides audio controls, adds hotkeys for said controls, adjusts some elements
// @author       GlawGlack
// @match        https://liltsome.yerf.org/*
// @grant        none
// @run-at       document-idle
// @license      unlicense
// ==/UserScript==

(function() {
	'use strict';

	function init() {

		const checkForAudio = setInterval(() => {
			const audioElement = document.querySelector('audio');

			if (audioElement && audioElement.src) {

				const movehere = document.querySelector('[class="player-progress"]');
				audioElement.controls = true;
				movehere.appendChild(audioElement);

				document.addEventListener('keydown', (e) => {
					if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
					switch(e.code) {
						case 'Space': e.preventDefault(); document.querySelector('[id="btnPlay"]').click(); break;

						case 'ArrowLeft': e.preventDefault(); if (event.key === 'ArrowLeft' && event.ctrlKey) {audioElement.currentTime = audioElement.currentTime - 10;}
							if (event.key === 'ArrowLeft') {audioElement.currentTime = audioElement.currentTime - 5;} break;
						case 'ArrowRight': e.preventDefault(); if (event.key === 'ArrowRight' && event.ctrlKey) {audioElement.currentTime = audioElement.currentTime + 10;}
							if (event.key === 'ArrowRight') {audioElement.currentTime = audioElement.currentTime + 5;} break;

						case 'ArrowUp': e.preventDefault(); audioElement.volume = audioElement.volume + 0.05; break;
						case 'ArrowDown': e.preventDefault(); audioElement.volume = audioElement.volume - 0.05; break;

						case 'KeyM': e.preventDefault(); if (audioElement.muted === true) {audioElement.muted = false;} else {audioElement.muted = true;} break;
					}
				});
				// smoosh default scrubber
				movehere.style.cssText =
					`
					width: 0px;
							  `;
				// make native larger
				audioElement.style.cssText =
					`
					display: unset !important;
					position: absolute !important;
					left: 20px !important;
					width: 75% !important;
					top: 50% !important;
									   `;
				// un-truncate current audio title
				document.querySelector('.player-title').style.cssText=
					`
					overflow: visible !important;
					white-space: wrap !important;
												`;
				clearInterval(checkForAudio);
			}
		}, 500);
	}

	if (document.readyState === 'loading') {
		document.addEventListener('DOMContentLoaded', init);
	} else {
		init();
	}
})();