Last active
July 7, 2019 15:54
-
-
Save shuuji3/2d15545f219be322e362fd2ac7fda4b1 to your computer and use it in GitHub Desktop.
Tampermonkey Script for あにてれ (https://ch.ani.tv): Add autoplay feature and keybindings (Space: Pause & Play / F: Toggle Fullscreen)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Add autoplay feature and keybindings (Space: Pause & Play / F: Toggle Fullscreen) | |
// @namespace http://github.com/shuuji3 | |
// @version 0.1 | |
// @description Add autoplay feature and keybindings (Space: Pause & Play / F: Toggle Fullscreen) | |
// @author You | |
// @match https://ch.ani.tv/episodes/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Autoplay video | |
const firstPlayButton = document.querySelector('#player-ctrl-play'); | |
firstPlayButton.click(); | |
// Pause & Play | |
function pauseAndPlay(e) { | |
e.preventDefault(); | |
const isPlaying = !!document.querySelector('.vjs-playing'); | |
const pauseButton = document.querySelector('#player-ctrl-pause'); | |
const playButton = document.querySelector('#player-ctrl-play'); | |
if (isPlaying) { | |
pauseButton.click(); | |
} else { | |
playButton.click(); | |
} | |
} | |
// Toggle fullscreen | |
function toggleFullscreen() { | |
const isFullscreen = !!document.querySelector('.vjs-playing'); | |
const fullscreenButton = document.querySelector('#player-ctrl-full-screen'); | |
const fullscreenOffButton = document.querySelector('#player-ctrl-full-screen-off'); | |
} | |
window.addEventListener('keydown', e => { | |
if (e.code === 'Space') { | |
pauseAndPlay(e); | |
} else if (e.code === 'KeyF') { | |
toggleFullscreen(); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment