油猴脚本实战:b站视频倍速播放

796 阅读1分钟

视频地址

www.bilibili.com/video/BV1pK…

源码

// ==UserScript==
// @name         修改B站
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.bilibili.com/*
// @require       https://code.jquery.com/jquery-2.1.4.min.js

// ==/UserScript==

(function() {
  'use strict';

  $(()=>{
  
    
    $('body').append(`
    <div id='video_set' style="position:fixed;right:10px;top:10px;z-index:9999;background:red">
      <input id="setPlay" value=1 type="number" style="padding:5px 10px;border:1px solid #ddd;border-radius:3px">
    </div>
    `)
    console.log("引入完成");

    $(document).on('change','#video_set #setPlay',function(){
        console.log(this.value);
        if(this.value<=16){

          document.querySelector('video').playbackRate=this.value
        }
        else{
          alert("最大为16")
        }
    })
  })
    
  // Your code here...
})();