shumin-Bilibili

视频结束时自动关全屏,添加获取视频封面按钮,修改为彩虹进度条高能进度条改灰色,缩窄顶栏,简化动态页并淡化非视频动态,清理链接,不显示视频页面的弹幕盒子、广告等右栏杂物,直接显示推荐视频。

目前為 2024-11-07 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            shumin-Bilibili
// @namespace       https://www.tampermonkey.net/
// @version         3.0.1
// @description     视频结束时自动关全屏,添加获取视频封面按钮,修改为彩虹进度条高能进度条改灰色,缩窄顶栏,简化动态页并淡化非视频动态,清理链接,不显示视频页面的弹幕盒子、广告等右栏杂物,直接显示推荐视频。
// @author          庶民player
// @license         MIT
// @match           *.bilibili.com/*
// @icon            https://static.hdslb.com/images/favicon.ico
// @require         https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @grant           none
// @run-at          document-idle
// ==/UserScript==
 
 
 
function go_dn(elem_name){
    for(
        let cur_li = $(elem_name) , next_li = cur_li.next();
        next_li.length > 0;
        next_li = cur_li.next()
    ){
        next_li.after(cur_li);
    }
}
function thin_top(){
    let set_h = 42

    function thin_topbar(){
        $(".bili-header.fixed-header")[0].style.cssText += 'height: '+set_h+'px !important; min-height: '+set_h+'px !important;';
        $(".bili-header__bar.mini-header")[0].style.cssText += 'height: '+set_h+'px !important; min-height: '+set_h+'px !important;';

        $(".bili-header__bar.mini-header").css({
            "padding-left": "7px",
            "padding-right": "0px",
        });
    }

    thin_topbar();
    const observer = new MutationObserver(() => {
        $("#biliMainHeader")[0].style.cssText += 'height: '+ set_h +'px !important; min-height: '+set_h+'px !important; top: '+( (set_h-64)/2 )+'px !important;';

        thin_topbar();
    });
    observer.observe(document.body, { childList: true, subtree: true });// 开始观察特定的DOM节点
}
 
 
$(document).ready(function () {
     thin_top();
 
 
//-=-=-=-=-=-=-=-=-=-=-=-=-t.bili-=-=-=-=-=-=-=-=-=-=-=-
    
    if (window.location.href.indexOf("t.bilibili.com") >= 0 ){
 
        if(window.location.href.indexOf("tab=video") < 0)
            $(".bili-dyn-list-tabs__item:nth-child(2)").click();
        //window.location.href = "https://t.bilibili.com/?tab=video";
 
        $(".right").hide();
        $(".left").hide();
 
        /*$(".bili-backtop").css({
            "right": "0px",
            "bottom": "300px",
        });*/
 
        $(document.body).css({'overflow-x':'hidden'});
        //$(".left-entry").remove();
        //$(".offset-center-search").remove();


function filterContent() {
    const elements = document.querySelectorAll('.bili-dyn-item__main');
    elements.forEach(function(element) {
        // 遍历所有匹配的元素// 使用 querySelector 来查找内部的子元素
        let opct = '0.5';

        if (
            element.querySelector(".bili-dyn-card-article") ||
            element.querySelector(".bili-dyn-card-audio") ||
            element.querySelector('.bili-dyn-card-video') ||
            element.querySelector('.bili-dyn-card-pgc')
        ){ opct = '1.0'; } // 白名单

        if (
            element.querySelector('.dyn-card-opus') ||
            element.querySelector('.reference') ||
            !element.querySelector("div[data-type='comment']") ||//不能评论的
            false
        ){ opct = '0.5'; } // 也许有用也许没用的,回调半透明

        if (
            element.querySelector(".dyn-goods") ||
            element.querySelector(".bili-dyn-card-goods") ||
            element.querySelector(".bili-dyn-card-reserve") ||
            element.querySelector(".bili-dyn-card-vote") ||
            element.querySelector(".lottery") ||
            element.querySelector(".bili-dyn-card-live") ||
            element.querySelector(".bili-dyn-card-event") ||
            element.querySelector(".bili-dyn-upower-common") ||
            element.querySelector(".dyn-blocked-mask__content") ||
            $(element).find('.bili-dyn-card-common__badge').filter(function() {
                return $(this).text().trim() === '活动';
            }).length > 0 ||
            $(element).find('.bili-dyn-card-video__badge').filter(function() {
                return (
                    $(this).text().trim() === '充电专属' ||
                    $(this).text().trim() === '直播回放' ||
                    false
                )
            }).length > 0 ||
            false
        ){ opct = '0.2'; } // 含黑名单的,全透明



        element.style.opacity = opct;
    });

}

        /*const listContainer = document.querySelector('.bili-dyn-list__items');  // 动态列表容器
        const observer = new MutationObserver(filterContent);
        if (listContainer) { observer.observe(listContainer, { childList: true, subtree: true }); }*/

        //window.addEventListener('scroll', filterContent);
        let scroll_inter = 256, scroll_num = scroll_inter;
        window.addEventListener('scroll', () => {
            scroll_num++;
            if (scroll_num > scroll_inter) {
                filterContent();
                scroll_num = 0; setTimeout(() => { scroll_num = scroll_inter; }, 100);
            }
        });

 
        return;
    }
 
//-=-=-=-=-=-=-=-=-=-=-=-=-自动关全屏-=-=-=-=-=-=-=-=-=-=-=-
 
    if (window.location.href.indexOf("bilibili.com/video/") >= 0 ){
        let cycle_id = setInterval(() => {
            if(
                $(".bpx-player-ending").is(":visible") ||
                $(".bpx-player-electric-box").is(":visible") ||
                false
            ) {
                document.webkitCancelFullScreen();
                document.exitFullscreen();
                document.cancelFullScreen();
            }
        }, 1000);
    }
 
//-=-=-=-=-=-=-=-=-=-=-=-=-下移、清理链接、高能进度条改绿色-=-=-=-=-=-=-=-=-=-=-=-
    
    window.onload = function(){
        setTimeout(
            () => {
                go_dn('.video-card-ad-small');
                go_dn('.video-page-game-card-small');
                go_dn('#paybar_module');
                go_dn('#danmukuBox');
 
                if (window.location.href.indexOf("bilibili.com/video/") >= 0 )
                    window.history.replaceState( null, null, window.location.pathname);




                const playedRect = document.querySelector('rect[clip-path="url(#bpx-player-pbp-played-path)"]');
                if (playedRect) {
                    const css = `
                        rect[clip-path="url(#bpx-player-pbp-played-path)"] {
                            fill: #808080 !important; /* 设置 played 部分为绿色 */
                        }
                    `;
                    // 将 CSS 添加到页面
                    var style = document.createElement('style');
                    style.type = 'text/css';
                    style.appendChild(document.createTextNode(css));
                    document.head.appendChild(style);
                }




            },
            5000
        )
    }
 
//-=-=-=-=-=-=-=-=-=-=-=-=-=-彩虹条=-=-=-=-=-=-=-=-=-=-=-=-=
    var css = `
    /* 进度条样式 */
    .bpx-player-progress-schedule-current {
        /*background: linear-gradient(
            to left,
            #FF0000 0%,
            #FF7F00 16.5%,
            #FFFF00 33%,
            #00FF00 50%,
            #0000FF 66%,
            #4B0082 83.5%,
            #9400D3 100%
        ) !important;*/
        background: linear-gradient(
            to left,
            #FF004D 0%,
            #FF6600 16.5%,
            #FFCC00 33%,
            #66FF33 50%,
            #33CCFF 66%,
            #9933FF 83.5%,
            #FF3399 100%
        ) !important;
    }
    /* 缓冲条样式*/
    .bpx-player-progress-schedule-buffer {
        background: repeating-linear-gradient(
            45deg,
            #888888 0,
            #888888 20px,
            #000000 20px,
            #000000 40px
        );
        background-size: 200% 200%;
        animation: barberPole 10s linear infinite;
    }
    @keyframes barberPole {
        0% { background-position: 0% 0%; }
        100% { background-position: 200% 200%; }
    }
    `;
    if (typeof GM_addStyle != "undefined") {
        GM_addStyle(css);
    } else if (typeof PRO_addStyle != "undefined") {
        PRO_addStyle(css);
    } else if (typeof addStyle != "undefined") {
        addStyle(css);
    } else {
        var node = document.createElement("style");
        node.type = "text/css";
        node.appendChild(document.createTextNode(css));
        var heads = document.getElementsByTagName("head");
        if (heads.length > 0) {
            heads[0].appendChild(node);
	} else {
		// no head yet, stick it whereever
		document.documentElement.appendChild(node);
	}
}

//-=-=-=-=-=-=-=-=-=-=-=-=封面-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
    if (window.location.href.indexOf("bilibili.com/video/") < 0 ) return;
    const openInNew = true; //是否在新标签页中打开图片地址
    const item = document.createElement('item');
    item.id = 'SIR';
    item.innerHTML = `
        <button class="SIR-button">获取封面</button>
    `;
    document.body.append(item)
 
    const style = document.createElement('style');
 
    var ss = `
      #SIR * {
          box-sizing: border-box;
          padding: 0;
          margin: 0;
      }
      #SIR .SIR-button {
          cursor: pointer;
          display: inline-block;
          height: 26px;
          margin-right: 10px;
          border: solid 1px ;
          border-radius: 3px;
          font-size: 13px;
          padding:0 5px;
          z-index: 5;
          opacity: 0.5;
          position:absolute;
    `;/*
 
          color: #FB7299;
          background: #66CCFF;
    */
 
    style.innerHTML = ss
        +"top:"
        +($('#arc_toolbar_report').offset().top + $('#arc_toolbar_report').height()*-0.2)//17
        +"px; left:"
        +($('#arc_toolbar_report').offset().left + $('#arc_toolbar_report').width()*0.58)
        +"px;}";
    const button = item.querySelector('.SIR-button')
    button.onclick = () => {
        if(openInNew) {
        window.open(getUrl());
        } else {
        self.location = getUrl();
        }
    }
    document.head.append(style)
 
    function getUrl() {
        // 获取当前视频的 BV 号
        var source_url = window.location.href;
        var video_BV = /https:\/\/www\.bilibili\.com\/video\/(BV\w+)/i;

        var match = source_url.match(video_BV);
        if (!match) {
            console.error("无法获取BV号");
            return;
        }

        var bvid = match[1]; // 提取 BV 号
        var api_url = `https://api.bilibili.com/x/web-interface/view?bvid=${bvid}`;

        // 创建 XMLHttpRequest 对象并发送 API 请求
        var xhr = new XMLHttpRequest();
        xhr.open('GET', api_url, false);
        xhr.send();

        // 解析 API 响应
        if (xhr.status === 200) {
            var response = JSON.parse(xhr.responseText);

            // 检查响应中是否包含封面地址
            if (response.code === 0 && response.data && response.data.pic) {
                return response.data.pic; // 返回封面图片地址
            } else {
                console.error("未能获取封面信息");
                return;
            }
        } else {
            console.error("请求失败,状态码: " + xhr.status);
            return;
        }
    }



});