Greasy Fork

Greasy Fork is available in English.

b-live-random-send-test

定时从设置的字幕中随机取出一条在B站直播间发送,需先登录B站账号

当前为 2023-07-11 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/447936/1218580/b-live-random-send-test.js

// ==UserScript==
// @author          Gamyou
// @version         1.5.7
// ==/UserScript==




window.onload=function(){const e={signText:"打卡",version:"2.4.2",updateFlag:!1,defaultKey:"danmu",configKey:"config",moduleId:"randomSendModule",moduleUrl:"http://greasyfork.icu/scripts/447937-bilibili-live-random-send/code/bilibili-live-random-send.js"},t=(t,l)=>{t||(t=e.defaultKey);let o=GM_getValue(t,l);return o||GM_getValue(e.defaultKey)},l=(t,l)=>{t||(t=e.defaultKey),l&&GM_setValue(t,l)},o=e=>{e&&GM_deleteValue(e)},a=e=>{e?GM_notification(e):console.warn("消息对象为空,无效通知")},n=t=>{let l=document.getElementById(e.moduleId);l||((l=document.createElement("script")).id=e.moduleId,l.type="text/javascript",l.text=t,document.head.appendChild(l))},r=()=>{let o=t(e.configKey,null);const a=(new Date).toLocaleDateString()+"/"+(new Date).getHours();if(o||(o={}),a!=o.lastUpdate){console.log("===> 进行脚本更新,最后更新时间:"+o.lastUpdate);const t=new AbortController,r=fetch(e.moduleUrl,{method:"GET",signal:t.signal,cache:"no-store"}),d=setTimeout(()=>t.abort(),4e4);r.then(e=>{if(e.ok)return e.text()}).then(t=>{t&&(d&&clearTimeout(d),n(t),o.script=t,o.lastUpdate=a,l(e.configKey,o),e.updateFlag=!0,console.log("===> 脚本更新完成"))}).catch(e=>console.error("===> 网络请求超时,或其它报错",e))}else e.updateFlag=!0};(()=>{let l=t(e.configKey,null);l&&l.script&&n(l.script),r()})();let d=setInterval(()=>{try{autoSendDanmuModuleLoaded?(clearInterval(d),d=null,setGmNotice(a),setGmGetValue(t),setGmSetValue(l),setGmDelValue(o),setParentData(e),runStart()):console.log("===> 组件初始化中···")}catch(e){console.warn("===> 组件初始化中···"),console.error(e)}},1e3),s=setInterval(()=>{e.updateFlag?(clearInterval(s),s=null):r()},6e4)}();