BiliLive Exp++

刷经验不用开直播页面哦

  1. // ==UserScript==
  2. // @name BiliLive Exp++
  3. // @namespace https://std4453.github.io/
  4. // @locale zh-CN
  5. // @version 1.0
  6. // @description 刷经验不用开直播页面哦
  7. // @author std4453
  8. // @match http*://link.bilibili.com/p/center/*
  9. // @grant GM_log
  10. // @connect api.live.bilibili.com
  11. // @iconURL http://live.bilibili.com/favicon.ico
  12. // @icon64URL http://live.bilibili.com/favicon.ico
  13. // @run-at document-idle
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. var DEBUG = false;
  20.  
  21. var userOnlineHeart = "http://api.live.bilibili.com/User/userOnlineHeart";
  22. var heartBeatB = "http://api.live.bilibili.com/feed/v1/feed/heartBeat?_=";
  23. var interval = 30000;
  24.  
  25. var fetch = (url, method) => {
  26. return new Promise((resolve, reject) => {
  27. var xhr = new XMLHttpRequest();
  28. xhr.open(method, url);
  29. xhr.withCredentials = true;
  30. xhr.onload = e => {
  31. if (xhr.readyState == 4) {
  32. if (xhr.status == 200) resolve(xhr.responseText, url);
  33. else eject(new Error(xhr.statusText));
  34. }
  35. };
  36. xhr.onerror = reject;
  37. xhr.send(null);
  38. });
  39. };
  40.  
  41. var send = (url, method) => {
  42. fetch(url, method).then(text => {
  43. if (DEBUG) console.log("Loaded " + url + ", get" + text);
  44. }, err => {
  45. if (DEBUG) {
  46. console.error("Unable to load " + url + ", got error:");
  47. console.error(err);
  48. }
  49. });
  50. };
  51.  
  52. var sendHeartBeat = () => {
  53. if (DEBUG) GM_log("Sending heartbeat...");
  54. send(userOnlineHeart, "POST");
  55. send(heartBeatB + ((new Date()).getTime()), "GET");
  56. if (DEBUG) GM_log("Heartbeat sent.");
  57. };
  58.  
  59. setInterval(sendHeartBeat, interval);
  60. GM_log("BiliLive Exp++ initialized!");
  61. })();