Greasy Fork

Greasy Fork is available in English.

真学添加视频加速按钮

用于真学网站的视频播放器助手

当前为 2019-10-08 提交的版本,查看 最新版本

// ==UserScript==
// @name 真学添加视频加速按钮
// @description 用于真学网站的视频播放器助手
// @namespace Violentmonkey Scripts
// @match http://bl.crtvup.com.cn/index.php
// @grant none
// @version 1.1
// ==/UserScript==

(function() {
  'use strict';
  var speedList = [1, 1.25, 1.5, 1.75, 2];
  window.onload=function(){
    // 添加视频加速按钮
    let controlBar = document.getElementsByClassName("vjs-control-bar")[0];
    speedList.forEach(function(e){
      let btn=document.createElement("button");
      let text=document.createTextNode(e+"x");
      btn.appendChild(text);

      controlBar.appendChild(btn);
      btn.setAttribute("data", e);
      btn.onclick=function() {
        setSpeed(e);
      };
    });

    // 删除右键菜单屏蔽
    document.body.oncontextmenu = null;
    document.getElementById("my-video").oncontextmenu = null;
    document.getElementById("my-video_html5_api").oncontextmenu = null;
    
    // 修改视频高度
    document.getElementById("my-video").style.height = "calc(100vh - 60px)";
    document.getElementById("right_list").style.height = "calc(100vh - 60px)";
  }
  function setSpeed(rate) {
     window.videojs.getPlayers("my-video")["my-video"].tech_.setPlaybackRate(rate)
  }
})();