Custom bilishare

B站(bilibili)大会员共享

当前为 2021-04-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Custom bilishare
  3. // @namespace https://github.com/invobzvr
  4. // @version 0.1
  5. // @description B站(bilibili)大会员共享
  6. // @author invobzvr
  7. // @match *://www.bilibili.com/bangumi/play/*
  8. // @grant unsafeWindow
  9. // @grant GM_deleteValue
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @license GPL-3.0
  13. // @homepageURL https://github.com/invobzvr/tmjs.toys/tree/main/bilishare
  14. // @supportURL https://github.com/invobzvr/tmjs.toys/issues
  15. // ==/UserScript==
  16.  
  17. (function () {
  18. const ORI_XHRO = XMLHttpRequest.prototype.open;
  19.  
  20. XMLHttpRequest.prototype.open = function () {
  21. if (arguments[1].startsWith('https://api.bilibili.com/pgc/player/web/playurl') && access_key) {
  22. let url = new URL(arguments[1]);
  23. url.searchParams.append('access_key', access_key);
  24. arguments[1] = url;
  25. };
  26. return ORI_XHRO.apply(this, arguments);
  27. }
  28.  
  29. function proxyIV() {
  30. return new Promise(resolve => {
  31. let iid = setInterval(() => {
  32. if (typeof __INITIAL_STATE__.userState.vipInfo.isVip !== 'undefined') {
  33. clearInterval(iid);
  34. __INITIAL_STATE__.userState.vipInfo.__defineGetter__('isVip', () => true);
  35. resolve();
  36. }
  37. }, 100);
  38. });
  39. }
  40.  
  41. async function init() {
  42. let ep_id = location.pathname.match('\/play\/ep(\\d+)')[1];
  43. await proxyIV();
  44. bangumiCallNext(`${ep_id}.`);
  45. bangumiCallNext(ep_id);
  46. }
  47.  
  48. let access_key = GM_getValue('access_key');
  49. access_key && init();
  50. Object.defineProperty(unsafeWindow, 'access_key', {
  51. get: () => access_key,
  52. set: val => {
  53. if (val) {
  54. GM_setValue('access_key', val);
  55. let lak = !access_key;
  56. access_key = val;
  57. lak && init();
  58. console.log('[access_key] setted');
  59. } else {
  60. GM_deleteValue('access_key');
  61. console.log('[access_key] deleted');
  62. }
  63. }
  64. })
  65. })();

QingJ © 2025

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