bilibili-live-random-send

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

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/447937/1268113/bilibili-live-random-send.js

  1. (function () {
  2. window.autoSendDanmuModuleLoaded = false;
  3. let pdata = {},
  4. moduleUrl = "https://gcore.jsdelivr.net/gh/gamyou/bilibili-live-random-send/prod/bilibili-live-random-send.js",
  5. parentUrl = 'https://gf.qytechs.cn/scripts/446725-b%E7%AB%99%E7%9B%B4%E6%92%AD%E9%97%B4%E5%AE%9A%E6%97%B6%E5%8F%91%E9%9A%8F%E6%9C%BA%E5%BC%B9%E5%B9%95/code/B%E7%AB%99%E7%9B%B4%E6%92%AD%E9%97%B4%E5%AE%9A%E6%97%B6%E5%8F%91%E9%9A%8F%E6%9C%BA%E5%BC%B9%E5%B9%95.user.js',
  6. gmNotice = obj => { alert('请更新油猴脚本'); window.location.href = parentUrl; },
  7. getGmValue = (key, defaultValue) => { return null; },
  8. setGmValue = (key, obj) => { console.warn('===> No implementation "setGmValue" method.'); },
  9. delGmValue = key => { console.warn('===> No implementation "delGmValue" method.'); };
  10. const setGmGetValue = callback => getGmValue = callback,
  11. setGmSetValue = callback => setGmValue = callback,
  12. setGmDelValue = callback => delGmValue = callback,
  13. setGmNotice = callback => gmNotice = callback,
  14. setParentData = obj => pdata = obj,
  15. createScript = (scriptText) => {
  16. let script = document.getElementById(pdata.moduleId);
  17. if (script) {
  18. script.remove();
  19. script = null;
  20. }
  21.  
  22. script = document.createElement('script');
  23. script.id = pdata.moduleId;
  24. script.type = 'text/javascript';
  25. script.text = scriptText;
  26. document.head.appendChild(script);
  27. },
  28. updateScript = () => {
  29. if (pdata.configKey) {
  30. let config = getGmValue(pdata.configKey, {});
  31. console.log('===> 进行脚本更新,最后更新时间:' + config.lastUpdate);
  32. const controller = new AbortController();
  33. const promise = fetch(moduleUrl, { method: 'GET', signal: controller.signal, cache: 'no-store' });
  34. const requestTimer = setTimeout(() => controller.abort(), 40e3);
  35. promise.then(response => {
  36. if (response.ok) {
  37. return response.text();
  38. }
  39. }).then(txt => {
  40. if (txt) {
  41. if (requestTimer) {clearTimeout(requestTimer);}
  42. createScript(txt);
  43. config.script = txt;
  44. config.lastUpdate = new Date().toLocaleDateString() + "/" + new Date().getHours();;
  45. setGmValue(pdata.configKey, config);
  46. console.log('===> 脚本更新完成,10秒后自动刷新页面');
  47. setTimeout(() => {
  48. window.location.reload();
  49. }, 10e3);
  50. }
  51. }).catch(error => console.error('===> 网络请求超时,或其它报错', error));
  52. }
  53. },
  54. runStart = () => {
  55. updateScript();
  56. if (!window.updateParentFlag) {
  57. window.updateParentFlag = true;
  58. window.location.href = parentUrl;
  59. }
  60. };
  61.  
  62. window.updateParentFlag = false;
  63. window.setParentData = setParentData;
  64. window.setGmGetValue = setGmGetValue;
  65. window.setGmSetValue = setGmSetValue;
  66. window.setGmDelValue = setGmDelValue;
  67. window.setGmNotice = setGmNotice;
  68. window.runStart = runStart;
  69. window.autoSendDanmuModuleLoaded = true;
  70. })();

QingJ © 2025

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