Greasy Fork is available in English.

喵哉B站数据分析助手

显示当前B站视频的详细数据,用作简单的数据对比和分析。

// ==UserScript==
// @name         喵哉B站数据分析助手
// @namespace    http://tampermonkey.net/
// @version      1.18
// @description  显示当前B站视频的详细数据,用作简单的数据对比和分析。
// @author       喵哉小茶馆
// @license      MIT
// @match        https://www.bilibili.com/video/*
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAXIUlEQVRoQ8WaeXic1ZXmf/d+S5WqJJVKu2RJtmVZNrbBBoMJm1kNBIewGchCSICk092Th2l6SEh3J5nMTJYmk55MQochdDokpElCiMHBJGDMbgMG29jG4H2TZO1Laan9++4980cJg1mydM/zzPvn9+m757z33POec24J/h/i9ts/f7uVPSK2RwojA2KK3WLlkFg5LNYeEGv3i0iXWNkjDz50z2/e/f1/BOrdD/5c7Hz1uYMtdTXtowe7iTS20Lygg6IaRQ28wvhvb6f+cxtA5VAqimBRYgnRuNZDdB6lwFrHus5sV0Devf6fin83ETvyhogosILK5SGTAWPBFAm15vCRSRKtPVSdeAERpxKhiFIuiCI/7OPXTaIkipIcRlex7rZP8+E7v8Os1hWzuodHut5t74/hzyZiR944tmvKKkQJZnQcNzQQBlhr33qLERgsRGg+YwYaBzClNUIH7UJgiwT3LkCI8NLIR1j+yVv520NFsuMZfrrqI3+Wb+67H3wQ5s+dPX/3y2t3Hxf70EA+h7IGE4aod5AAcJTQHM3Ts+ZlZlx5CY6MoYiCVSAWSzllBZcCUawTQW3rZrWX5ILGVnKrH5Kthw5sPvuLf7fsbYMfjD+J9eDu54fqaqvrEEEJSBCgAoMpBGBDFKBzBQ709DOrrQVUSDGwjOooTa5BWzi8/yizrr0IJRmU9lHTOyIYUC4P/+ebuWL55ym4Dk5gcZUQOhoHjX/VNX/Uzz8aEXtksyhAMnnQ0zkhBhsasCHalDyyojhqKyn6VThiUSgGR8ZorgMEZnY2M7D5CM1LZqO8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gQW/vJAce+SXLz1hG2D+Je/EppYHKCqI0OFIqJ2J5/elnWbd2zdYv/Z/7Tz1uwffBn0TkLQTrfiEqGcGp1ITzLsMRD6UMtphFtj+DyhRQy1ehHIfSkSodq7eOVmoszdCWnXSWOYTJKHRnEZUnU5hgvLuPXCRCmE5TriNUNdQz4zPXlxXCMH+8F++PP3i03g3vkk+oVZcsX/Xgd29/SL/+OOrElRgUwVAPU2MjVIw5OBNp3OoE2XSByckMYS5HQ3szvtIU8wWmbEC6a5yKykYOd+1iRnUzVbVVDPRvZe6tt7DjkScxK847WDtvXse77f8h/FkReSe+feed37nji7d9UUQT7HwKP5hB/tBmfnkow813fGF65emISOm/UF5+eD3J/iHabRn+4jqsDZnqGSbix/CrPJ7v6x9fcctNyeMt/Wn4dxN5C77v+2NrH8w7k5NKlKXnpHPomDMTpd2ShE6bGNqyi+qJFPk3usCAXtqCZw0Ky4rbbj//uR3bnztu4f/fWLHi4g8/euddY8NDYzI4OCZ5Y8QERXntH/9ZNv3TXbLl7h8VPrP0zC+/+7v/KP4vi4QYS7aq654AAAAASUVORK5CYII=
// @grant        none
// ==/UserScript==

(function () {
  "use strict";

  // 信息面板对象
  var InfoBoard = (function () {
    function remove() {
      document.querySelectorAll(".mz_videoInfo").forEach((e) => e.remove());
    }
    function create() {
      var t = document.createElement("div");
      t.className = "mz_videoInfo";
      t.style.color = "#A0A4AA";
      t.style.whiteSpace = "nowrap";
      document.querySelector(".left-container").insertBefore(t, document.querySelector("#v_desc"));
      return t;
    }
    function addTxt(txt) {
      var t = document.createElement("span");
      t.appendChild(document.createTextNode(txt));
      t.style.width = "140px";
      t.style.display = "inline-block";
      document.querySelector(".mz_videoInfo").appendChild(t);
      return t;
    }
    function nextRow() {
      var t = document.createElement("br");
      document.querySelector(".mz_videoInfo").appendChild(t);
      return t;
    }
    function addButton(name, fn) {
      var o = document.createElement("input");
      o.style.margin = "2px";
      o.style.padding = "1px";
      o.type = "button";
      o.value = name;
      o.addEventListener("click", fn);
      document.querySelector(".mz_videoInfo").appendChild(o);
      return o;
    }

    return {
      remove: remove,
      create: create,
      nextRow: nextRow,
      addTxt: addTxt,
      addButton: addButton,
    };
  })();

  // 求百分比
  function percent(a, b) {
    return Number((a / b) * 100).toFixed(2);
  }

  // 求多少万
  function w(num, wStr = "w") {
    if (num > 10000) {
      let result = num / 10000;
      result = Math.floor(result * 100) / 100;
      var s_x = result.toString(); //将数字转换为字符串
      var pos_decimal = s_x.indexOf("."); //小数点的索引值
      // 当整数时,pos_decimal=-1 自动补0
      if (pos_decimal < 0) {
        pos_decimal = s_x.length;
        s_x += ".";
      }
      // 当数字的长度< 小数点索引+2时,补0
      while (s_x.length <= pos_decimal + 2) {
        s_x += "0";
      }
      s_x += wStr;
    } else {
      s_x = num;
    }
    return s_x;
  }

  // 等待特定元素,然后执行callback
  function waitFor(selector, callback, maxAttempts = 100, interval = 100) {
    let attempts = 0;
    const intervalId = setInterval(() => {
      if (document.querySelector(selector)) {
        console.log(`${selector}已出现。`);
        callback();
        clearInterval(intervalId);
      } else {
        attempts += 1;
        console.log(`第${attempts}次尝试寻找${selector}失败。`);
        if (attempts >= maxAttempts) {
          clearInterval(intervalId);
          console.log(`尝试次数超过${maxAttempts}次,停止尝试。`);
        }
      }
    }, interval);
  }

  // 打开脚本主页
  function updateScript() {
    window.open("https://greasyfork.org/zh-CN/scripts/449366-%E5%96%B5%E5%93%89b%E7%AB%99%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E5%8A%A9%E6%89%8B", "_blank");
  }

  // 设置:B站刷新时执行fn
  function setAutoRefresh(fn) {
    function waitForVue(callBack) {
      var taskId = setInterval(check, 500, callBack);
      var tryTime = 0;
      function check() {
        if (typeof document.querySelector("#app").__vue__ != "undefined") {
          clearInterval(taskId);
          callBack();
        } else {
          tryTime += 1;
          if (tryTime >= 20) throw "尝试20次(10s)后扔未找到vue, 程序退出。";
          console.log("没有找到vue, 等待500ms后重试。");
        }
      }
    }
    function setAfterHooks() {
      document.querySelector("#app").__vue__.$router.afterHooks.push(() => fn());
    }
    waitForVue(setAfterHooks);
  }

  // 按钮功能 检查更新
  function buttonFn_checkUpdate() {
    InfoBoard.nextRow();
    InfoBoard.addTxt("正在检查更新...");
    InfoBoard.nextRow();

    // 发送请求
    var updateRequest = new XMLHttpRequest();
    var url = "https://greasyfork.org/zh-CN/scripts/449366-%E5%96%B5%E5%93%89b%E7%AB%99%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E5%8A%A9%E6%89%8B";
    updateRequest.open("GET", url, true);
    updateRequest.send();
    updateRequest.onreadystatechange = onreadystatechange;

    function onreadystatechange() {
      if (updateRequest.readyState != 4 || updateRequest.status != 200) return;

      // 将网页保存到body
      if (!document.querySelector(".mz_checkUpdate")) {
        var div = document.createElement("div");
        div.className = "mz_checkUpdate";
        div.style.display = "none";
        div.innerHTML = updateRequest.responseText;
        document.querySelector("body").appendChild(div);
      }

      var v = document.querySelector(".mz_checkUpdate").querySelector(".install-link").getAttribute("data-script-version");
      if (v != version) {
        InfoBoard.addButton("从" + version + "更新至" + v, updateScript);
        InfoBoard.addTxt("更新后请刷新此页面。");
      } else {
        InfoBoard.addTxt("当前版本号: " + version + ", 是最新版本。");
      }
    }
  }

  // 按钮功能 打开主页私信反馈
  function buttonFn_advice() {
    window.open("https://space.bilibili.com/157272038", "_blank");
  }

  // 初始化
  function initialize_video_page() {
    document.querySelector(".video-toolbar-left").addEventListener("mouseover", set_sanlian_percent);
    // 修改互动按钮宽度
    document.querySelectorAll(".video-toolbar-left-item").forEach((e) => {
      e.style.width = "auto";
    });
  }

  // 设置三连按钮
  function set_sanlian_percent() {
    var stat = window.__INITIAL_STATE__.videoData.stat;
    var e1 = document.querySelector(".video-like").lastElementChild;
    var e2 = document.querySelector(".video-coin").lastElementChild;
    var e3 = document.querySelector(".video-fav").lastElementChild;
    var e4 = document.querySelector(".video-share-info").lastElementChild;
    if (e1.textContent.indexOf("(") == -1) e1.textContent += "\xa0" + "(" + percent(stat.like, stat.view) + "%)";
    if (e2.textContent.indexOf("(") == -1) e2.textContent += "\xa0" + "(" + percent(stat.coin, stat.view) + "%)";
    if (e3.textContent.indexOf("(") == -1) e3.textContent += "\xa0" + "(" + percent(stat.favorite, stat.view) + "%)";
    if (e4.textContent.indexOf("(") == -1 && e4.textContent.indexOf("点击") == -1) e4.textContent += "\xa0" + "(" + percent(stat.share, stat.view) + "%)";
  }

  // 设置tag (已废弃,很遗憾,阿B已不再提供tag相关数据)
  function set_tags() {
    var s_tags = window.__INITIAL_STATE__.tags;
    var tags = document.querySelectorAll(".tag-link");
    for (var i = 0; i < tags.length; i++) {
      var tag = tags[i];
      var tagTxt = tag.textContent.replace(/\s/g, "");
      // 排除部分标签
      if (tag.parentElement.className.indexOf("firstchannel") != -1) continue;
      if (tag.parentElement.className.indexOf("secondchannel") != -1) continue;
      // 搜索tag的对应的特征值
      var msgs = [];
      for (var j = 0; j < s_tags.length; j++) {
        var e = s_tags[j];
        if (e.tag_name != tagTxt) continue;
        if (e.count && e.count.atten) msgs.push(`关注: ${w(e.count.atten)}`); // 目前失效,阿B给他隐藏起来了
        if (e.count && e.count.use) msgs.push(`使用: ${w(e.count.use)}`); // 目前失效,阿B给他隐藏起来了
        if (e.archive_count && e.archive_count != "" && e.archive_count != "-") msgs.push(`使用: ${e.archive_count}`); // 目前失效,阿B给他隐藏起来了
        if (e.featured_count) msgs.push(`推荐: ${w(e.featured_count)}`);
        if (msgs.length) tag.textContent += ` (${msgs.join(" ")})`;
        break;
      }
    }

    // 展开tag标签
    var t = document.querySelector(".show-more-btn");
    if (t.className.indexOf("unfold") == -1) t.click();
    // t.style.display = "none";
  }

  // 视频页面处理
  function update_video_page() {
    InfoBoard.remove();
    InfoBoard.create();
    InfoBoard.addButton("检查更新", buttonFn_checkUpdate);
    InfoBoard.addButton("私信反馈", buttonFn_advice);
    InfoBoard.nextRow();
    InfoBoard.addTxt("[喵哉B站数据分析助手]正在获取数据...");
    InfoBoard.addTxt("没有反应可以刷新试试...也可能是出bug了...请私信反馈...");

    var video_data = window.__INITIAL_STATE__.videoData;
    var stat = video_data.stat;
    stat.age = ((new Date().getTime() - new Date(video_data.pubdate * 1000).getTime()) / (1000 * 3600 * 24)).toFixed(2);
    set_sanlian_percent();
    // set_tags(); 已废弃

    InfoBoard.remove();
    InfoBoard.create();
    InfoBoard.addButton("检查更新", buttonFn_checkUpdate);
    InfoBoard.addButton("私信反馈", buttonFn_advice);
    InfoBoard.nextRow();
    InfoBoard.addTxt("标题: " + video_data.title);
    InfoBoard.nextRow();

    if (video_data.honor_reply.honor) {
      video_data.honor_reply.honor.forEach((e) => InfoBoard.addTxt(e.desc));
      InfoBoard.nextRow();
    }

    InfoBoard.addTxt("播放: " + w(stat.view));
    InfoBoard.addTxt("年龄: " + stat.age + "天");
    InfoBoard.addTxt("弹幕: " + w(stat.danmaku) + " (" + percent(stat.danmaku, stat.view) + "%)");
    InfoBoard.addTxt("评论: " + w(stat.reply) + " (" + percent(stat.reply, stat.view) + "%)");
    InfoBoard.nextRow();

    InfoBoard.addTxt("点赞: " + w(stat.like) + " (" + percent(stat.like, stat.view) + "%)");
    InfoBoard.addTxt("投币: " + w(stat.coin) + " (" + percent(stat.coin, stat.view) + "%)");
    InfoBoard.addTxt("收藏: " + w(stat.favorite) + " (" + percent(stat.favorite, stat.view) + "%)");
    InfoBoard.addTxt("分享: " + w(stat.share) + " (" + percent(stat.share, stat.view) + "%)");
    InfoBoard.nextRow();
  }

  // 主函数
  function mian() {
    initialize_video_page(); //第一次初始化
    setAutoRefresh(update_video_page); //设置好自动刷新
    update_video_page();
  }

  var version = "1.18"; //当前版本号
  waitFor(".video-share-info-text", mian);
})();