Greasy Fork

来自缓存

Greasy Fork is available in English.

百度网盘自定义倍速播放

第一次写的脚本,主要是考研看视频舒服一点,设置了一个可以自定义倍速的脚本,后面会逐渐完善和增加功能,欢迎反馈

当前为 2021-01-20 提交的版本,查看 最新版本

// ==UserScript==
// @name         百度网盘自定义倍速播放
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  第一次写的脚本,主要是考研看视频舒服一点,设置了一个可以自定义倍速的脚本,后面会逐渐完善和增加功能,欢迎反馈
// @author       枫影
// @match        *://pan.baidu.com/play/video
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    //生成倍速下拉菜单
    /*function createSelect(id){
    	var s=document.createElement("SELECT");
    	s.setAttribute("id",id);
    	var p=document.createElement("OPTION");
    	var p1=document.createElement("OPTION");
    	var p2=document.createElement("OPTION");
    	var p3=document.createElement("OPTION");
    	var p4=document.createElement("OPTION");
    	var p5=document.createElement("OPTION");
    	p.innerHTML="请选择倍速";
    	p1.innerHTML="0.5";
    	p2.innerHTML="0.7";
    	p3.innerHTML="1.0";
    	p4.innerHTML="1.5";
    	p5.innerHTML="2.0";
    	s.add(p);
    	s.add(p1);
		s.add(p2);
		s.add(p3);
		s.add(p4);
		s.add(p5);
		s.style.position="absolute";
		s.style.zIndex=999;
		document.body.appendChild(s);
    }*/

    function createInput(inid,onid){
		alert("加载倍速脚本完成");

		//生成元素
    	var d=document.createElement("FORM");
    	d.style.width="400px";
    	d.style.height="50px";
		d.setAttribute("id","inform");
    	var init=document.createElement("INPUT");
    	init.setAttribute("type","text");
    	init.setAttribute("placeholder","请输入你想倍速的倍数");
    	init.setAttribute("id",inid);
    	var on=document.createElement("BUTTON");
    	var res=document.createElement("INPUT");
    	on.innerHTML="确认";
    	res.setAttribute("type","reset");
		res.innerHTML="清空";
    	on.setAttribute("id",onid);

		//设置位置
    	init.style.position="absolute";
    	on.style.position="absolute";
    	res.style.position="absolute";
		d.style.position="absolute";
    	init.style.zIndex=999;
    	on.style.zIndex=999;
    	res.style.zIndex=999;
		d.style.left="5px";
		d.style.top="50%";
		init.style.top="30%";
		init.style.left="1px";
    	on.style.left="42%";
        on.style.top="30%";
    	res.style.left="53%";
        res.style.top="30%";

		//设置样式
		d.style.borderStyle="dashed";
		d.style.borderColor="aqua";

		//生成到界面上
		d.appendChild(init);
		d.appendChild(on);
		d.appendChild(res);
    	document.body.appendChild(d);
    }

    function setFast(id){
    	var fast=document.getElementById(id).value;
		if(fast==0){
			fast=1;
			alert("你输入的倍数非法,已为你自动调整到原倍速!");
		}
		console.log("执行倍速:"+fast);
    	videojs.getPlayers("video-player").html5player.tech_.setPlaybackRate(fast);
    }

    function getInputFastAndSet(inid,btnid){
    	var on=document.getElementById(btnid);
    	on.onclick=function(){
    		setFast(inid);
    	}
    }

    createInput("in","btn");
    getInputFastAndSet("in","btn");
})();