// ==UserScript== // @name B站弹幕查询器(查发布者) // @namespace PyHaoCoder // @version 1.0 // @description 通过B站视频查询弹幕并查找指定用户,未经授权禁止修改、分发或商业用途;举报不成功呢,气死咯,说别人内心狭隘,自己搁这天天蹲点举报,我笑死,纯小丑一个🤡 // @author PyHaoCoder // @icon https://www.bilibili.com/favicon.ico // @match https://www.bilibili.com/video/* // @grant GM_xmlhttpRequest // @grant GM_addStyle // @connect api.bilibili.com // @license Proprietary // @copyright 2025, PyHaoCoder (All Rights Reserved) // @downloadURL none // ==/UserScript== (function () { 'use strict'; // 定时器间隔时间(单位:毫秒) const intervalTime = 1000; // 5秒 // ==================== 获取视频CID ==================== function fetchCID() { const bvid = location.href.split('/')[4].split('?')[0]; const url = `https://api.bilibili.com/x/player/pagelist?bvid=${bvid}&jsonp=jsonp` GM_xmlhttpRequest({ method: 'GET', url: url, onload: function (response) { // 获取页面内容 const pageContent = response.responseText; const data = JSON.parse(pageContent); if (data.data) { // 获取视频CID window._cid = data.data[0].cid; // 更新全局变量 console.log('获取视频CID:', window._cid); // 更新 _url if (!window._url || location.href !== _url) { window._url = location.href; } } else { console.error('获取视频CID失败'); } }, onerror: function (err) { console.log('获取视频CID失败:' + err.statusText); } }); } // 隐藏表格 function hideTable() { const container = document.getElementById('resultContainer') container.style.display = "none" } // 初始化定时器 function startTimer() { setInterval(() => { // 如果 _url 未定义或当前 URL 不等于 _url,则更新 CID if (window._url && location.href !== window._url) { fetchCID(); hideTable(); } }, intervalTime); } // 首次初始化 fetchCID(); // 启动定时器 startTimer(); })(); (function () { 'use strict'; // ==================== 哈希转换模块 ==================== window.BiliBili_midcrc = function () { 'use strict'; const CRCPOLYNOMIAL = 0xEDB88320; const startTime = new Date().getTime(), crctable = new Array(256), create_table = function () { let crcreg, i, j; for (i = 0; i < 256; ++i) { crcreg = i; for (j = 0; j < 8; ++j) { if ((crcreg & 1) != 0) { crcreg = CRCPOLYNOMIAL ^ (crcreg >>> 1); } else { crcreg >>>= 1; } } crctable[i] = crcreg; } }, crc32 = function (input) { if (typeof (input) != 'string') input = input.toString(); let crcstart = 0xFFFFFFFF, len = input.length, index; for (let i = 0; i < len; ++i) { index = (crcstart ^ input.charCodeAt(i)) & 0xff; crcstart = (crcstart >>> 8) ^ crctable[index]; } return crcstart; }, crc32lastindex = function (input) { if (typeof (input) != 'string') input = input.toString(); let crcstart = 0xFFFFFFFF, len = input.length, index; for (let i = 0; i < len; ++i) { index = (crcstart ^ input.charCodeAt(i)) & 0xff; crcstart = (crcstart >>> 8) ^ crctable[index]; } return index; }, getcrcindex = function (t) { for (let i = 0; i < 256; i++) { if (crctable[i] >>> 24 == t) return i; } return -1; }, deepCheck = function (i, index) { let tc = 0x00, str = '', hash = crc32(i); tc = hash & 0xff ^ index[2]; if (!(tc <= 57 && tc >= 48)) return [0]; str += tc - 48; hash = crctable[index[2]] ^ (hash >>> 8); tc = hash & 0xff ^ index[1]; if (!(tc <= 57 && tc >= 48)) return [0]; str += tc - 48; hash = crctable[index[1]] ^ (hash >>> 8); tc = hash & 0xff ^ index[0]; if (!(tc <= 57 && tc >= 48)) return [0]; str += tc - 48; hash = crctable[index[0]] ^ (hash >>> 8); return [1, str]; }; create_table(); const index = new Array(4); // 单次转换函数 const singleConvert = function (input) { let ht = parseInt('0x' + input) ^ 0xffffffff, snum, i, lastindex, deepCheckData; for (i = 3; i >= 0; i--) { index[3 - i] = getcrcindex(ht >>> (i * 8)); snum = crctable[index[3 - i]]; ht ^= snum >>> ((3 - i) * 8); } for (i = 0; i < 100000000; i++) { lastindex = crc32lastindex(i); if (lastindex == index[3]) { deepCheckData = deepCheck(i, index) if (deepCheckData[0]) break; } } if (i == 100000000) return -1; return i + '' + deepCheckData[1]; }; // 批量转换函数 const batchConvert = function (hashArray) { return hashArray.map(function (hash) { return singleConvert(hash); }); }; return { singleConvert: singleConvert, // 单次转换 batchConvert: batchConvert // 批量转换 }; }; })(); (function () { 'use strict'; // ==================== 油猴脚本主逻辑 ==================== // 创建UI界面 function createUI() { const style = ` `; const html = `
用户MID | 时间 | 内容 |
---|---|---|
${comment.mid} | ${comment.date} | ${text} |