Greasy Fork

视频倍速播放

看视频播放太慢了,直接倍速播放

当前为 2021-02-04 提交的版本,查看 最新版本

// ==UserScript==
// @name         视频倍速播放
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  看视频播放太慢了,直接倍速播放
// @author       wll
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/2.2.0/jquery.js
// @match        *://ke.qq.com/webcourse/index.html
// @match        *://www.bilibili.com/*
// @match        *://www.iqiyi.com/*
// @note         20-12-26 1.0.0 初版发布视频倍速播放
// ==/UserScript==

(function() {
    'use strict';

    var stepHtml='<input id="rangeId" type="number" step="0.1" min="0.1" max="10" value="1" style="z-index:999999;position:absolute;top:100px;right:100px;border:solid 1px;background-color:#E3EDCD;" />';
	$("body").prepend(stepHtml);

    window.setInterval(function(){
        let step = document.getElementById("rangeId").value||1.0;

        console.log("倍速播放方法启动中....."+step);

        var htmlVideo = $("video").length;

        if(htmlVideo > 0){

            var url = location.href;
            console.log("url-->"+url);

            if (url.indexOf('bilibili.com/video/') > 0) {
                //play video twice as fast
                document.querySelector('video').defaultPlaybackRate = 2.0;//默认两倍速播放
                document.querySelector('video').play();
            }

            // now play three times as fast just for the heck of it
            document.querySelector('video').playbackRate = step;//修改此值设置当前的播放倍数
        }else{
            console.log("当前视频不支持倍速播放.....(ಥ_ಥ) o(╥﹏╥)o");
        }

    },1000);

})();