bilibili网页端每天自动打开一次直播间

每天自动打开一次直播间(配合直播挂机助手使用)

  1. // ==UserScript==
  2. // @name bilibili网页端每天自动打开一次直播间
  3. // @namespace indefined
  4. // @version 0.0.3
  5. // @description 每天自动打开一次直播间(配合直播挂机助手使用)
  6. // @author indefined
  7. // @match *://www.bilibili.com/*
  8. // @include https://www.mcbbs.net/template/mcbbs/image/special_photo_bg.png?*
  9. // @license MIT
  10. // @connect app.bilibili.com
  11. // @connect api.bilibili.com
  12. // @connect passport.bilibili.com
  13. // @connect link.acg.tv
  14. // @connect www.mcbbs.net
  15. // @grant GM_xmlhttpRequest
  16. // @grant GM_getValue
  17. // @grant GM_setValue
  18. // @grant GM_deleteValue
  19. // @run-at document-idle
  20. // ==/UserScript==
  21.  
  22. (function() {
  23. 'use strict';
  24. //这里可以填自己想打开的直播间url
  25. var liveUrl = 'http://live.bilibili.com/13602541';
  26. //根据name获取Cookie
  27. function getCookie(name) {
  28. // 拆分 cookie 字符串
  29. var cookieArr = document.cookie.split(";");
  30. // 循环遍历数组元素
  31. for(var i = 0; i < cookieArr.length; i++) {
  32. var cookiePair = cookieArr[i].split("=");
  33. /* 删除 cookie 名称开头的空白并将其与给定字符串进行比较 */
  34. if(name == cookiePair[0].trim()) {
  35. // 解码cookie值并返回
  36. return decodeURIComponent(cookiePair[1]);
  37. }
  38. }
  39. // 如果未找到,则返回null
  40. return null;
  41. }
  42. //设置Cookie
  43. //这是有设定过期时间的使用示例:
  44. //s20是代表20秒
  45. //h是指小时,如12小时则是:h12
  46. //d是天数,30天则:d30
  47. function setCookie(name,value,time)
  48. {
  49. var strsec = getsec(time);
  50. var exp = new Date();
  51. exp.setTime(exp.getTime() + strsec*1);
  52. document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
  53. }
  54. function getsec(str)
  55. {
  56. var str1=str.substring(1,str.length)*1;
  57. var str2=str.substring(0,1);
  58. if (str2=="s")
  59. {
  60. return str1*1000;
  61. }
  62. else if (str2=="h")
  63. {
  64. return str1*60*60*1000;
  65. }
  66. else if (str2=="d")
  67. {
  68. return str1*24*60*60*1000;
  69. }
  70. }
  71. Date.prototype.Format = function (fmt) {
  72. var o = {
  73. "M+": this.getMonth() + 1, //月份
  74. "d+": this.getDate(), //日
  75. "H+": this.getHours(), //小时
  76. "m+": this.getMinutes(), //分
  77. "s+": this.getSeconds(), //秒
  78. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  79. "S": this.getMilliseconds() //毫秒
  80. };
  81. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  82. for (var k in o)
  83. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  84. return fmt;
  85. }
  86. var today = new Date().Format("yyyy-MM-dd");
  87. if(!getCookie('openLive') || getCookie('openLive') != today){
  88. window.open(liveUrl);
  89. setCookie('openLive',today,'d7');
  90. }
  91.  
  92. })();

QingJ © 2025

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