Greasy Fork镜像 支持简体中文。

糊狸-B站成分查询Helper

用于标注B站评论区用户成分属性,三相与Vtuber的数据来源于原插件"新三相之力指示器F",与本人无关;其余为自己添加,优化了原插件堆了七八百行的屎山,动态化处理后仅200余行;仅供娱乐不代表本人任何立场

  1. // ==UserScript==
  2. // @name 糊狸-B站成分查询Helper
  3. // @namespace www.bilibili.com
  4. // @version 1.0.0
  5. // @description 用于标注B站评论区用户成分属性,三相与Vtuber的数据来源于原插件"新三相之力指示器F",与本人无关;其余为自己添加,优化了原插件堆了七八百行的屎山,动态化处理后仅200余行;仅供娱乐不代表本人任何立场
  6. // @author biyuehu
  7. // @match https://*.bilibili.com/*
  8. // @icon https://static.hdslb.com/images/favicon.ico
  9. // @connect bilibili.com
  10. // @grant GM_xmlhttpRequest
  11. // @license MIT
  12. // @run-at document-end
  13. // ==/UserScript==
  14.  
  15. /***
  16. * @Author: Biyuehu
  17. * @Blog: http://imlolicon.tk
  18. * @Date: 2023-02-15 17:46:12
  19. */
  20.  
  21. (function () {
  22. 'use strict';
  23.  
  24. /* 配置区 */
  25. const config = {
  26. times: 2500, // 标签处理间隔时间 单位:ms
  27. testLog: true // 是否开启调试日志
  28. }
  29. // 显示标签配置在👇面
  30.  
  31. const threeList = [
  32. ["【 传奇 | 三相之力】", "原神&明日方舟&王者荣耀", "#FFD700"],
  33. ["【 史诗 | 二刺螈双象限】", "原神&明日方舟&!王者荣耀", "#FF0000"],
  34. ["【 史诗 | 双批齐聚】", "原神&!明日方舟&王者荣耀", "#FF0000"],
  35. ["【 史诗 | 稀有的存在】", "!原神&明日方舟&王者荣耀", "#FF0000"],
  36. ["【 稀有 | 原批】", "原神&!明日方舟&!王者荣耀", "#6600CC"],
  37. ["【 稀有 | 粥畜】", "!原神&明日方舟&王者荣耀", "#6600CC"],
  38. ["【 稀有 | 农批】", "!原神&!明日方舟&王者荣耀", "#6600CC"]
  39. ];
  40.  
  41. const vtuberList = [
  42. ["嘉心糖", "嘉然", "#E799B0"],
  43. ["雏草姬", "塔菲", "#FF00CC"],
  44. ["棺材板", "東雪蓮", "#C0C0C0"],
  45. ["杰尼", "七海", "#947583"],
  46. ["喵喵露", "猫雷", "#00FF00"],
  47. ["三畜", "小狗说", "#B8A6D9"],
  48. ["顶碗人", "向晚", "#9AC8E2"],
  49. ["贝极星", "贝拉", "#DB7D74"],
  50. ["奶淇琳", "乃琳", "#576690"],
  51. ["小星星", "星瞳", "#E0E0E0"],
  52. ["小孩梓", "梓", "#9900FF"]
  53. ];
  54.  
  55. const vocaloadList = [
  56. ["骑士团", "初音|miku|MIKU", "#00CC99"],
  57. ["洛天依", "天依", "#33CCFF"]
  58. ];
  59.  
  60. const igameList = [
  61. ["仙剑"],
  62. ["古剑"],
  63. ["逆水寒"],
  64. ["诛仙世界"],
  65. ["剑网"]
  66. ];
  67.  
  68. const cgameList = [
  69. ["黑神话"],
  70. ["LOL", "英雄联盟|LOL"],
  71. ["COD", "使命召唤"]
  72. ];
  73.  
  74. const ecygameList = [
  75. ["幻塔", null, "#FFCC66"],
  76. ["战双"],
  77. ["鸣潮"],
  78. ["米-零", "绝区零", "#0066FF"],
  79. ["米-崩", "崩坏|崩三", "#0066FF"],
  80. ["米-铁", "星穹铁道", "#0066FF"],
  81. ["光遇"],
  82. ["碧蓝", null, "#33CCC"],
  83. ["月球人", "FGO|冠位指定"],
  84. ["公主", "公主连结", "#CCFF99"],
  85. ["车万人", "东方project|灵梦|芙兰朵露|魔理沙"]
  86. ];
  87.  
  88. const zgameList = [
  89. ["塞尔达"],
  90. ["怪猎", "怪物猎人"]
  91. ];
  92.  
  93. const ogameList = [
  94. ["安慕希", "MINECRAFT|Minecraft|我的世界", "#006600"],
  95. ["传说之下", "UNDERTALE|undertale|Undertale|传说之下", "#333366"],
  96. ["SCP", null, "#330000"]
  97. ];
  98.  
  99. const otherList = [
  100. ["【 隐藏 | 动态抽奖】", "抽奖", "#254680"]
  101. ];
  102.  
  103. const defaultTag = ["【 普通 | 纯良】", "#11DD77"];
  104.  
  105. // 不需要显示的注释即可
  106. const captor = [
  107. ['Vtuber', vtuberList],
  108. ['', threeList],
  109. ['V家', vocaloadList],
  110. ['网游', igameList, "#6666FF"],
  111. ['端游', cgameList, "#6699FF"],
  112. ['二游', ecygameList, "pink"],
  113. ['主机', zgameList],
  114. ['混沌', ogameList, "#FF6600"],
  115. ['', otherList]
  116. ];
  117.  
  118.  
  119. /* Functions */
  120. const getUid = function (htmlEntity) {
  121. if (isNew) {
  122. return htmlEntity.dataset['userId'];
  123. } else {
  124. return htmlEntity.children[0]['href'].replace(/[^\d]/g, "");
  125. }
  126. }
  127.  
  128. const getCommentList = function () {
  129. if (isNew) {
  130. let lst = new Set();
  131. for (let c of document.getElementsByClassName('user-name')) {
  132. lst.add(c);
  133. }
  134. for (let c of document.getElementsByClassName('sub-user-name')) {
  135. lst.add(c);
  136. }
  137. return lst;
  138. } else {
  139. return document.getElementsByClassName('user');
  140. }
  141. }
  142.  
  143. const log = function (message) {
  144. return config.testLog ? console.log(message) : null;
  145. };
  146.  
  147. const searchStr = function (text, rule) {
  148. const ruleAnd = rule.split('&');
  149. let trueNum = 0;
  150. ruleAnd.forEach((rule2) => {
  151. const ruleOr = rule2.split('|');
  152. ruleOr.forEach(rule3 => {
  153. if ((rule3.substr(0, 1) === '!' && text.includes(rule3.substr(1)) !== true) || (rule3.substr(0, 1) !== '!' && text.includes(rule3))) {
  154. trueNum++;
  155. } else {
  156. return false;
  157. }
  158. });
  159. });
  160.  
  161. return trueNum >= ruleAnd.length;
  162. }
  163.  
  164. const spawnHtml = function (data) {
  165. return `<b style='color: ${data[1]}' >${data[0]}</b>`
  166. }
  167.  
  168. const handel = function (text, htmlEntity) {
  169. let result = false;
  170. for (let num = 0; num < captor.length; num++) {
  171. let captorName = captor[num][0],
  172. arr = captor[num][1] ?? '#000000',
  173. captorColor = captor[num][2],
  174. isof;
  175.  
  176. for (let init = 0; init < arr.length; init++) {
  177. let tempArr = arr[init];
  178. let viewName = tempArr[0],
  179. keyword = tempArr[1] || viewName,
  180. color = tempArr[2];
  181.  
  182. if (searchStr(text, keyword)) {
  183. result = true;
  184. if (captorName) {
  185. isof || (htmlEntity.innerHTML += `<b style='color: ${captorColor}' > ${captorName} `);
  186. isof = true;
  187. htmlEntity.innerHTML += '| </b>' + `<b style='color: ${color}'> ${viewName}</b>`;
  188. } else {
  189. htmlEntity.innerHTML += spawnHtml([viewName, color]);
  190. }
  191. }
  192. init === arr.length - 1 && isof && (htmlEntity.innerHTML += `<b style='color: ${captorColor}' >】</b>`);
  193. }
  194. };
  195.  
  196. result || (htmlEntity.innerHTML += spawnHtml(defaultTag));
  197. }
  198.  
  199. const unknown = new Set();
  200. const blog = 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?&host_mid=';
  201. // 检测是不是新版
  202. const isNew = document.getElementsByClassName('item goback').length != 0;
  203.  
  204. log(isNew);
  205. log("Loading...");
  206.  
  207. setInterval(() => {
  208. const commentlist = getCommentList();
  209. if (commentlist.length != 0) {
  210. commentlist.forEach(htmlEntity => {
  211. if (htmlEntity.innerHTML.indexOf(`<span id="huli">`) == -1) {
  212. htmlEntity.innerHTML += `<span id="huli">`;
  213. const uid = getUid(htmlEntity);
  214. unknown.add(uid)
  215.  
  216. GM_xmlhttpRequest({
  217. method: "get",
  218. url: blog + uid,
  219. data: '',
  220. headers: {
  221. 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'
  222. },
  223. onload: res => {
  224. if (res.status === 200) {
  225. unknown.delete(uid);
  226. const text = JSON.stringify(JSON.parse(res.response).data);
  227. handel(text, htmlEntity);
  228. } else {
  229. log('Fail');
  230. log(res);
  231. }
  232. },
  233. });
  234. htmlEntity.innerHTML += `</span>`;
  235. }
  236. });
  237. }
  238. }, config.times)
  239. })();

QingJ © 2025

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