dazn, media controls

allows forward/backwards with arrow keys and pause with space

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         dazn, media controls
// @description  allows forward/backwards with arrow keys and pause with space
// @version      1.1
// @author       Tobias L
// @include      *.dazn.com/*
// @license      GPL-3.0-only
// @namespace    https://github.com/WhiteG00se/User-Scripts
// ==/UserScript==
// goes well with this steam controller profile:
// steam://controllerconfig/413080/2807431315

function backward() {
	let button = document.querySelector('[data-test-id="PLAYER_BUTTON_REWIND"]')
	if (button == null)
		button = document.querySelector('[data-test-id="PLAYER_BUTTON_REWIND PLAYER_BUTTON_REWIND_VISIBLE"]')
	button.click()
}
function forward() {
	let button = document.querySelector('[data-test-id="PLAYER_BUTTON_FAST_FORWARD"]')
	if (button == null)
		button = document.querySelector('[data-test-id="PLAYER_BUTTON_FAST_FORWARD PLAYER_BUTTON_FAST_FORWARD_VISIBLE"]')
	button.click()
}
function pause() {
	let button = document.querySelector('[data-test-id="PLAYER_BUTTON_PAUSE"]')
	if (button == null) 
		button = document.querySelector('[data-test-id="PLAYER_BUTTON_PAUSE PLAYER_BUTTON_PAUSE_VISIBLE"]')
	if (button == null) 
		button = document.querySelector('[data-test-id="PLAYER_BUTTON_PLAY"]')
	if (button == null) 
		button = document.querySelector('[data-test-id="PLAYER_BUTTON_PLAY PLAYER_BUTTON_PLAY_VISIBLE"]')

	button.click()
}

document.body.addEventListener("keydown", function (e) {
	if (e.key === "ArrowLeft") {
		e.preventDefault()
		backward()
	}
	if (e.key === "ArrowRight") {
		e.preventDefault()
		forward()
	}
	if (e.key === " ") {
		e.preventDefault()
		pause()
	}
})