bili_optimizer

1.自动展开视频简介 2.点击宽屏模式自动将播放器和页面下边沿对齐

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         bili_optimizer
// @namespace    http://tampermonkey.net/
// @version      2024-12-05
// @description  1.自动展开视频简介 2.点击宽屏模式自动将播放器和页面下边沿对齐
// @author       Han Shuwang
// @match        https://www.bilibili.com/video/*
// @match        https://www.bilibili.com/list/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// ==/UserScript==
// 添加WEBHOOK
(function() {
    'use strict';

    // Your code here...
    setTimeout(() => {
        // 获取播放器容器元素
        const playerContainer = document.getElementById('bilibili-player');

        // 获取目标按钮
        const targetButton = document.querySelector('.bpx-player-ctrl-btn.bpx-player-ctrl-wide');

        if (playerContainer && targetButton) {
            targetButton.addEventListener('click', () => {
                // console.log("点击了宽屏模式");
                // 获取播放器容器的位置和尺寸
                let rect = playerContainer.getBoundingClientRect();

                // 获取浏览器窗口的高度
                let viewportHeight = window.innerHeight;

                // 检查播放器下边沿是否在浏览器下边沿之上
                if (rect.bottom > viewportHeight) {
                    // 计算需要滚动的偏移量
                    const offset = rect.bottom - viewportHeight;

                    // 使用 smooth 滚动到目标位置
                    window.scrollBy({
                        top: offset,
                        behavior: 'smooth'
                    });
                    console.log("已对齐");
                }
            });
        }
        unfold_discription();

    }, 4000);//延时4秒,可自己修改,单位ms

function unfold_discription(){
    var unfold_flag = 0;
    let desciption_unfold = document.getElementsByClassName('toggle-btn');
    if(desciption_unfold&&unfold_flag==0){
        if(desciption_unfold[0].textContent == '展开更多')
        {
            desciption_unfold[0].click();
            unfold_flag = 1;
            console.log("已展开");
        }
    }
}
})();