B站直播SC悬浮窗

将B站直播的SC部分展开显示到一个悬浮窗

目前为 2024-01-07 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name B站直播SC悬浮窗
  3. // @namespace https://gitee.com/zhangsongqiang/userscript/
  4. // @version 0.5
  5. // @description 将B站直播的SC部分展开显示到一个悬浮窗
  6. // @author Zhangsq37
  7. // @match https://live.bilibili.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
  9. // @grant GM_addStyle
  10. // @grant GM_registerMenuCommand
  11. // @license MIT
  12. // @grant unsafeWindow
  13. // ==/UserScript==
  14.  
  15. (function () {
  16.  
  17. const styles_superchat_items = `
  18. div.superchatItem {
  19. width: 85%;
  20. height: auto;
  21. border: 2px solid gray;
  22. border-radius: 10px;
  23. padding: 0%;
  24. margin: 5%;
  25. margin-right: 10%;
  26. transition: background-color 2s;
  27. }
  28. div.superchatItem>div.sc_title {
  29. width: 100%;
  30. padding-top: 4px;
  31. padding-bottom: 4px;
  32. display: flex;
  33. flex-wrap: wrap;
  34. justify-content: space-between;
  35. background-color: #ffffffe0;
  36. border-top-left-radius: 10px;
  37. border-top-right-radius: 10px;
  38. }
  39. div.superchatItem>div.sc_title>div.sc_sender {
  40. min-width: 60%;
  41. max-width: 65%;
  42. height: 20px;
  43. display: flex;
  44. padding-left: 5px;
  45. white-space: nowrap;
  46. overflow: hidden;
  47. text-overflow: ellipsis;
  48. }
  49. div.superchatItem>div.sc_title>div.sc_sender>div.sender_fans_medal_label {
  50. border-top-left-radius: 6px;
  51. border-bottom-left-radius: 6px;
  52. padding-left: 4px;
  53. padding-right: 4px;
  54. padding-bottom: 4px;
  55. /*text-align: center;
  56. text-justify: auto;*/
  57. color: white;
  58. }
  59. div.superchatItem>div.sc_title>div.sc_sender>div.sender_fans_medal_level {
  60. border-top-right-radius: 6px;
  61. border-bottom-right-radius: 6px;
  62. padding-left: 4px;
  63. padding-right: 4px;
  64. /*text-align: center*/
  65. ;
  66. }
  67. div.superchatItem>div.sc_title>div.sc_sender>div.sender_uname>a {
  68. text-decoration: none;
  69. padding-left: 10px;
  70. color: #a70404bd;
  71. }
  72. div.superchatItem>div.sc_title>div.sc_info {
  73. width: 30%;
  74. display: flex;
  75. flex-wrap: nowrap;
  76. justify-content: flex-end;
  77. }
  78. div.superchatItem>div.sc_title>div.sc_info>div.sc_sendtime {
  79. color: #000000ae;
  80. font-weight: bold;
  81. padding-left: 20px;
  82. padding-right: 20px;
  83. display: inline-block;
  84. }
  85. div.superchatItem>div.sc_title>div.sc_info>div.sc_price {
  86. color: #00000050;
  87. font-weight: bold;
  88. padding-right: 5px;
  89. display: inline-block;
  90. }
  91. div.superchatItem>div.sc_content {
  92. padding: 5px;
  93. text-align: left;
  94. padding-left: 10px;
  95. padding-right: 10px;
  96. border-bottom-left-radius: 10px;
  97. border-bottom-right-radius: 10px;
  98. word-break: break-all;
  99. /* 只对英文起作用,以字母作为换行依据 */
  100. word-wrap: break-word;
  101. /* 只对英文起作用,以单词作为换行依据 */
  102. white-space: pre-wrap;
  103. /* 只对中文起作用,强制换行 */
  104. }
  105. div.superchatItem>div.superchat_progress {
  106. width: 100%;
  107. height: 3px;
  108. border-radius: 2px;
  109. }
  110. div.superchatItem>div.superchat_progress>div.superchat_progress_value {
  111. width: 100%;
  112. height: 3px;
  113. border-radius: 1px;
  114. background-color: #00000060;
  115. transition: width 1s linear;
  116. }
  117. `;
  118.  
  119. class SuperChatMonitor {
  120. Monitor(ChatPanelContainer = null) {
  121. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  122. const options = { childList: true };
  123. this.ChatPanelContainer = ChatPanelContainer;
  124. const chat_mutation = new MutationObserver(this.monitor_callback);
  125. chat_mutation.observe(this.ChatPanelContainer, options);
  126. this.SuperchatHistroy = [];
  127. this.handle_new_superchat_data = (superchat_data) => { };
  128. }
  129.  
  130. monitor_callback = (mutationRecoards, observer) => {
  131. mutationRecoards.forEach(mutationRecoard => {
  132. if (mutationRecoard.type == "childList") {
  133. mutationRecoard.addedNodes.forEach(
  134. addnode => {
  135. if (addnode.classList.contains("superChat-card-detail")) {//是SC
  136. this.parse_new_superchat_callback(addnode);
  137. console.info(addnode);
  138. }
  139. }
  140. );
  141. }
  142. else {
  143. console.error(mutationRecoard);
  144. }
  145. });
  146. }
  147.  
  148. parse_new_superchat_callback(new_superchat) {
  149. console.log('new superchat');
  150. var send_time = parseInt(new_superchat.getAttribute("data-ts")) * 1000;
  151. var sender_uname = new_superchat.getAttribute("data-uname");
  152. var sender_uid = new_superchat.getAttribute("data-uid");
  153. var send_content = new_superchat.getAttribute("data-danmaku");
  154. var superChatPrice = parseInt(new_superchat.querySelector("div.card-item-top-right").innerText.split("0电池")[0]);
  155. var sender_fans_medal_label = new_superchat.querySelector("span.fans-medal-content");
  156. var sender_fans_medal_level = new_superchat.querySelector("div.fans-medal-level");
  157. if (sender_fans_medal_label) {
  158. sender_fans_medal_label = sender_fans_medal_label.innerText;
  159. sender_fans_medal_level = sender_fans_medal_level.innerText;
  160. }
  161. var superchat_data = { sender_uname, sender_uid, send_content, superChatPrice, sender_fans_medal_label, sender_fans_medal_level, send_time };
  162. this.SuperchatHistroy.push(superchat_data);
  163.  
  164. this.handle_new_superchat_data(superchat_data); //回调函数,用于处理解析出的数据
  165. }
  166.  
  167. send_history_superchat() {
  168. this.SuperchatHistroy.forEach(
  169. (history_sc_data) => {
  170. this.handle_new_superchat_data(history_sc_data);
  171. }
  172. )
  173. }
  174. }
  175.  
  176. class SuperChatItem {
  177. constructor(superchat_data) {
  178. this.sender_uname = superchat_data.sender_uname;
  179. this.sender_uid = superchat_data.sender_uid;
  180. this.sender_fans_medal_label = superchat_data.sender_fans_medal_label;
  181. this.sender_fans_medal_level = superchat_data.sender_fans_medal_level;
  182. this.send_content = superchat_data.send_content;
  183. this.superChatPrice = superchat_data.superChatPrice;
  184. this.send_time = superchat_data.send_time;
  185. }
  186. generateNode() {
  187. var div_superchatItem = document.createElement("div");
  188. div_superchatItem.className = "superchatItem";
  189. div_superchatItem.style.backgroundColor = this.get_sc_background_color();
  190. var div_sc_title = document.createElement("div");
  191. div_sc_title.className = "sc_title";
  192. var div_sc_sender = document.createElement("div");
  193. div_sc_sender.className = "sc_sender";
  194. var div_sender_fans_medal_label = document.createElement("div");
  195. div_sender_fans_medal_label.className = "sender_fans_medal_label";
  196. var div_sender_fans_medal_level = document.createElement("div");
  197. div_sender_fans_medal_level.className = "sender_fans_medal_level";
  198.  
  199. if (this.sender_fans_medal_label) {
  200. var fans_medal_color = this.get_fans_medal_color();
  201. div_sender_fans_medal_label.style.border = "1px solid " + fans_medal_color;
  202. div_sender_fans_medal_label.style.backgroundColor = fans_medal_color;
  203. div_sender_fans_medal_label.innerText = this.sender_fans_medal_label;
  204.  
  205. div_sender_fans_medal_level.style.border = "1px solid " + fans_medal_color;
  206. div_sender_fans_medal_level.style.color = fans_medal_color;
  207. div_sender_fans_medal_level.innerText = this.sender_fans_medal_level;
  208. }
  209. else {
  210. div_sender_fans_medal_label.style.visibility = "hidden";
  211. div_sender_fans_medal_level.style.visibility = "hidden";
  212.  
  213. }
  214. var div_sender_uname = document.createElement("div");
  215. div_sender_uname.className = "sender_uname";
  216.  
  217.  
  218. var a_uname = document.createElement("a");
  219. a_uname.href = "https://space.bilibili.com/" + this.sender_uid;
  220. a_uname.target = "_blank";
  221. a_uname.innerText = this.sender_uname;
  222. a_uname.title = this.sender_uname;
  223.  
  224. div_sender_uname.appendChild(a_uname);
  225. div_sc_sender.appendChild(div_sender_fans_medal_label);
  226. div_sc_sender.appendChild(div_sender_fans_medal_level);
  227. div_sc_sender.appendChild(div_sender_uname);
  228.  
  229. var div_sc_info = document.createElement("div");
  230. div_sc_info.className = "sc_info";
  231.  
  232. var div_sc_sendtime = document.createElement("div");
  233. div_sc_sendtime.className = "sc_sendtime";
  234. div_sc_sendtime.setAttribute("send-time", this.send_time.toString());
  235. div_sc_sendtime.innerText = (new Date(this.send_time)).toLocaleTimeString();
  236.  
  237. var div_sc_price = document.createElement("div");
  238. div_sc_price.className = "sc_price";
  239. div_sc_price.innerText = "¥" + this.superChatPrice;
  240.  
  241. div_sc_info.appendChild(div_sc_sendtime);
  242. div_sc_info.appendChild(div_sc_price);
  243.  
  244. div_sc_title.appendChild(div_sc_sender);
  245. div_sc_title.appendChild(div_sc_info);
  246.  
  247. var div_sc_content = document.createElement("div");
  248. div_sc_content.className = "sc_content";
  249. div_sc_content.innerHTML = this.send_content + ' ';
  250.  
  251. var div_superchat_progress = document.createElement("div");
  252. div_superchat_progress.className = "superchat_progress";
  253.  
  254. var div_superchat_progress_value = document.createElement("div");
  255. div_superchat_progress_value.className = "superchat_progress_value";
  256. div_superchat_progress.appendChild(div_superchat_progress_value);
  257.  
  258. div_superchatItem.appendChild(div_sc_title);
  259. div_superchatItem.appendChild(div_sc_content);
  260. div_superchatItem.appendChild(div_superchat_progress);
  261.  
  262. this.progress = div_superchat_progress_value;
  263. this.set_progress();
  264. this.div_superchatItem = div_superchatItem;
  265. return div_superchatItem;
  266. }
  267.  
  268. get_sc_background_color() {
  269. let price = this.superChatPrice;
  270. if ((price >= 30) && (price < 50)) {
  271. return "#2c64b4";
  272. } else if ((price >= 50) && (price < 100)) {
  273. return "#447c9c";
  274. } else if ((price >= 100) && (price < 500)) {
  275. return "#c89c24";
  276. } else if ((price >= 500) && (price < 1000)) {
  277. return "#e49444";
  278. } else if ((price >= 1000) && (price < 2000)) {
  279. return "#e44c4c";
  280. } else if (price >= 2000) {
  281. return "#ac1c34";
  282. } else {
  283. return "#ffffff";
  284. }
  285. }
  286.  
  287. get_sc_show_time() {
  288. let price = this.superChatPrice;
  289. if ((price >= 30) && (price < 50)) {
  290. return 60;
  291. } else if ((price >= 50) && (price < 100)) {
  292. return 120;
  293. } else if ((price >= 100) && (price < 500)) {
  294. return 300;
  295. } else if ((price >= 500) && (price < 1000)) {
  296. return 1800;
  297. } else if ((price >= 1000) && (price < 2000)) {
  298. return 3600;
  299. } else if (price >= 2000) {
  300. return 7200;
  301. } else {
  302. return 1;
  303. }
  304. };
  305.  
  306. get_fans_medal_color() {
  307. let fans_medal_level = this.sender_fans_medal_level;
  308. if ((fans_medal_level > 0) && (fans_medal_level <= 4)) {
  309. return "#5c968e";
  310. } else if ((fans_medal_level > 4) && (fans_medal_level <= 8)) {
  311. return "#5d7b9e";
  312. } else if ((fans_medal_level > 8) && (fans_medal_level <= 12)) {
  313. return "#8c7ca4";
  314. } else if ((fans_medal_level > 12) && (fans_medal_level <= 16)) {
  315. return "#bc6484";
  316. } else if ((fans_medal_level > 16) && (fans_medal_level <= 20)) {
  317. return "#c49c24";
  318. } else if ((fans_medal_level > 20) && (fans_medal_level <= 24)) {
  319. return "#2c6a61";
  320. } else if ((fans_medal_level > 24) && (fans_medal_level <= 28)) {
  321. return "#142464";
  322. } else if ((fans_medal_level > 28) && (fans_medal_level <= 32)) {
  323. return "#442474";
  324. } else if ((fans_medal_level > 32) && (fans_medal_level <= 36)) {
  325. return "#942347";
  326. } else if ((fans_medal_level > 36) && (fans_medal_level <= 40)) {
  327. return "#fc7424";
  328. } else {
  329. return "#000000";
  330. }
  331. };
  332.  
  333. set_progress() {
  334. this.sc_show_time = this.sc_leave_time = this.get_sc_show_time();
  335. this.timer = setInterval(() => {
  336. this.sc_leave_time -= 1;
  337. if (this.sc_leave_time == 0) {
  338. this.progress.style.width = "0%";
  339. this.div_superchatItem.style.backgroundColor = "lightgray";
  340. clearInterval(this.timer);
  341. }
  342. else {
  343. this.progress.style.width = (this.sc_leave_time * 100 / this.sc_show_time).toString() + "%";
  344. }
  345. }, 1000);
  346. }
  347.  
  348. static set_styles() {
  349. GM_addStyle(styles_superchat_items);
  350. }
  351. }
  352.  
  353. class FloatingWindow {
  354. constructor() {
  355. if (document.querySelector("div#superChat_Display_Panel")) {
  356. console.warn("悬浮窗口已存在!!!");
  357. }
  358. else {
  359. console.log("创建悬浮窗口");
  360. //顶栏的控制栏
  361. var checkbox_superchat_auto_scroll = document.createElement("input");
  362. checkbox_superchat_auto_scroll.id = "checkbox_superchat_auto_scroll";
  363. checkbox_superchat_auto_scroll.type = "checkbox";
  364.  
  365. var label_for_superchat_auto_scroll_heckbox = document.createElement("label");
  366. label_for_superchat_auto_scroll_heckbox.setAttribute("for", "checkbox_superchat_auto_scroll");
  367. label_for_superchat_auto_scroll_heckbox.innerText = "SC自动滚动";
  368.  
  369. checkbox_superchat_auto_scroll.onchange = () => {
  370. if (checkbox_superchat_auto_scroll.checked) {
  371. superChat_Display_Panel.scrollTo(0, 999999999);
  372. }
  373. };
  374.  
  375. var div_checkbox_superchat_auto_scroll = document.createElement("div");
  376. div_checkbox_superchat_auto_scroll.className = "div_checkbox_superchat_auto_scroll";
  377. div_checkbox_superchat_auto_scroll.style.paddingLeft = "10px";
  378. div_checkbox_superchat_auto_scroll.appendChild(checkbox_superchat_auto_scroll);
  379. div_checkbox_superchat_auto_scroll.appendChild(label_for_superchat_auto_scroll_heckbox);
  380.  
  381. var superChat_Display_Panel_CtrlBar = document.createElement("div");
  382. superChat_Display_Panel_CtrlBar.id = "superChat_Display_Panel_CtrlBar";
  383. superChat_Display_Panel_CtrlBar.appendChild(div_checkbox_superchat_auto_scroll);
  384.  
  385. //主体显示区
  386. var superChat_Display_Panel = document.createElement("div");
  387. superChat_Display_Panel.id = "superChat_Display_Panel";
  388. superChat_Display_Panel.style.width = "100%";
  389. superChat_Display_Panel.style.border = "1px solid gray";
  390.  
  391. //包含和插入的容器
  392. var superChat_Display_Container = document.createElement("div");
  393. superChat_Display_Container.id = "superChat_Display_Container";
  394. superChat_Display_Container.style.width = "400px";
  395. superChat_Display_Container.style.height = "220px";
  396. superChat_Display_Container.style.border = "1px solid black";
  397. superChat_Display_Container.style.borderRadius = "10px";
  398. superChat_Display_Container.style.zIndex = "999999999";
  399. superChat_Display_Container.appendChild(superChat_Display_Panel_CtrlBar);
  400. superChat_Display_Container.appendChild(superChat_Display_Panel);
  401.  
  402. document.body.appendChild(superChat_Display_Container);
  403.  
  404. FloatingWindow.dragToMove(superChat_Display_Panel_CtrlBar, superChat_Display_Container);
  405.  
  406. this.superChat_Display_Panel = superChat_Display_Panel;
  407. this.superChat_Display_Container = superChat_Display_Container;
  408. this.checkbox_superchat_auto_scroll = checkbox_superchat_auto_scroll;
  409. }
  410. }
  411.  
  412. remove() {
  413. this.superChat_Display_Container.remove();
  414. }
  415.  
  416. add_new_superchat_item(new_superchatItem) {
  417. this.superChat_Display_Panel.appendChild(new_superchatItem);
  418. if (this.checkbox_superchat_auto_scroll.checked) {
  419. this.superChat_Display_Panel.scrollTo(0, 999999999);
  420. }
  421. }
  422.  
  423. static set_styles() {
  424. const styles_superchat_panel = `div#superChat_Display_Panel_CtrlBar {
  425. width: 100%;
  426. height: 20px;
  427. display: flex;
  428. flex-wrap: nowrap;
  429. justify-content: space-between;
  430. }
  431. div#superChat_Display_Panel {
  432. margin-bottom: 10px;
  433. overflow-y: scroll;
  434. min-height: 260px;
  435. height: calc(100% - 40px);
  436. }
  437. div#superChat_Display_Container {
  438. min-width: 400px;
  439. min-height: 300px;
  440. padding-bottom: 10px;
  441. resize: both;
  442. overflow-x: hidden;
  443. overflow-y: auto;
  444. position: absolute;
  445. top:150px;
  446. right: 0px;
  447. }`;
  448. GM_addStyle(styles_superchat_panel);
  449. }
  450.  
  451. static dragToMove(dragNode, moveNode) {//(被拖动的Part,被移动的整体)
  452. dragNode.onmousedown = function (event) {
  453. event = event || window.event
  454. //获取鼠标按下时的坐标
  455. let x = event.clientX
  456. let y = event.clientY
  457. //获取鼠标按下时距离div边框的距离
  458. let ol = x - moveNode.offsetLeft
  459. let ot = y - moveNode.offsetTop
  460. //使用document的原因:防止用户拖拽速度过快导致元素的onmousemove事件失效,所以把onmousemove事件绑定在document上就能避免失效
  461. document.onmousemove = function (event) {
  462. event = event || window.event
  463. moveNode.style.left = event.clientX - ol + 'px'
  464. moveNode.style.top = event.clientY - ot + 'px'
  465. }
  466. //取消onmousemove事件和onmouseup事件
  467. document.onmouseup = function () {
  468. document.onmousemove = 'null'
  469. document.onmouseup = 'null'
  470. }
  471. }
  472. };
  473.  
  474. }
  475.  
  476. const new_window_html =
  477. `
  478. <!DOCTYPE html>
  479. <html lang="en">
  480. <head>
  481. <meta charset="UTF-8">
  482. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  483. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  484. <title>Document</title>
  485. </head>
  486. <body>
  487. <style id="styles_superchat_items"></style>
  488. <style>
  489. :root {
  490. height: 100%;
  491. }
  492. body {
  493. margin: 0px;
  494. height: 100%;
  495. }
  496. div#ctrlbar {
  497. position: fixed;
  498. margin: 0px;
  499. padding: 0px;
  500. width: 100%;
  501. height: 5%;
  502. bottom: 0%;
  503. border: 1px solid;
  504. }
  505. div#superchat-item-area {
  506. height: 95%;
  507. overflow-y: scroll;
  508. }
  509. </style>
  510. <div id="superchat-item-area">
  511. </div>
  512. <div id="ctrlbar">
  513. <input type="checkbox" name="" id="check_auto_scroll">
  514. <label for="check_auto_scroll">SC自动滚动</label>
  515. &nbsp;
  516. &nbsp;
  517. &nbsp;
  518. &nbsp;
  519. <span id = 'ScCount'></span>
  520. </div>
  521. <script>
  522. //window.onload = window.onresize = () => {
  523. // var devicewidth = document.documentElement.clientWidth;
  524. // var scale = devicewidth / 1920;
  525. // document.body.style.zoom = scale;
  526. //};
  527.  
  528. var superchat_display_panel = document.querySelector("div#superchat-item-area");
  529. var check_auto_scroll = document.querySelector("input#check_auto_scroll");
  530. check_auto_scroll.onchange = () => {
  531. if (check_auto_scroll.checked) {
  532. superchat_display_panel.scrollTo(0, 99999999999999999);
  533. }
  534. }
  535. var add_new_superchat_item = (sc_item) => {
  536. superchat_display_panel.appendChild(sc_item);
  537. if (check_auto_scroll.checked) {
  538. superchat_display_panel.scrollTo(0, 99999999999999999);
  539. }
  540. }
  541. var set_styles = (stylesheet) => {
  542. document.querySelector("style#styles_superchat_items").innerHTML = stylesheet;
  543. }
  544. </script>
  545. </body>
  546. </html>
  547. `;
  548.  
  549. class NewWindow {
  550. constructor() {
  551. this.display_window = window.open("", 'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
  552. this.display_window.resizeTo(400, 600);
  553. this.display_window.document.write(new_window_html);
  554. this.set_styles();
  555. this.sc_count_element = this.display_window.document.querySelector('span#ScCount');
  556. }
  557.  
  558. add_new_superchat_item(sc_item) {
  559. this.display_window.add_new_superchat_item(sc_item);
  560. }
  561.  
  562. set_superchat_count(cnt) {
  563. this.sc_count_element.innerText = '共计' + cnt + '个SC';
  564. }
  565.  
  566. set_styles() {
  567. this.display_window.set_styles(styles_superchat_items);
  568. }
  569. remove() {
  570. if (!this.display_window.closed) {
  571. this.display_window.close();
  572. }
  573. }
  574. }
  575.  
  576. class SuperchatDisplayManager {
  577. constructor(ChatPanelContainer) {
  578. this.sc_monitor = new SuperChatMonitor();
  579. this.sc_monitor.Monitor(ChatPanelContainer);
  580. this.sc_display = null;
  581. }
  582.  
  583. DisplayInFloatingWindow() {
  584. if (this.sc_display) {
  585. if (this.sc_display.constructor.name == "FloatingWindow") {
  586. return;
  587. }
  588. else {
  589. this.sc_display.remove();
  590. }
  591. }
  592. this.sc_display = new FloatingWindow();
  593. this.sc_monitor.handle_new_superchat_data = (sc_data) => { this.sc_display.add_new_superchat_item(new SuperChatItem(sc_data).generateNode()); } //设置处理SC的回调函数
  594. this.sc_monitor.send_history_superchat();//恢复历史记录
  595. }
  596.  
  597. DisplayInNewWindow() {
  598. if (this.sc_display) {
  599. if (this.sc_display.constructor.name == "NewWindow") {
  600. return;
  601. }
  602. else {
  603. this.sc_display.remove();
  604. }
  605. }
  606. this.sc_display = new NewWindow();
  607. this.sc_monitor.handle_new_superchat_data = (sc_data) => { this.sc_display.add_new_superchat_item(new SuperChatItem(sc_data).generateNode()); this.sc_display.set_superchat_count(this.sc_monitor.SuperchatHistroy.length); }; //设置处理SC的回调函数
  608. this.sc_monitor.send_history_superchat();//恢复历史记录
  609. }
  610.  
  611. close() {
  612. if (!this.sc_display) {
  613. return;
  614. }
  615. else {
  616. this.sc_monitor.handle_new_superchat_data = null;
  617. this.sc_display.remove();
  618. }
  619. }
  620. }
  621.  
  622. SuperChatItem.set_styles();
  623. FloatingWindow.set_styles();
  624.  
  625. var ChatPanelContainer = document.querySelector("div#chat-history-list>div#chat-items");
  626. if (ChatPanelContainer) {
  627. var sc_manager = new SuperchatDisplayManager(ChatPanelContainer);
  628. GM_registerMenuCommand("以悬浮窗展示", () => { sc_manager.DisplayInFloatingWindow(); });
  629. GM_registerMenuCommand("以新窗口展示", () => { sc_manager.DisplayInNewWindow(); });
  630. GM_registerMenuCommand("关闭SC窗口", () => { sc_manager.close() });
  631. };
  632. })();

QingJ © 2025

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