进场和关注

记录直播间进场信息和直播间关注信息

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name 进场和关注
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 记录直播间进场信息和直播间关注信息
  6. // @author 太陽闇の力
  7. // @include /https?:\/\/live\.bilibili\.com\/(blanc\/)?\d+\??.*/
  8. // @require https://cdn.jsdelivr.net/gh/eric2788/bliveproxy@d66adfa34cbf41db3d313f49d0814e47cb3b6c4c/bliveproxy-unsafe.js
  9. // @grant unsafeWindow
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. //https?:\/\/live\.bilibili\.com\/(blanc\/)?23611306\??.*/
  15. //-----------UI区----------
  16. let isunfold = 0;
  17. let unfold = ["展开","收起"];
  18. // 总容器
  19. const container = window.document.createElement('div');
  20. container.style.cssText = 'width:600px;position:fixed;bottom:5px;left:5px;z-index:999;box-sizing:border-box;';
  21.  
  22. // 工具名称
  23. const topTool = window.document.createElement('div');
  24. topTool.innerHTML = '进场                      关注';
  25. topTool.style.cssText = 'text-align:center;line-height:20px;width:100%;color:rgb(210,143,166);font-size:14px;';
  26.  
  27. // 最小化按钮
  28. const collapseButton = window.document.createElement('button');
  29. collapseButton.innerText = unfold[isunfold];
  30. collapseButton.style.cssText = 'float:right;width:40px;height:20px;border:none;cursor:pointer;background-color:#1890ff;border-radius:1px;color:#ffffff;';
  31.  
  32. // 主窗口
  33. const mainWindow = window.document.createElement('div');
  34. mainWindow.style.cssText = 'display: flex;flex-wrap: wrap;justify-content:space-between;width:100%;background-color:rgba(220, 192, 221, .5);padding:10px;box-sizing:border-box;';
  35. if(isunfold==0){
  36. mainWindow.style.display = "none";
  37. }
  38.  
  39. const today = new Date();
  40. const todaytring = String(today.getFullYear())+'-'+String(today.getMonth()+1)+'-'+String(today.getDate())+'\n'
  41. // 进场
  42. const textArea = window.document.createElement('textarea');
  43. textArea.value = todaytring;
  44. textArea.style.cssText = 'width:45%;height:180px;resize:none;outline:none;background-color:rgba(255,255,255,.5);border-radius:2px';
  45. // 关注
  46. const textArea2 = window.document.createElement('textarea');
  47. textArea2.value = todaytring;
  48. textArea2.style.cssText = 'width:45%;height:180px;resize:none;outline:none;background-color:rgba(255,255,255,.5);border-radius:2px';
  49.  
  50. // 组装
  51. topTool.appendChild(collapseButton);
  52. container.appendChild(topTool);
  53. mainWindow.appendChild(textArea);
  54. mainWindow.appendChild(textArea2)
  55. container.appendChild(mainWindow);
  56. window.document.body.appendChild(container);
  57. // 显示逻辑控制
  58. collapseButton.addEventListener('click', () => {
  59. if (collapseButton.innerText === '收起') {
  60. mainWindow.style.display = 'none';
  61. collapseButton.innerText = '展开';
  62. return;
  63. }
  64. if (collapseButton.innerText === '展开') {
  65. mainWindow.style.display = 'flex';
  66. collapseButton.innerText = '收起';
  67. return;
  68. }
  69. }, false);
  70. function hdl(command){
  71. const data = command.data;
  72. const uid = data.uid;
  73. const uname = data.uname;
  74. const timestamp = data.timestamp*1000;
  75. const date = new Date(timestamp);
  76. const datestring = String(date.getHours())+":"+String(date.getMinutes());
  77. if(data.msg_type==1){
  78. textArea.value+=`【${uname}】${uid}|${datestring}\n`;
  79.  
  80. }else if(data.msg_type==2){
  81. textArea2.value+=`【${uname}】${uid}|${datestring}\n`;
  82. }
  83. }
  84. bliveproxy.addCommandHandler('INTERACT_WORD', hdl);
  85.  
  86.  
  87. })();