Greasy Fork

Greasy Fork is available in English.

倍速控制器

对大部分视频网站的视频播放页面生成快捷键

当前为 2022-10-21 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         倍速控制器
// @namespace    http://tampermonkey.net/
// @version      2.1
// @description  对大部分视频网站的视频播放页面生成快捷键
// @author       五等份的商鞅
// @match        *://*
// @match        *://*/*
// @match        *://*/*/*
// @match        *://*/*/*/*
// @match        *://*/*/*/*/*
// @match        *://*/*/*/*/*/*
// @match        *://*/*/*/*/*/*/*
// @match        *://*/*/*/*/*/*/*/*
// @icon         https://cas.pxc.jx.cn/lyuapServer/favicon.ico
// @grant        none
// @license     GPL-3.0-or-later
// ==/UserScript==
(function(){setTimeout(function(){var videos=document.querySelectorAll('video');if(videos.length != 0){var getRate=function(){return localStorage.getItem('rate')};var rate=getRate()|| 2;var setRate=function(t){localStorage.setItem('rate', t);rate=t};setRate(rate);var changeRate=function(){videos[0].playbackRate=rate};changeRate();var aid=document.createElement('div');document.querySelector('body').insertAdjacentElement('beforebegin', aid);aid.style="float:left;position: fixed;top: 50%;left: 50%;width: 200px;height: 200px;border-radius: 50%;text-align: center;line-height: 200px;font-size: 40px;color: #fff;background-color: rgba(251,215,0,1);transform: translateX(-100px)translateY(-100px);transition:all 1s";aid.onclick=function(){aid.style.display='none'};var tips=function(){aid.innerHTML=`x${videos[0].playbackRate}倍速`;aid.style.display='block';setTimeout(function(){aid.style.display='none'}, 3000)};tips();var panel=document.createElement('ul');document.querySelector('body').insertAdjacentElement('afterbegin', panel);panel.innerHTML=`<li><span>默认播放速度:</span><input type="number" value="${getRate()}"></li><li><span>当前播放速度:</span><input type="number" value="${videos[0].playbackRate}"></li><li><div><span>倍速快捷键:</span><br>[0]:呼出悬浮菜单;<br>[1]:1倍速;<br>[2]:1.25倍速;<br>[3]:1.75倍速;<br>[4]:2倍速;<br>[5]:3倍速;<br>[6]:4倍速;<br>[7]:5倍速;<br>[8]:8倍速;<br>[9]:16倍速<br></div></li>`;panel.style="float:left;position: fixed;left: -23vmin;top: 20%;padding: 2vmin 0;width: 24vmin;height:5vmin;border-radius: 5vmin;list-style: none;background-color: rgba(255, 255, 204, 1);transition: all 0.5s;";panel.className='control';let panelItem=document.querySelectorAll('.control>li');let panelItemInput=document.querySelectorAll('.control>li input');for(var n=0;n < panelItem.length;n++){panelItem[n].style=`display: flex;justify-content: space-between;margin: 1vmin;padding: 1vmin;width: 22vmin;background-color: pink;border-radius: 3vmin;box-sizing: border-box;`};panelItemInput[0].style.width='5vmin';panelItemInput[1].style.width='5vmin';panel.onmouseover=function(){panel.style.left='0';panel.style.height='auto'};panel.onmouseout=function(){panel.style.left='-23vmin';panel.style.height='5vmin'};panelItemInput[0].onchange=function(){if(this.value > 16)this.value=16;if(this.value <= 0)this.value=1;setRate(this.value);changeRate();tips()};panelItemInput[1].onchange=function(){if(this.value > 16)this.value=16;if(this.value <= 0)this.value=1;rate=this.value;changeRate();tips()};setTimeout(panel.style.zIndex=100,1000);setTimeout(aid.style.zIndex=100,1000);videos[0].oncanplay=changeRate;videos[0].onchange=changeRate;window.onkeydown=function(){switch(event.keyCode){case 48: panel.style.left='0';panel.style.height='auto';setTimeout(function(){panel.style.left='-23vmin';panel.style.height='5vmin'},3000);break;case 49: rate=1;changeRate();tips();break;case 50: rate=1.5;changeRate();tips();break;case 51: rate=1.75;changeRate();tips();break;case 52: rate=2;changeRate();tips();break;case 53: rate=3;changeRate();tips();break;case 54: rate=4;changeRate();tips();break;case 55: rate=5;changeRate();tips();break;case 56: rate=8;changeRate();tips();break;case 57: rate=16;changeRate();tips();break}}}},2000)})();