b站视频加速

这个油猴脚本为B站视频播放器添加了一个便捷控制视频播放速度的功能

目前為 2023-09-12 提交的版本,檢視 最新版本

// ==UserScript==
// @name         b站视频加速
// @namespace    ningbnii/monkey_video_speed
// @version      0.0.1
// @author       ningbnii
// @description  这个油猴脚本为B站视频播放器添加了一个便捷控制视频播放速度的功能
// @license      GPLv3
// @icon         https://www.wxbuluo.com/favicon.ico
// @match        https://www.bilibili.com/*
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.global.prod.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js
// @grant        GM_addStyle
// @grant        GM_registerMenuCommand
// ==/UserScript==

(t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const o=document.createElement("style");o.textContent=t,document.head.append(o)})(" .swal2-modal{display:flex!important;flex-direction:column!important}.swal2-modal input{margin:20px auto 0;width:80%!important}.monkey-box[data-v-3e6f1a5b]{box-shadow:2px 2px 4px #000;background:#fff;position:fixed;bottom:0;z-index:1000;display:flex;flex-direction:column;max-width:300px;padding:10px} ");

(function (vue) {
    'use strict';

    const i={__name:"HelloWorld",setup(n){let e=vue.ref(1);const t=document.querySelector("video");t.played&&(t.playbackRate=e.value),t.addEventListener("play",()=>{t.playbackRate=e.value;}),document.addEventListener("keydown",o=>{o.key==="-"&&e.value>.5?e.value-=.5:o.key==="="&&e.value<16&&(e.value+=.5),t.playbackRate=e.value;});function a(){Swal.fire({title:"使用说明",html:`
      <div class="read-the-docs">
        <p>按"-"键减速,按"+"键加速</p>
        <p>当前播放速度:${e.value}</p>
      </div>
    `,showConfirmButton:!0});}return (o,r)=>(vue.openBlock(),vue.createElementBlock("span",{onClick:r[0]||(r[0]=b=>a())},"播放速度:"+vue.toDisplayString(vue.unref(e)),1))}};var v=(()=>typeof GM_registerMenuCommand<"u"?GM_registerMenuCommand:void 0)();const m=(n,e)=>{const t=n.__vccOpts||n;for(const[a,o]of e)t[a]=o;return t},f={class:"monkey-box"},y={__name:"App",setup(n){return v("作者博客",function(){location.href="https://www.wxbuluo.com";}),(e,t)=>(vue.openBlock(),vue.createElementBlock("div",f,[vue.createVNode(i)]))}},k=m(y,[["__scopeId","data-v-3e6f1a5b"]]);vue.createApp(k).mount((()=>{const n=document.createElement("div");return document.body.append(n),n})());

})(Vue);