b站显示视频 av 号、bv 号及弹幕 cid

在b站播放页标题栏下面显示视频 av 号、bv 号及弹幕 cid

目前為 2020-05-21 提交的版本,檢視 最新版本

// ==UserScript==
// @name                b站显示视频 av 号、bv 号及弹幕 cid
// @namespace           https://gist.github.com/phtwo
// @version             0.1
// @description         在b站播放页标题栏下面显示视频 av 号、bv 号及弹幕 cid
// @match               *://www.bilibili.com/video/av*
// @match               *://www.bilibili.com/video/BV*
// @grant               none
//
// @author              phtwo
// @homepage            https://gist.github.com/phtwo/e2d8c04707ed6a6369a55be37e3f14c7
// @supportURL          https://gist.github.com/phtwo/e2d8c04707ed6a6369a55be37e3f14c7
//
// @noframes
// @nocompat Chrome
//
// ==/UserScript==

(function () {
  const list = []

  /** @type Element */
  let videoDataLineElem

  setTimeout(init, 500)

  function init() {
    videoDataLineElem = document.querySelector('#viewbox_report .video-data:nth-of-type(2)')
    if (!videoDataLineElem) {
      return
    }

    const {aid, bvid, cid} = window

    addItem('av', aid)
    addItem(' ', bvid)
    addItem('cid', cid)

    const fragment = createFragment()

    const referenceNode = videoDataLineElem.querySelector('.copyright')
    videoDataLineElem.insertBefore(fragment, referenceNode)
  }

  function createFragment() {
    const firstPrefix = '  '
    const prefix = ' · '

    const nodeList = list.map((item, index) => {
      let text = (index === 0 ? firstPrefix : prefix)
        + item.prefix
        + item.value

      const elem = document.createElement('span')
      elem.innerHTML = text
      elem.style.color = '#afafaf'

      return elem
    })

    const fragment = document.createDocumentFragment()
    fragment.append(...nodeList)
    return fragment
  }


  function addItem(prefix = '', value) {
    value && list.push({prefix, value})
  }

})

QingJ © 2025

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