Greasy Fork

Greasy Fork is available in English.

在视频信息区显示视频 av 号

Display avid on video information header.

当前为 2025-06-22 提交的版本,查看 最新版本

// ==UserScript==
// @name         在视频信息区显示视频 av 号
// @namespace    im.outv.userscripts.bilibili.avid
// @version      0.2.0
// @description  Display avid on video information header.
// @author       You
// @match        https://www.bilibili.com/video/*
// @match        https://*.bilibili.com/video/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let afterStyleBlock;

    function createStyleBlock() {
        const style = document.createElement("style")
        document.body.appendChild(style)
        return style
    }

    function updateAvidDisplay(aid, bvid) {
        if (!aid) return
        if (!afterStyleBlock) {
            afterStyleBlock = createStyleBlock()
        }

        afterStyleBlock.innerText = `#viewbox_report .video-info-meta:after { content: "${bvid} av${aid}"; color: var(--text3); }`
        console.log("Updated", aid, bvid, afterStyleBlock)
    }

    function onStateUpdate(value) {
        console.log("State updated", value)
        updateAvidDisplay(window.__INITIAL_STATE__.aid, window.__INITIAL_STATE__.bvid)

    }

    if (typeof window.__INITIAL_STATE__ === "undefined") {
      window.__INITIAL_STATE__ = {};
    }
    window.__INITIAL_STATE__ = new Proxy(window.__INITIAL_STATE__, {
        set(target, prop, value) {
            target[prop] = value;
            onStateUpdate(value);
            return true;
        }
    });
})();