Greasy Fork

Greasy Fork is available in English.

视频倍速播放(追剧学习神器)

看视频播太慢,这能忍?直接倍速播放,【食用方法】①调节右上角加速框右侧上下按钮即可调节倍率 ②在右上角的加速框内输入加速倍率,如2、4、8、16等。快捷键:ctrl + 左右箭头

当前为 2021-12-14 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         视频倍速播放(追剧学习神器)
// @namespace    http://tampermonkey.net/
// @icon         https://img-blog.csdnimg.cn/20181221195058594.gif
// @version      1.1.0
// @description  看视频播太慢,这能忍?直接倍速播放,【食用方法】①调节右上角加速框右侧上下按钮即可调节倍率 ②在右上角的加速框内输入加速倍率,如2、4、8、16等。快捷键:ctrl + 左右箭头
// @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/*
// @match        *://ehuixue.cn/index/study/*
// @match        *://*.ehuixue.cn/index/study/*
// @match        *://*.chaoxing.com/*
// @match        *://*.douyin.com/*
// @match        *://*.youku.com/*
// @match        *://*.tv.cctv.com/*
// @note         增加支持网站:	依照规则增加@match所在标签即可
// @note         郑重声明:	本脚本只做学习交流使用,未经作者允许,禁止转载,不得使用与非法用途,一经发现,追责到底
// @note         授权联系:	[email protected]
// @note         版本更新	20-12-26 1.0.0	初版发布视频倍速播放
// @note         版本更新	21-02-04 1.0.1 	优化用户体验
// @note         版本更新	21-02-04 1.0.2 	优化标题,优化简介
// @note         版本更新	21-06-18 1.0.3 	增加新的倍速网址,ehuixue.cn/index/study,ehuixue.cn/index/study,chaoxing.com
// @note         版本更新	21-06-25 1.0.4 	增加新的倍速网址,douyin.com
// @note         版本更新	21-06-26 1.0.5 	增加新的倍速网址,pan.baidu.com,youku.com
// @note         版本更新	21-07-09 1.0.6 	修正哔哩哔哩网站无法暂停问题
// @note         版本更新	21-10-11 1.0.7 	由于百度云视频倍速播放收费,一时无法解决,暂时停用百度相关加速*://*.pan.baidu.com/*
// @note         版本更新	21-12-11 1.0.8  感谢用户“何佳林”,提供建议,增加快捷键控制倍速 ctrl + ->  ctrl + <- 
// @note         版本更新	21-12-13 1.0.9  增加cctv支持,增加倍速控件悬浮不跟随滑动 
// @note         版本更新	21-12-14 1.1.0  增加倍率记忆功能,防止页面刷新倍率重新计算 

// ==/UserScript==

(function() {
	'use strict';

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

	window.setInterval(function() {
		let step = document.getElementById("rangeId").value || 1.0;
		var htmlVideo = $("video").length;
		if(htmlVideo > 0) {
            console.log("倍速播放方法启动,当前倍率为....." + step);
			var url = location.href;

			if(url.indexOf('bilibili.com/video/') > 0) {
			    if(stopFlag){
			        //play video twice as fast
			    	document.querySelector('video').defaultPlaybackRate = 1.0; //矫正正常播放
			    	document.querySelector('video').play();
			    	stopFlag = false;
			    }
			}

            if(step!=1){
            	localUtil.setSValue("stepKey",step);
            }
            var stepKey = localUtil.getSValue("stepKey");
            if(stepKey != null){
            	step = stepKey;
            	$("#rangeId").val(step);
            }

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

	}, 1000);

    document.onkeydown = function() {
		if (window.event.ctrlKey && (window.event.keyCode == 37)) {
			console.log("---");
			$("#rangeId").val(parseFloat(parseFloat($("#rangeId").val()) - 0.1 < 0.1 ? 0.1 : parseFloat($("#rangeId").val()) - 0.1).toFixed(1));
		}
		if (window.event.ctrlKey && (window.event.keyCode == 39)) {
			console.log("+++");
			$("#rangeId").val(parseFloat(parseFloat($("#rangeId").val()) + 0.1 > 20  ? 20  : parseFloat($("#rangeId").val()) + 0.1).toFixed(1));
		}
	}

    let localUtil = {
		getSValue(name) {
			return window.localStorage.getItem(name);
		},
		setSValue(name, value) {
		    window.localStorage.setItem(name, value);
		},
		getGValue(name) {
			return window.GM_getValue(name);
		},
		setGValue(name, value) {
			window.GM_setValue(name, value);
		}
	}
		
})();