阿里网盘播放器防挡字幕

阿里网盘网页播放器老是挡住我的字幕,该脚本用于防止视频控制器挡住字幕,实现方式为简单地将控制器上移,修改代码中的fff变量可以设置控制器的高度。

目前為 2021-11-21 提交的版本,檢視 最新版本

// ==UserScript==
// @name         阿里网盘播放器防挡字幕
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  阿里网盘网页播放器老是挡住我的字幕,该脚本用于防止视频控制器挡住字幕,实现方式为简单地将控制器上移,修改代码中的fff变量可以设置控制器的高度。
// @author       voeoc
// @match        https://www.aliyundrive.com/*
// @icon         https://www.google.com/s2/favicons?domain=aliyundrive.com
// @grant        GM_addStyle
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_notification
// @run-at       document-end
// @license MIT 
// ==/UserScript==

(function() {
    'use strict';
    const GMKEY_CONTROL_PANEL_BOTTOM_VALUE = "VOEOC_GMKEY_CONTROL_PANEL_BOTTOM_VALUE";

    const MENU_ACCESS_KEY_CONTROL_PANEL_BOTTOM = "VOEOC_MENU_ACCESS_KEY_CONTROL_PANEL_BOTTOM";

    let controlPanelBottom = GM_getValue(GMKEY_CONTROL_PANEL_BOTTOM_VALUE, 150);
    addControlPanelBottomStyle();
    // 添加移出鼠标自动隐藏的功能
    waitElementLoaded(".video-player--29_72", (videoControlPanel) => {
        videoControlPanel.addEventListener("mouseout", function() {
            videoControlPanel.classList.remove("show--Zy5bU");
        });
        videoControlPanel.addEventListener("mouseover", function() {
            videoControlPanel.classList.add("show--Zy5bU");
        });
    });
    // 注册(不可用)菜单项
    registerMenuCommandControlPanelBottom();

    function addControlPanelBottomStyle() {
        GM_addStyle(`.video-player--29_72{bottom:${controlPanelBottom}px;}`);
        GM_addStyle(`:fullscreen .video-player--29_72{bottom:${controlPanelBottom}px;}`);
    }

    function registerMenuCommandControlPanelBottom() {
        let menuId = GM_registerMenuCommand(
            `控制器高度[${controlPanelBottom}]`,
            function(){
                let newBottom = prompt("请输入新的控制器高度:", controlPanelBottom);
                if(newBottom != null && newBottom != controlPanelBottom) {
                    GM_setValue(GMKEY_CONTROL_PANEL_BOTTOM_VALUE, newBottom);
                    controlPanelBottom = newBottom;
                    addControlPanelBottomStyle();
                    GM_notification({text: `已设置控制器高度!!\n(点击刷新网页)`, timeout: 3500, onclick: function(){location.reload();}});
                    // 重新注册(不可用)菜单
                    GM_unregisterMenuCommand(menuId);
                    registerMenuCommandControlPanelBottom();
                }
            },
            MENU_ACCESS_KEY_CONTROL_PANEL_BOTTOM);
    }

    function waitElementLoaded(selector, func) {
        const TIME_OUT = 100; // 找100次没有找到就放弃
        let findTimeNum = 0; // 记录查找的次数
        let timer = setInterval(() => {
            let element = document.querySelector(selector);
            console.log(`voeoc: 查找${selector}:${element}`)
            if (element != null) {
                // 清除定时器
                clearInterval(timer);
                func(element);
            } else {
                findTimeNum++;
                if (TIME_OUT < findTimeNum) {
                    // 清除定时器,并且不执行回调
                    clearInterval(timer);
                    console.log(`voeoc: 查找${selector}失败`)
                }
            }
        }, 200);
    }

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址