Greasy Fork镜像 支持简体中文。

bilibili视频下载

支持Web、RPC、Blob、Aria等下载方式;支持下载flv、dash、mp4视频格式;支持下载港区番剧;支持下载字幕弹幕;支持换源播放等功能

  1. // ==UserScript==
  2. // @name bilibili视频下载
  3. // @namespace https://github.com/injahow
  4. // @version 2.6.3
  5. // @description 支持Web、RPC、Blob、Aria等下载方式;支持下载flv、dash、mp4视频格式;支持下载港区番剧;支持下载字幕弹幕;支持换源播放等功能
  6. // @author injahow
  7. // @copyright 2021, injahow (https://github.com/injahow)
  8. // @license MIT
  9. // @source https://github.com/injahow/user.js
  10. // @supportURL https://github.com/injahow/user.js/issues
  11. // @match *://www.bilibili.com/video/av*
  12. // @match *://www.bilibili.com/video/BV*
  13. // @match *://www.bilibili.com/list/*
  14. // @match *://www.bilibili.com/festival/*
  15. // @match *://www.bilibili.com/bangumi/play/ep*
  16. // @match *://www.bilibili.com/bangumi/play/ss*
  17. // @match *://www.bilibili.com/cheese/play/ep*
  18. // @match *://www.bilibili.com/cheese/play/ss*
  19. // @require https://static.hdslb.com/js/jquery.min.js
  20. // @icon https://static.hdslb.com/images/favicon.ico
  21. // @compatible chrome
  22. // @compatible firefox
  23. // @grant none
  24. // ==/UserScript==
  25. /* globals $ waitForKeyElements */
  26. // @[ You can find all source codes in GitHub repo ]
  27. !function() {
  28. "use strict";
  29. function _defineProperties(target, props) {
  30. for (var i = 0; i < props.length; i++) {
  31. var descriptor = props[i];
  32. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0,
  33. "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
  34. }
  35. }
  36. var user = new (function() {
  37. function User() {
  38. !function _classCallCheck(instance, Constructor) {
  39. if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
  40. }(this, User), this.is_login = !1, this.vip_status = 0, this.mid = "", this.uname = "",
  41. this.has_init = !1, this.lazyInit();
  42. }
  43. return function _createClass(Constructor, protoProps, staticProps) {
  44. return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps),
  45. Object.defineProperty(Constructor, "prototype", {
  46. writable: !1
  47. }), Constructor;
  48. }(User, [ {
  49. key: "needReplace",
  50. value: function needReplace() {
  51. return !this.is_login || !this.vip_status && video.base().needVip();
  52. }
  53. }, {
  54. key: "isVIP",
  55. value: function isVIP() {
  56. return 1 === this.vip_status;
  57. }
  58. }, {
  59. key: "lazyInit",
  60. value: function lazyInit(last_init) {
  61. this.has_init || (window.__BILI_USER_INFO__ ? (this.is_login = window.__BILI_USER_INFO__.isLogin,
  62. this.vip_status = window.__BILI_USER_INFO__.vipStatus, this.mid = window.__BILI_USER_INFO__.mid || "",
  63. this.uname = window.__BILI_USER_INFO__.uname || "") : window.__BiliUser__ && (this.is_login = window.__BiliUser__.isLogin,
  64. window.__BiliUser__.cache ? (this.vip_status = window.__BiliUser__.cache.data.vipStatus,
  65. this.mid = window.__BiliUser__.cache.data.mid || "", this.uname = window.__BiliUser__.cache.data.uname || "") : (this.vip_status = 0,
  66. this.mid = "", this.uname = "")), this.has_init = last_init);
  67. }
  68. } ]), User;
  69. }());
  70. function _slicedToArray(arr, i) {
  71. return function _arrayWithHoles(arr) {
  72. if (Array.isArray(arr)) return arr;
  73. }(arr) || function _iterableToArrayLimit(arr, i) {
  74. var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
  75. if (null == _i) return;
  76. var _s, _e, _arr = [], _n = !0, _d = !1;
  77. try {
  78. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0) ;
  79. } catch (err) {
  80. _d = !0, _e = err;
  81. } finally {
  82. try {
  83. _n || null == _i.return || _i.return();
  84. } finally {
  85. if (_d) throw _e;
  86. }
  87. }
  88. return _arr;
  89. }(arr, i) || function _unsupportedIterableToArray(o, minLen) {
  90. if (!o) return;
  91. if ("string" == typeof o) return _arrayLikeToArray(o, minLen);
  92. var n = Object.prototype.toString.call(o).slice(8, -1);
  93. "Object" === n && o.constructor && (n = o.constructor.name);
  94. if ("Map" === n || "Set" === n) return Array.from(o);
  95. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  96. }(arr, i) || function _nonIterableRest() {
  97. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  98. }();
  99. }
  100. function _arrayLikeToArray(arr, len) {
  101. (null == len || len > arr.length) && (len = arr.length);
  102. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  103. return arr2;
  104. }
  105. function cache_classCallCheck(instance, Constructor) {
  106. if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
  107. }
  108. function cache_defineProperties(target, props) {
  109. for (var i = 0; i < props.length; i++) {
  110. var descriptor = props[i];
  111. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0,
  112. "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
  113. }
  114. }
  115. function cache_createClass(Constructor, protoProps, staticProps) {
  116. return protoProps && cache_defineProperties(Constructor.prototype, protoProps),
  117. staticProps && cache_defineProperties(Constructor, staticProps), Object.defineProperty(Constructor, "prototype", {
  118. writable: !1
  119. }), Constructor;
  120. }
  121. var CacheFactory = function() {
  122. function CacheFactory() {
  123. cache_classCallCheck(this, CacheFactory);
  124. }
  125. return cache_createClass(CacheFactory, null, [ {
  126. key: "get",
  127. value: function get() {
  128. var name = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "default", cache = CacheFactory.map[name];
  129. return cache instanceof Cache || (cache = new Cache, CacheFactory.map[name] = cache),
  130. cache;
  131. }
  132. }, {
  133. key: "setValue",
  134. value: function setValue() {
  135. var key = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "", value = arguments.length > 1 ? arguments[1] : void 0, _key$split = key.split(".", 2), _key$split2 = _slicedToArray(_key$split, 2), cacheName = _key$split2[0], cacheKey = _key$split2[1];
  136. if (cacheName && cacheKey) {
  137. var cache = CacheFactory.get(cacheName);
  138. cache instanceof Cache && cache.set(cacheKey, value);
  139. }
  140. }
  141. }, {
  142. key: "clear",
  143. value: function clear(name) {
  144. name ? CacheFactory.get(name).clear() : CacheFactory.map = {};
  145. }
  146. } ]), CacheFactory;
  147. }();
  148. !function _defineProperty(obj, key, value) {
  149. return key in obj ? Object.defineProperty(obj, key, {
  150. value: value,
  151. enumerable: !0,
  152. configurable: !0,
  153. writable: !0
  154. }) : obj[key] = value, obj;
  155. }(CacheFactory, "map", {});
  156. var Cache = function() {
  157. function Cache() {
  158. cache_classCallCheck(this, Cache), this.data = {};
  159. }
  160. return cache_createClass(Cache, [ {
  161. key: "get",
  162. value: function get() {
  163. var key = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "";
  164. return this.data[key];
  165. }
  166. }, {
  167. key: "set",
  168. value: function set() {
  169. var key = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "", value = arguments.length > 1 ? arguments[1] : void 0;
  170. this.data[key] = value;
  171. }
  172. }, {
  173. key: "clear",
  174. value: function clear() {
  175. this.data = {};
  176. }
  177. } ]), Cache;
  178. }(), cache = CacheFactory;
  179. var scroll_scroll = {
  180. show: function show_scroll() {
  181. $("div#bp_config").is(":hidden") && $("div#message_box").is(":hidden") && $("body").css("overflow", "auto");
  182. },
  183. hide: function hide_scroll() {
  184. $("body").css("overflow", "hidden");
  185. }
  186. }, message = '<div class="message-bg"></div> <div id="message_box"> <div class="message-box-mark"></div> <div class="message-box-bg"> <span style="font-size:20px"><b>提示:</b></span> <div id="message_box_context" style="margin:2% 0">...</div><br/><br/> <div class="message-box-btn"> <button name="affirm">确定</button> <button name="cancel">取消</button> </div> </div> </div> <style>.message-bg{position:fixed;float:right;right:0;top:2%;z-index:30000}.message{margin-bottom:15px;padding:2% 2%;width:300px;display:flex;margin-top:-70px;opacity:0}.message-success{background-color:#dfd;border-left:6px solid #4caf50}.message-error{background-color:#fdd;border-left:6px solid #f44336}.message-info{background-color:#e7f3fe;border-left:6px solid #0c86de}.message-warning{background-color:#ffc;border-left:6px solid #ffeb3b}.message-context{font-size:21px;word-wrap:break-word;word-break:break-all}.message-context p{margin:0}#message_box{opacity:0;display:none;position:fixed;inset:0px;top:0;left:0;width:100%;height:100%;z-index:20000}.message-box-bg{position:absolute;background:#fff;border-radius:10px;padding:20px;top:50%;left:50%;transform:translate(-50%,-50%);width:500px;z-index:20001}.message-box-mark{width:100%;height:100%;position:fixed;top:0;left:0;background:rgba(0,0,0,.5);z-index:20000}.message-box-btn{text-align:right}.message-box-btn button{margin:0 5px;width:120px;height:40px;border-width:0;border-radius:3px;background:#1e90ff;cursor:pointer;outline:0;color:#fff;font-size:17px}.message-box-btn button:hover{background:#59f}</style> ';
  187. function messageBox(ctx, type) {
  188. "confirm" === type ? $('.message-box-btn button[name="cancel"]').show() : "alert" === type && $('.message-box-btn button[name="cancel"]').hide(),
  189. ctx.html ? $("#message_box_context").html('<div style="font-size:18px">'.concat(ctx.html, "</div>")) : $("#message_box_context").html('<div style="font-size:18px">╰( ̄▽ ̄)╮</div>'),
  190. scroll_scroll.hide(), $("#message_box").show(), $("#message_box").animate({
  191. opacity: "1"
  192. }, 300);
  193. var option = {
  194. affirm: function affirm() {
  195. $("#message_box").hide(), $("#message_box").css("opacity", 0), scroll_scroll.show(),
  196. ctx.callback && ctx.callback.affirm && ctx.callback.affirm();
  197. },
  198. cancel: function cancel() {
  199. $("#message_box").hide(), $("#message_box").css("opacity", 0), scroll_scroll.show(),
  200. ctx.callback && ctx.callback.cancel && ctx.callback.cancel();
  201. }
  202. };
  203. return $('.message-box-btn button[name="affirm"]')[0].onclick = option.affirm, $('.message-box-btn button[name="cancel"]')[0].onclick = option.cancel,
  204. option;
  205. }
  206. var id = 0;
  207. function message_message(html, type) {
  208. (function messageEnQueue(message, id) {
  209. $(".message-bg").append(message), $("#message_".concat(id)).animate({
  210. "margin-top": "+=70px",
  211. opacity: "1"
  212. }, 300);
  213. })('<div id="message_'.concat(id += 1, '" class="message message-').concat(type, '"><div class="message-context"><p><strong>').concat(type, ":</strong></p><p>").concat(html, "</p></div></div>"), id),
  214. function messageDeQueue(id) {
  215. var time = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 3;
  216. setTimeout((function() {
  217. var e = "div#message_".concat(id);
  218. $(e).animate({
  219. "margin-top": "-=70px",
  220. opacity: "0"
  221. }, 300, (function() {
  222. $(e).remove();
  223. }));
  224. }), 1e3 * time);
  225. }(id, 3);
  226. }
  227. var message_Message_success = function success(html) {
  228. return message_message(html, "success");
  229. }, message_Message_warning = function warning(html) {
  230. return message_message(html, "warning");
  231. }, message_Message_error = function error(html) {
  232. return message_message(html, "error");
  233. }, message_Message_info = function info(html) {
  234. return message_message(html, "info");
  235. }, message_Message_miaow = function miaow() {
  236. return message_message("(^・ω・^)~喵喵喵~", "info");
  237. }, MessageBox_alert = function alert(html, affirm) {
  238. return messageBox({
  239. html: html,
  240. callback: {
  241. affirm: affirm
  242. }
  243. }, "alert");
  244. }, MessageBox_confirm = function confirm(html, affirm, cancel) {
  245. return messageBox({
  246. html: html,
  247. callback: {
  248. affirm: affirm,
  249. cancel: cancel
  250. }
  251. }, "confirm");
  252. };
  253. function ajax(obj) {
  254. return new Promise((function(resolve, reject) {
  255. obj.success = function(res) {
  256. res && res.code && message_Message_warning("".concat(res.message || "CODE:".concat(res.code))),
  257. resolve(res);
  258. }, obj.error = function(err) {
  259. message_Message_error("网络异常"), reject(err);
  260. }, $.ajax(obj);
  261. }));
  262. }
  263. function _ajax(obj) {
  264. return new Promise((function(resolve, reject) {
  265. var _success = obj.success;
  266. obj.success = function(res) {
  267. resolve(_success ? _success(res) : res);
  268. };
  269. var _error = obj.error;
  270. obj.error = function(res) {
  271. reject(_error ? _error(res) : res);
  272. }, $.ajax(obj);
  273. }));
  274. }
  275. function _typeof(obj) {
  276. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
  277. return typeof obj;
  278. } : function(obj) {
  279. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  280. }, _typeof(obj);
  281. }
  282. function _toConsumableArray(arr) {
  283. return function _arrayWithoutHoles(arr) {
  284. if (Array.isArray(arr)) return video_base_arrayLikeToArray(arr);
  285. }(arr) || function _iterableToArray(iter) {
  286. if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
  287. }(arr) || video_base_unsupportedIterableToArray(arr) || function _nonIterableSpread() {
  288. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  289. }();
  290. }
  291. function _createForOfIteratorHelper(o, allowArrayLike) {
  292. var it = "undefined" != typeof Symbol && o[Symbol.iterator] || o["@@iterator"];
  293. if (!it) {
  294. if (Array.isArray(o) || (it = video_base_unsupportedIterableToArray(o)) || allowArrayLike && o && "number" == typeof o.length) {
  295. it && (o = it);
  296. var i = 0, F = function F() {};
  297. return {
  298. s: F,
  299. n: function n() {
  300. return i >= o.length ? {
  301. done: !0
  302. } : {
  303. done: !1,
  304. value: o[i++]
  305. };
  306. },
  307. e: function e(_e) {
  308. throw _e;
  309. },
  310. f: F
  311. };
  312. }
  313. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  314. }
  315. var err, normalCompletion = !0, didErr = !1;
  316. return {
  317. s: function s() {
  318. it = it.call(o);
  319. },
  320. n: function n() {
  321. var step = it.next();
  322. return normalCompletion = step.done, step;
  323. },
  324. e: function e(_e2) {
  325. didErr = !0, err = _e2;
  326. },
  327. f: function f() {
  328. try {
  329. normalCompletion || null == it.return || it.return();
  330. } finally {
  331. if (didErr) throw err;
  332. }
  333. }
  334. };
  335. }
  336. function video_base_unsupportedIterableToArray(o, minLen) {
  337. if (o) {
  338. if ("string" == typeof o) return video_base_arrayLikeToArray(o, minLen);
  339. var n = Object.prototype.toString.call(o).slice(8, -1);
  340. return "Object" === n && o.constructor && (n = o.constructor.name), "Map" === n || "Set" === n ? Array.from(o) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? video_base_arrayLikeToArray(o, minLen) : void 0;
  341. }
  342. }
  343. function video_base_arrayLikeToArray(arr, len) {
  344. (null == len || len > arr.length) && (len = arr.length);
  345. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  346. return arr2;
  347. }
  348. function _inherits(subClass, superClass) {
  349. if ("function" != typeof superClass && null !== superClass) throw new TypeError("Super expression must either be null or a function");
  350. subClass.prototype = Object.create(superClass && superClass.prototype, {
  351. constructor: {
  352. value: subClass,
  353. writable: !0,
  354. configurable: !0
  355. }
  356. }), Object.defineProperty(subClass, "prototype", {
  357. writable: !1
  358. }), superClass && _setPrototypeOf(subClass, superClass);
  359. }
  360. function _setPrototypeOf(o, p) {
  361. return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
  362. return o.__proto__ = p, o;
  363. }, _setPrototypeOf(o, p);
  364. }
  365. function _createSuper(Derived) {
  366. var hasNativeReflectConstruct = function _isNativeReflectConstruct() {
  367. if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
  368. if (Reflect.construct.sham) return !1;
  369. if ("function" == typeof Proxy) return !0;
  370. try {
  371. return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {}))),
  372. !0;
  373. } catch (e) {
  374. return !1;
  375. }
  376. }();
  377. return function _createSuperInternal() {
  378. var result, Super = _getPrototypeOf(Derived);
  379. if (hasNativeReflectConstruct) {
  380. var NewTarget = _getPrototypeOf(this).constructor;
  381. result = Reflect.construct(Super, arguments, NewTarget);
  382. } else result = Super.apply(this, arguments);
  383. return _possibleConstructorReturn(this, result);
  384. };
  385. }
  386. function _possibleConstructorReturn(self, call) {
  387. if (call && ("object" === _typeof(call) || "function" == typeof call)) return call;
  388. if (void 0 !== call) throw new TypeError("Derived constructors may only return object or undefined");
  389. return _assertThisInitialized(self);
  390. }
  391. function _assertThisInitialized(self) {
  392. if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  393. return self;
  394. }
  395. function set(target, property, value, receiver) {
  396. return set = "undefined" != typeof Reflect && Reflect.set ? Reflect.set : function set(target, property, value, receiver) {
  397. var desc, base = function _superPropBase(object, property) {
  398. for (;!Object.prototype.hasOwnProperty.call(object, property) && null !== (object = _getPrototypeOf(object)); ) ;
  399. return object;
  400. }(target, property);
  401. if (base) {
  402. if ((desc = Object.getOwnPropertyDescriptor(base, property)).set) return desc.set.call(receiver, value),
  403. !0;
  404. if (!desc.writable) return !1;
  405. }
  406. if (desc = Object.getOwnPropertyDescriptor(receiver, property)) {
  407. if (!desc.writable) return !1;
  408. desc.value = value, Object.defineProperty(receiver, property, desc);
  409. } else video_base_defineProperty(receiver, property, value);
  410. return !0;
  411. }, set(target, property, value, receiver);
  412. }
  413. function _getPrototypeOf(o) {
  414. return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
  415. return o.__proto__ || Object.getPrototypeOf(o);
  416. }, _getPrototypeOf(o);
  417. }
  418. function ownKeys(object, enumerableOnly) {
  419. var keys = Object.keys(object);
  420. if (Object.getOwnPropertySymbols) {
  421. var symbols = Object.getOwnPropertySymbols(object);
  422. enumerableOnly && (symbols = symbols.filter((function(sym) {
  423. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  424. }))), keys.push.apply(keys, symbols);
  425. }
  426. return keys;
  427. }
  428. function _objectSpread(target) {
  429. for (var i = 1; i < arguments.length; i++) {
  430. var source = null != arguments[i] ? arguments[i] : {};
  431. i % 2 ? ownKeys(Object(source), !0).forEach((function(key) {
  432. video_base_defineProperty(target, key, source[key]);
  433. })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach((function(key) {
  434. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  435. }));
  436. }
  437. return target;
  438. }
  439. function video_base_defineProperty(obj, key, value) {
  440. return key in obj ? Object.defineProperty(obj, key, {
  441. value: value,
  442. enumerable: !0,
  443. configurable: !0,
  444. writable: !0
  445. }) : obj[key] = value, obj;
  446. }
  447. function video_base_classCallCheck(instance, Constructor) {
  448. if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
  449. }
  450. function video_base_defineProperties(target, props) {
  451. for (var i = 0; i < props.length; i++) {
  452. var descriptor = props[i];
  453. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0,
  454. "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
  455. }
  456. }
  457. function video_base_createClass(Constructor, protoProps, staticProps) {
  458. return protoProps && video_base_defineProperties(Constructor.prototype, protoProps),
  459. staticProps && video_base_defineProperties(Constructor, staticProps), Object.defineProperty(Constructor, "prototype", {
  460. writable: !1
  461. }), Constructor;
  462. }
  463. var clazzMap = {}, VideoBase = function() {
  464. function VideoBase(video_type, main_title, state) {
  465. video_base_classCallCheck(this, VideoBase), this.constructor.name in clazzMap || (clazzMap[this.constructor.name] = this.constructor),
  466. this.video_type = video_type || "video", this.main_title = main_title || "", this.state = state,
  467. this.page = state && parseInt(state.p) || 1;
  468. }
  469. return video_base_createClass(VideoBase, [ {
  470. key: "getVideo",
  471. value: function getVideo(p) {
  472. var _this = this, prop = {
  473. p: p,
  474. id: 0,
  475. title: "",
  476. filename: "",
  477. aid: 0,
  478. bvid: "",
  479. cid: 0,
  480. epid: 0,
  481. needVip: !1,
  482. vipNeedPay: !1,
  483. isLimited: !1
  484. }, clazz = clazzMap[this.constructor.name];
  485. return prop = _objectSpread(_objectSpread({}, prop), Object.fromEntries(Object.getOwnPropertyNames(VideoBase.prototype).filter((function(key) {
  486. return key in prop;
  487. })).map((function(key) {
  488. return [ key, clazz.prototype[key].call(_this, p) ];
  489. }))));
  490. }
  491. }, {
  492. key: "type",
  493. value: function type() {
  494. return this.video_type;
  495. }
  496. }, {
  497. key: "getName",
  498. value: function getName() {
  499. return this.main_title || "";
  500. }
  501. }, {
  502. key: "getFilename",
  503. value: function getFilename() {
  504. return this.getName().replace(/[\/\\:*?"<>|]+/g, "");
  505. }
  506. }, {
  507. key: "p",
  508. value: function p(_p) {
  509. return (_p = parseInt(_p) || 0) > 0 && _p <= this.total() ? _p : this.page;
  510. }
  511. }, {
  512. key: "id",
  513. value: function id(p) {
  514. return this.p(p) - 1;
  515. }
  516. }, {
  517. key: "total",
  518. value: function total() {
  519. return 0;
  520. }
  521. }, {
  522. key: "title",
  523. value: function title() {
  524. return "";
  525. }
  526. }, {
  527. key: "filename",
  528. value: function filename() {
  529. return "";
  530. }
  531. }, {
  532. key: "aid",
  533. value: function aid() {
  534. return 0;
  535. }
  536. }, {
  537. key: "bvid",
  538. value: function bvid() {
  539. return "";
  540. }
  541. }, {
  542. key: "cid",
  543. value: function cid() {
  544. return 0;
  545. }
  546. }, {
  547. key: "epid",
  548. value: function epid() {
  549. return "";
  550. }
  551. }, {
  552. key: "needVip",
  553. value: function needVip() {
  554. return !1;
  555. }
  556. }, {
  557. key: "vipNeedPay",
  558. value: function vipNeedPay() {
  559. return !1;
  560. }
  561. }, {
  562. key: "isLimited",
  563. value: function isLimited() {
  564. return !1;
  565. }
  566. } ]), VideoBase;
  567. }(), Video = function(_VideoBase) {
  568. _inherits(Video, _VideoBase);
  569. var _super = _createSuper(Video);
  570. function Video(main_title, state) {
  571. var _state$sectionsInfo, _thisSuper, _this2;
  572. video_base_classCallCheck(this, Video), (_this2 = _super.call(this, "video", main_title, state)).video_list = [];
  573. var sections = state.sections || (null === (_state$sectionsInfo = state.sectionsInfo) || void 0 === _state$sectionsInfo ? void 0 : _state$sectionsInfo.sections) || [];
  574. if (!sections.length) return _possibleConstructorReturn(_this2);
  575. var _step, new_page = 0, i = 1, _iterator = _createForOfIteratorHelper(sections);
  576. try {
  577. for (_iterator.s(); !(_step = _iterator.n()).done; ) {
  578. var _step2, _iterator2 = _createForOfIteratorHelper(_step.value.episodes || []);
  579. try {
  580. for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
  581. var ep = _step2.value;
  582. _this2.video_list.push(ep), state.videoData.bvid == ep.bvid && (new_page = i), i++;
  583. }
  584. } catch (err) {
  585. _iterator2.e(err);
  586. } finally {
  587. _iterator2.f();
  588. }
  589. }
  590. } catch (err) {
  591. _iterator.e(err);
  592. } finally {
  593. _iterator.f();
  594. }
  595. return new_page < 1 ? _this2.video_list = [] : function _set(target, property, value, receiver, isStrict) {
  596. if (!set(target, property, value, receiver || target) && isStrict) throw new Error("failed to set property");
  597. return value;
  598. }((_thisSuper = _assertThisInitialized(_this2), _getPrototypeOf(Video.prototype)), "page", new_page, _thisSuper, !0),
  599. _this2;
  600. }
  601. return video_base_createClass(Video, [ {
  602. key: "total",
  603. value: function total() {
  604. return this.video_list.length > 0 ? this.video_list.length : this.state.videoData.pages.length;
  605. }
  606. }, {
  607. key: "title",
  608. value: function title(p) {
  609. var id = this.id(p);
  610. return this.video_list.length > 0 ? this.video_list[id].title : this.state.videoData.pages[id].part;
  611. }
  612. }, {
  613. key: "filename",
  614. value: function filename(p) {
  615. if (this.video_list.length > 0) return this.title(p).replace(/[\/\\:*?"<>|]+/g, "");
  616. var id = this.id(p);
  617. return (this.main_title + (this.total() > 1 ? " P".concat(id + 1, " ").concat(this.state.videoData.pages[id].part || "") : "")).replace(/[\/\\:*?"<>|]+/g, "");
  618. }
  619. }, {
  620. key: "aid",
  621. value: function aid(p) {
  622. return this.video_list.length > 0 ? this.video_list[this.id(p)].aid : this.state.videoData.aid;
  623. }
  624. }, {
  625. key: "bvid",
  626. value: function bvid(p) {
  627. return this.video_list.length > 0 ? this.video_list[this.id(p)].bvid : this.state.videoData.bvid;
  628. }
  629. }, {
  630. key: "cid",
  631. value: function cid(p) {
  632. return this.video_list.length > 0 ? this.video_list[this.id(p)].cid : this.state.videoData.pages[this.id(p)].cid;
  633. }
  634. } ]), Video;
  635. }(VideoBase), VideoList = function(_VideoBase2) {
  636. _inherits(VideoList, _VideoBase2);
  637. var _super2 = _createSuper(VideoList);
  638. function VideoList(main_title, state) {
  639. var _this3;
  640. video_base_classCallCheck(this, VideoList), (_this3 = _super2.call(this, "video", main_title, state)).video = new Video(state.videoData.title, state);
  641. var _step3, video_list = [], _iterator3 = _createForOfIteratorHelper(state.resourceList || []);
  642. try {
  643. for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) for (var video = _step3.value, i = 0, length = video.pages && video.pages.length || 0; i < length; ) {
  644. var _video = Object.assign({}, video);
  645. _video.title = video.title + (length > 1 ? " P".concat(i + 1, " ").concat(video.pages[i].title) : ""),
  646. _video.cid = video.pages[i].cid || 0, video_list.push(_video), i++;
  647. }
  648. } catch (err) {
  649. _iterator3.e(err);
  650. } finally {
  651. _iterator3.f();
  652. }
  653. return _this3.video_list = video_list, _this3;
  654. }
  655. return video_base_createClass(VideoList, [ {
  656. key: "total",
  657. value: function total() {
  658. return this.video_list.length;
  659. }
  660. }, {
  661. key: "title",
  662. value: function title(p) {
  663. return p ? this.video_list[this.id(p)].title : this.video.title();
  664. }
  665. }, {
  666. key: "filename",
  667. value: function filename(p) {
  668. if (!p) return this.video.filename();
  669. var id = this.id(p);
  670. return (this.main_title + (this.total() > 1 ? " P".concat(id + 1, " ").concat(this.video_list[id].title) : "")).replace(/[\/\\:*?"<>|]+/g, "");
  671. }
  672. }, {
  673. key: "aid",
  674. value: function aid(p) {
  675. return p ? this.video_list[this.id(p)].aid : this.video.aid();
  676. }
  677. }, {
  678. key: "bvid",
  679. value: function bvid(p) {
  680. return p ? this.video_list[this.id(p)].bvid : this.video.bvid();
  681. }
  682. }, {
  683. key: "cid",
  684. value: function cid(p) {
  685. return p ? this.video_list[this.id(p)].cid : this.video.cid();
  686. }
  687. } ]), VideoList;
  688. }(VideoBase), VideoFestival = function(_VideoBase3) {
  689. _inherits(VideoFestival, _VideoBase3);
  690. var _super3 = _createSuper(VideoFestival);
  691. function VideoFestival(main_title, state) {
  692. var _this4;
  693. return video_base_classCallCheck(this, VideoFestival), (_this4 = _super3.call(this, "video", main_title, state)).video_info = state.videoInfo,
  694. _this4.video_list = state.sectionEpisodes || [], _this4;
  695. }
  696. return video_base_createClass(VideoFestival, [ {
  697. key: "total",
  698. value: function total() {
  699. return this.video_list.length;
  700. }
  701. }, {
  702. key: "title",
  703. value: function title(p) {
  704. return p ? this.video_list[this.id(p)].title : this.video_info.title;
  705. }
  706. }, {
  707. key: "filename",
  708. value: function filename(p) {
  709. var title;
  710. if (p) {
  711. var id = this.id(p);
  712. title = this.main_title + (this.total() > 1 ? " P".concat(id + 1, " ").concat(this.video_list[id].title) : "");
  713. } else title = this.video_info.title;
  714. return title.replace(/[\/\\:*?"<>|]+/g, "");
  715. }
  716. }, {
  717. key: "aid",
  718. value: function aid(p) {
  719. return p ? this.video_list[this.id(p)].id : this.video_info.aid;
  720. }
  721. }, {
  722. key: "bvid",
  723. value: function bvid(p) {
  724. return p ? this.video_list[this.id(p)].bvid : this.video_info.bvid;
  725. }
  726. }, {
  727. key: "cid",
  728. value: function cid(p) {
  729. return p ? this.video_list[this.id(p)].cid : this.video_info.cid;
  730. }
  731. } ]), VideoFestival;
  732. }(VideoBase), Bangumi = function(_VideoBase4) {
  733. _inherits(Bangumi, _VideoBase4);
  734. var _super4 = _createSuper(Bangumi);
  735. function Bangumi(main_title, state) {
  736. var _this5;
  737. return video_base_classCallCheck(this, Bangumi), (_this5 = _super4.call(this, "bangumi", main_title, state)).epInfo = state.epInfo,
  738. _this5.epList = state.epList, _this5.epId = state.epId, _this5.epMap = state.epMap,
  739. _this5.isEpMap = state.isEpMap, _this5;
  740. }
  741. return video_base_createClass(Bangumi, [ {
  742. key: "total",
  743. value: function total() {
  744. return this.epList.length;
  745. }
  746. }, {
  747. key: "getEpisode",
  748. value: function getEpisode(p) {
  749. return p ? this.epList[this.id(p)] : this.epMap[this.epId] || this.epInfo || {};
  750. }
  751. }, {
  752. key: "getEpPadLen",
  753. value: function getEpPadLen() {
  754. for (var n = Object.keys(this.isEpMap).length, len = n < 10 ? 1 : 0; n >= 1; ) n /= 10,
  755. len++;
  756. return len;
  757. }
  758. }, {
  759. key: "title",
  760. value: function title(p) {
  761. var ep = this.getEpisode(p), title = "";
  762. if (this.isEpMap[ep.id]) {
  763. var epNum = Object.keys(this.isEpMap).length > 1 ? "EP".concat(("" + this.p(p)).padStart(this.getEpPadLen(), "0")) : "";
  764. title = "".concat(this.main_title, " ").concat(epNum, " ").concat(ep.long_title);
  765. } else ep.share_copy ? (title = ep.share_copy.split("》", 2), title = title.length > 1 ? "".concat(this.main_title, " ").concat(title[1]) : "".concat(this.main_title, " ").concat(ep.title, " ").concat(ep.long_title)) : title = "".concat(ep.title, " ").concat(ep.long_title);
  766. return title.replaceAll("undefined", "").replaceAll(" ", " ").trim();
  767. }
  768. }, {
  769. key: "filename",
  770. value: function filename(p) {
  771. return this.title(p).replace(/[\/\\:*?"<>|]+/g, "");
  772. }
  773. }, {
  774. key: "aid",
  775. value: function aid(p) {
  776. return this.getEpisode(p).aid;
  777. }
  778. }, {
  779. key: "bvid",
  780. value: function bvid(p) {
  781. return this.getEpisode(p).bvid;
  782. }
  783. }, {
  784. key: "cid",
  785. value: function cid(p) {
  786. return this.getEpisode(p).cid;
  787. }
  788. }, {
  789. key: "epid",
  790. value: function epid(p) {
  791. return this.getEpisode(p).id;
  792. }
  793. }, {
  794. key: "needVip",
  795. value: function needVip(p) {
  796. return "会员" === this.getEpisode(p).badge;
  797. }
  798. }, {
  799. key: "vipNeedPay",
  800. value: function vipNeedPay(p) {
  801. return "付费" === this.getEpisode(p).badge;
  802. }
  803. }, {
  804. key: "isLimited",
  805. value: function isLimited() {
  806. return !1;
  807. }
  808. } ], [ {
  809. key: "build",
  810. value: function build() {
  811. var bangumiCache = cache.get("Bangumi");
  812. if (location.href == bangumiCache.get("href") && bangumiCache.get("build")) return bangumiCache.get("build");
  813. bangumiCache.set("build", null);
  814. var main_title, sid, epid, epMap = {}, pathname = location.pathname.toLowerCase();
  815. pathname.startsWith("/bangumi/play/ss") ? (sid = pathname.match(/ss(\d+)/), sid = parseInt(sid[1])) : pathname.startsWith("/bangumi/play/ep") && (epid = pathname.match(/ep(\d+)/),
  816. epid = parseInt(epid[1]));
  817. try {
  818. console.log("location sid:", sid, "epid:", epid);
  819. var page_data = JSON.parse($(".toolbar").attr("mr-show"));
  820. main_title = page_data.msg.title, sid = sid || page_data.msg.season_id, epid = epid || page_data.msg.ep_id,
  821. console.log("mr-show get sid:", sid, "epid:", epid);
  822. } catch (_unused) {
  823. console.warn("mr-show get err");
  824. }
  825. if (sid != bangumiCache.get("sid") && (bangumiCache.set("sid", sid), bangumiCache.set("epid", ""),
  826. bangumiCache.set("hasData", !1)), sid && !epid && _ajax({
  827. type: "GET",
  828. url: "https://api.bilibili.com/pgc/player/web/v2/playurl?support_multi_audio=true&qn=80&fnver=0&fnval=4048&fourk=1&gaia_source=&from_client=BROWSER&is_main_page=true&need_fragment=true&season_id=".concat(sid, "&isGaiaAvoided=false&voice_balance=1&drm_tech_type=2"),
  829. dataType: "json",
  830. xhrFields: {
  831. withCredentials: !0
  832. }
  833. }).then((function(res) {
  834. res && !res.code && bangumiCache.set("epid", res.result.view_info.report.ep_id);
  835. })), bangumiCache.get("lock")) throw "bangumiCache request waiting !";
  836. if (bangumiCache.set("lock", !0), epid = epid || "", _ajax({
  837. type: "GET",
  838. url: "https://api.bilibili.com/pgc/view/web/ep/list?season_id=".concat(sid = sid || "", "&ep_id=").concat(epid),
  839. dataType: "json",
  840. cache: !0
  841. }).then((function(res) {
  842. res && !res.code && (bangumiCache.set("hasData", !0), bangumiCache.set("episodes", res.result.episodes || []),
  843. bangumiCache.set("section", res.result.section || []));
  844. })).finally((function() {
  845. bangumiCache.set("lock", !1);
  846. })), bangumiCache.set("href", location.href), !epid && !bangumiCache.get("epid")) throw "epid not found !";
  847. if (!bangumiCache.get("hasData")) throw "bangumiCache no data !";
  848. var _step4, episodes = bangumiCache.get("episodes") || [], isEpMap = {}, _iterator4 = _createForOfIteratorHelper(episodes = [].concat(_toConsumableArray(episodes.filter((function(a) {
  849. return 1 != a.badge_type;
  850. }))), _toConsumableArray(episodes.filter((function(a) {
  851. return 1 == a.badge_type;
  852. })))));
  853. try {
  854. for (_iterator4.s(); !(_step4 = _iterator4.n()).done; ) {
  855. var ep = _step4.value;
  856. [ 0, 2, 3 ].includes(ep.badge_type) && (isEpMap[ep.id] = !0);
  857. }
  858. } catch (err) {
  859. _iterator4.e(err);
  860. } finally {
  861. _iterator4.f();
  862. }
  863. var _step5, _iterator5 = _createForOfIteratorHelper(bangumiCache.get("section") || []);
  864. try {
  865. for (_iterator5.s(); !(_step5 = _iterator5.n()).done; ) {
  866. var item = _step5.value;
  867. if (item.episodes) {
  868. var _step6, _iterator6 = _createForOfIteratorHelper(item.episodes);
  869. try {
  870. for (_iterator6.s(); !(_step6 = _iterator6.n()).done; ) {
  871. var _ep = _step6.value;
  872. episodes.push(_ep);
  873. }
  874. } catch (err) {
  875. _iterator6.e(err);
  876. } finally {
  877. _iterator6.f();
  878. }
  879. }
  880. }
  881. } catch (err) {
  882. _iterator5.e(err);
  883. } finally {
  884. _iterator5.f();
  885. }
  886. epid = epid || bangumiCache.get("epid");
  887. for (var _id = 0, i = 0; i < episodes.length; i++) epMap[episodes[i].id] = episodes[i],
  888. episodes[i].id == epid && (_id = i);
  889. var bangumi = new Bangumi(main_title, {
  890. p: _id + 1,
  891. epId: epid,
  892. epList: episodes,
  893. isEpMap: isEpMap,
  894. epMap: epMap,
  895. epInfo: epMap[epid]
  896. });
  897. return bangumiCache.set("build", bangumi), bangumi;
  898. }
  899. } ]), Bangumi;
  900. }(VideoBase), Cheese = function(_VideoBase5) {
  901. _inherits(Cheese, _VideoBase5);
  902. var _super5 = _createSuper(Cheese);
  903. function Cheese(main_title, state) {
  904. var _this6;
  905. return video_base_classCallCheck(this, Cheese), (_this6 = _super5.call(this, "cheese", main_title, state)).episodes = state.episodes,
  906. _this6;
  907. }
  908. return video_base_createClass(Cheese, [ {
  909. key: "total",
  910. value: function total() {
  911. return this.episodes.length;
  912. }
  913. }, {
  914. key: "title",
  915. value: function title(p) {
  916. return this.episodes[this.id(p)].title;
  917. }
  918. }, {
  919. key: "filename",
  920. value: function filename(p) {
  921. return "".concat(this.main_title, " EP").concat(this.p(p), " ").concat(this.title(p)).replace(/[\/\\:*?"<>|]+/g, "");
  922. }
  923. }, {
  924. key: "aid",
  925. value: function aid(p) {
  926. return this.episodes[this.id(p)].aid;
  927. }
  928. }, {
  929. key: "cid",
  930. value: function cid(p) {
  931. return this.episodes[this.id(p)].cid;
  932. }
  933. }, {
  934. key: "epid",
  935. value: function epid(p) {
  936. return this.episodes[this.id(p)].id;
  937. }
  938. } ], [ {
  939. key: "build",
  940. value: function build() {
  941. var epid, cheeseCache = cache.get("Cheese"), sid = (location.href.match(/\/cheese\/play\/ss(\d+)/i) || [ "", "" ])[1];
  942. if (sid || (epid = (location.href.match(/\/cheese\/play\/ep(\d+)/i) || [ "", "" ])[1]),
  943. epid || (epid = parseInt($(".bpx-state-active").eq(0).attr("data-episodeid"))),
  944. sid && sid != cheeseCache.get("sid") && (cheeseCache.set("sid", sid), cheeseCache.set("episodes", null)),
  945. !cheeseCache.get("episodes")) {
  946. if (cheeseCache.get("lock")) throw "cheese request waiting !";
  947. if (cheeseCache.set("lock", !0), !sid && !epid) return void console.log("get_season error");
  948. _ajax({
  949. url: "https://api.bilibili.com/pugv/view/web/season?season_id=".concat(sid || "", "&ep_id=").concat(epid || ""),
  950. xhrFields: {
  951. withCredentials: !0
  952. },
  953. dataType: "json"
  954. }).then((function(res) {
  955. res.code ? Message.warning("获取剧集信息失败") : cheeseCache.set("episodes", res.data.episodes);
  956. })).finally((function() {
  957. cheeseCache.set("lock", !1);
  958. }));
  959. }
  960. var episodes = cheeseCache.get("episodes");
  961. if (!episodes) throw "cheese has not data !";
  962. for (var _id = -1, i = 0; i < episodes.length; i++) {
  963. if (!epid) {
  964. epid = episodes[i].id, _id = 0;
  965. break;
  966. }
  967. if (episodes[i].id == epid) {
  968. _id = i;
  969. break;
  970. }
  971. }
  972. if (_id < 0) throw cheeseCache.set("episodes", null), "episodes need reload !";
  973. return new Cheese(($("div.archive-title-box").text() || "unknown").replace(/[\/\\:*?"<>|]+/g, ""), {
  974. p: _id + 1,
  975. episodes: episodes
  976. });
  977. }
  978. } ]), Cheese;
  979. }(VideoBase);
  980. function type() {
  981. var routerMap = {
  982. video: "/video/",
  983. list: "/list/",
  984. festival: "/festival/",
  985. bangumi: "/bangumi/play/",
  986. cheese: "/cheese/play/"
  987. };
  988. for (var key in routerMap) if (location.pathname.startsWith(routerMap[key])) return key;
  989. return "?";
  990. }
  991. var q_map = {
  992. "8K 超高清": 127,
  993. "4K 超清": 120,
  994. "1080P 60帧": 116,
  995. "1080P 高码率": 112,
  996. "1080P 高清": 80,
  997. "720P 高清": 64,
  998. "480P 清晰": 32,
  999. "360P 流畅": 16,
  1000. "自动": 32
  1001. };
  1002. var video = {
  1003. type: type,
  1004. base: function base() {
  1005. var _type = type(), vb = new VideoBase;
  1006. if ("video" === _type) {
  1007. var state = window.__INITIAL_STATE__, main_title = state.videoData && state.videoData.title;
  1008. vb = new Video(main_title, state);
  1009. } else if ("list" === _type) {
  1010. var _state = window.__INITIAL_STATE__, _main_title = _state.mediaListInfo && _state.mediaListInfo.upper.name + "-" + _state.mediaListInfo.title;
  1011. vb = new VideoList(_main_title, _state);
  1012. } else if ("festival" === _type) {
  1013. var _state2 = window.__INITIAL_STATE__, _main_title2 = _state2.title;
  1014. vb = new VideoFestival(_main_title2, _state2);
  1015. } else "bangumi" === _type ? vb = Bangumi.build() : "cheese" === _type && (vb = Cheese.build());
  1016. return vb;
  1017. },
  1018. get_quality: function get_quality() {
  1019. var _q = 0, _q_max = 0, _type = type();
  1020. if ("cheese" === _type) {
  1021. var q = $("div.edu-player-quality-item.active span").text(), q_max = $($("div.edu-player-quality-item span").get(0)).text();
  1022. _q = q in q_map ? q_map[q] : 0, _q_max = q_max in q_map ? q_map[q_max] : 0;
  1023. } else {
  1024. var keys = Object.keys(videoQualityMap), _q2 = parseInt(("video" === _type ? $("li.bpx-player-ctrl-quality-menu-item.bpx-state-active") : $("li.squirtle-select-item.active")).attr("data-value")), _q_max2 = parseInt($(("video" === _type ? $("li.bpx-player-ctrl-quality-menu-item") : $("li.squirtle-select-item")).get(0)).attr("data-value"));
  1025. _q = keys.indexOf("".concat(_q2)) > -1 ? _q2 : 0, _q_max = keys.indexOf("".concat(_q_max2)) > -1 ? _q_max2 : 0;
  1026. }
  1027. return !_q && (_q = 80), !_q_max && (_q_max = 80), user.isVIP() || (_q = _q > 80 ? 80 : _q),
  1028. {
  1029. q: _q,
  1030. q_max: _q_max
  1031. };
  1032. },
  1033. get_quality_support: function get_quality_support() {
  1034. var list, quality_list = [], _type = type();
  1035. if ("cheese" === _type) (list = $("div.edu-player-quality-item span")).each((function() {
  1036. var k = $(this).text();
  1037. q_map[k] && quality_list.push(q_map[k]);
  1038. })); else {
  1039. var keys = Object.keys(videoQualityMap);
  1040. (list = [ "video", "list" ].includes(_type) ? $("li.bpx-player-ctrl-quality-menu-item") : $("li.squirtle-select-item")) && list.length && list.each((function() {
  1041. var q = "".concat(parseInt($(this).attr("data-value")));
  1042. keys.indexOf(q) > -1 && quality_list.push(q);
  1043. }));
  1044. }
  1045. return quality_list.length ? quality_list : [ "80", "64", "32", "16" ];
  1046. }
  1047. };
  1048. function store_defineProperties(target, props) {
  1049. for (var i = 0; i < props.length; i++) {
  1050. var descriptor = props[i];
  1051. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0,
  1052. "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
  1053. }
  1054. }
  1055. var Store = function() {
  1056. function Store() {
  1057. !function store_classCallCheck(instance, Constructor) {
  1058. if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
  1059. }(this, Store), this.prefix = "bp_";
  1060. }
  1061. return function store_createClass(Constructor, protoProps, staticProps) {
  1062. return protoProps && store_defineProperties(Constructor.prototype, protoProps),
  1063. staticProps && store_defineProperties(Constructor, staticProps), Object.defineProperty(Constructor, "prototype", {
  1064. writable: !1
  1065. }), Constructor;
  1066. }(Store, [ {
  1067. key: "get",
  1068. value: function get() {
  1069. var key = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "";
  1070. return localStorage.getItem(this.prefix + key) || "";
  1071. }
  1072. }, {
  1073. key: "set",
  1074. value: function set() {
  1075. var key = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "", value = arguments.length > 1 ? arguments[1] : void 0;
  1076. localStorage.setItem(this.prefix + key, value);
  1077. }
  1078. } ]), Store;
  1079. }(), store = new Store;
  1080. function api_typeof(obj) {
  1081. return api_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
  1082. return typeof obj;
  1083. } : function(obj) {
  1084. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  1085. }, api_typeof(obj);
  1086. }
  1087. function api_createForOfIteratorHelper(o, allowArrayLike) {
  1088. var it = "undefined" != typeof Symbol && o[Symbol.iterator] || o["@@iterator"];
  1089. if (!it) {
  1090. if (Array.isArray(o) || (it = api_unsupportedIterableToArray(o)) || allowArrayLike && o && "number" == typeof o.length) {
  1091. it && (o = it);
  1092. var i = 0, F = function F() {};
  1093. return {
  1094. s: F,
  1095. n: function n() {
  1096. return i >= o.length ? {
  1097. done: !0
  1098. } : {
  1099. done: !1,
  1100. value: o[i++]
  1101. };
  1102. },
  1103. e: function e(_e) {
  1104. throw _e;
  1105. },
  1106. f: F
  1107. };
  1108. }
  1109. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1110. }
  1111. var err, normalCompletion = !0, didErr = !1;
  1112. return {
  1113. s: function s() {
  1114. it = it.call(o);
  1115. },
  1116. n: function n() {
  1117. var step = it.next();
  1118. return normalCompletion = step.done, step;
  1119. },
  1120. e: function e(_e2) {
  1121. didErr = !0, err = _e2;
  1122. },
  1123. f: function f() {
  1124. try {
  1125. normalCompletion || null == it.return || it.return();
  1126. } finally {
  1127. if (didErr) throw err;
  1128. }
  1129. }
  1130. };
  1131. }
  1132. function api_toConsumableArray(arr) {
  1133. return function api_arrayWithoutHoles(arr) {
  1134. if (Array.isArray(arr)) return api_arrayLikeToArray(arr);
  1135. }(arr) || function api_iterableToArray(iter) {
  1136. if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
  1137. }(arr) || api_unsupportedIterableToArray(arr) || function api_nonIterableSpread() {
  1138. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1139. }();
  1140. }
  1141. function api_unsupportedIterableToArray(o, minLen) {
  1142. if (o) {
  1143. if ("string" == typeof o) return api_arrayLikeToArray(o, minLen);
  1144. var n = Object.prototype.toString.call(o).slice(8, -1);
  1145. return "Object" === n && o.constructor && (n = o.constructor.name), "Map" === n || "Set" === n ? Array.from(o) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? api_arrayLikeToArray(o, minLen) : void 0;
  1146. }
  1147. }
  1148. function api_arrayLikeToArray(arr, len) {
  1149. (null == len || len > arr.length) && (len = arr.length);
  1150. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  1151. return arr2;
  1152. }
  1153. function _regeneratorRuntime() {
  1154. _regeneratorRuntime = function _regeneratorRuntime() {
  1155. return exports;
  1156. };
  1157. var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  1158. function define(obj, key, value) {
  1159. return Object.defineProperty(obj, key, {
  1160. value: value,
  1161. enumerable: !0,
  1162. configurable: !0,
  1163. writable: !0
  1164. }), obj[key];
  1165. }
  1166. try {
  1167. define({}, "");
  1168. } catch (err) {
  1169. define = function define(obj, key, value) {
  1170. return obj[key] = value;
  1171. };
  1172. }
  1173. function wrap(innerFn, outerFn, self, tryLocsList) {
  1174. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
  1175. return generator._invoke = function(innerFn, self, context) {
  1176. var state = "suspendedStart";
  1177. return function(method, arg) {
  1178. if ("executing" === state) throw new Error("Generator is already running");
  1179. if ("completed" === state) {
  1180. if ("throw" === method) throw arg;
  1181. return doneResult();
  1182. }
  1183. for (context.method = method, context.arg = arg; ;) {
  1184. var delegate = context.delegate;
  1185. if (delegate) {
  1186. var delegateResult = maybeInvokeDelegate(delegate, context);
  1187. if (delegateResult) {
  1188. if (delegateResult === ContinueSentinel) continue;
  1189. return delegateResult;
  1190. }
  1191. }
  1192. if ("next" === context.method) context.sent = context._sent = context.arg; else if ("throw" === context.method) {
  1193. if ("suspendedStart" === state) throw state = "completed", context.arg;
  1194. context.dispatchException(context.arg);
  1195. } else "return" === context.method && context.abrupt("return", context.arg);
  1196. state = "executing";
  1197. var record = tryCatch(innerFn, self, context);
  1198. if ("normal" === record.type) {
  1199. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  1200. return {
  1201. value: record.arg,
  1202. done: context.done
  1203. };
  1204. }
  1205. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  1206. }
  1207. };
  1208. }(innerFn, self, context), generator;
  1209. }
  1210. function tryCatch(fn, obj, arg) {
  1211. try {
  1212. return {
  1213. type: "normal",
  1214. arg: fn.call(obj, arg)
  1215. };
  1216. } catch (err) {
  1217. return {
  1218. type: "throw",
  1219. arg: err
  1220. };
  1221. }
  1222. }
  1223. exports.wrap = wrap;
  1224. var ContinueSentinel = {};
  1225. function Generator() {}
  1226. function GeneratorFunction() {}
  1227. function GeneratorFunctionPrototype() {}
  1228. var IteratorPrototype = {};
  1229. define(IteratorPrototype, iteratorSymbol, (function() {
  1230. return this;
  1231. }));
  1232. var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  1233. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  1234. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  1235. function defineIteratorMethods(prototype) {
  1236. [ "next", "throw", "return" ].forEach((function(method) {
  1237. define(prototype, method, (function(arg) {
  1238. return this._invoke(method, arg);
  1239. }));
  1240. }));
  1241. }
  1242. function AsyncIterator(generator, PromiseImpl) {
  1243. function invoke(method, arg, resolve, reject) {
  1244. var record = tryCatch(generator[method], generator, arg);
  1245. if ("throw" !== record.type) {
  1246. var result = record.arg, value = result.value;
  1247. return value && "object" == api_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then((function(value) {
  1248. invoke("next", value, resolve, reject);
  1249. }), (function(err) {
  1250. invoke("throw", err, resolve, reject);
  1251. })) : PromiseImpl.resolve(value).then((function(unwrapped) {
  1252. result.value = unwrapped, resolve(result);
  1253. }), (function(error) {
  1254. return invoke("throw", error, resolve, reject);
  1255. }));
  1256. }
  1257. reject(record.arg);
  1258. }
  1259. var previousPromise;
  1260. this._invoke = function(method, arg) {
  1261. function callInvokeWithMethodAndArg() {
  1262. return new PromiseImpl((function(resolve, reject) {
  1263. invoke(method, arg, resolve, reject);
  1264. }));
  1265. }
  1266. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  1267. };
  1268. }
  1269. function maybeInvokeDelegate(delegate, context) {
  1270. var method = delegate.iterator[context.method];
  1271. if (void 0 === method) {
  1272. if (context.delegate = null, "throw" === context.method) {
  1273. if (delegate.iterator.return && (context.method = "return", context.arg = void 0,
  1274. maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  1275. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  1276. }
  1277. return ContinueSentinel;
  1278. }
  1279. var record = tryCatch(method, delegate.iterator, context.arg);
  1280. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg,
  1281. context.delegate = null, ContinueSentinel;
  1282. var info = record.arg;
  1283. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc,
  1284. "return" !== context.method && (context.method = "next", context.arg = void 0),
  1285. context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"),
  1286. context.delegate = null, ContinueSentinel);
  1287. }
  1288. function pushTryEntry(locs) {
  1289. var entry = {
  1290. tryLoc: locs[0]
  1291. };
  1292. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2],
  1293. entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  1294. }
  1295. function resetTryEntry(entry) {
  1296. var record = entry.completion || {};
  1297. record.type = "normal", delete record.arg, entry.completion = record;
  1298. }
  1299. function Context(tryLocsList) {
  1300. this.tryEntries = [ {
  1301. tryLoc: "root"
  1302. } ], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
  1303. }
  1304. function values(iterable) {
  1305. if (iterable) {
  1306. var iteratorMethod = iterable[iteratorSymbol];
  1307. if (iteratorMethod) return iteratorMethod.call(iterable);
  1308. if ("function" == typeof iterable.next) return iterable;
  1309. if (!isNaN(iterable.length)) {
  1310. var i = -1, next = function next() {
  1311. for (;++i < iterable.length; ) if (hasOwn.call(iterable, i)) return next.value = iterable[i],
  1312. next.done = !1, next;
  1313. return next.value = void 0, next.done = !0, next;
  1314. };
  1315. return next.next = next;
  1316. }
  1317. }
  1318. return {
  1319. next: doneResult
  1320. };
  1321. }
  1322. function doneResult() {
  1323. return {
  1324. value: void 0,
  1325. done: !0
  1326. };
  1327. }
  1328. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype),
  1329. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"),
  1330. exports.isGeneratorFunction = function(genFun) {
  1331. var ctor = "function" == typeof genFun && genFun.constructor;
  1332. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  1333. }, exports.mark = function(genFun) {
  1334. return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype,
  1335. define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp),
  1336. genFun;
  1337. }, exports.awrap = function(arg) {
  1338. return {
  1339. __await: arg
  1340. };
  1341. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, (function() {
  1342. return this;
  1343. })), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  1344. void 0 === PromiseImpl && (PromiseImpl = Promise);
  1345. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  1346. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then((function(result) {
  1347. return result.done ? result.value : iter.next();
  1348. }));
  1349. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, (function() {
  1350. return this;
  1351. })), define(Gp, "toString", (function() {
  1352. return "[object Generator]";
  1353. })), exports.keys = function(object) {
  1354. var keys = [];
  1355. for (var key in object) keys.push(key);
  1356. return keys.reverse(), function next() {
  1357. for (;keys.length; ) {
  1358. var key = keys.pop();
  1359. if (key in object) return next.value = key, next.done = !1, next;
  1360. }
  1361. return next.done = !0, next;
  1362. };
  1363. }, exports.values = values, Context.prototype = {
  1364. constructor: Context,
  1365. reset: function reset(skipTempReset) {
  1366. if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1,
  1367. this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(resetTryEntry),
  1368. !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = void 0);
  1369. },
  1370. stop: function stop() {
  1371. this.done = !0;
  1372. var rootRecord = this.tryEntries[0].completion;
  1373. if ("throw" === rootRecord.type) throw rootRecord.arg;
  1374. return this.rval;
  1375. },
  1376. dispatchException: function dispatchException(exception) {
  1377. if (this.done) throw exception;
  1378. var context = this;
  1379. function handle(loc, caught) {
  1380. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next",
  1381. context.arg = void 0), !!caught;
  1382. }
  1383. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1384. var entry = this.tryEntries[i], record = entry.completion;
  1385. if ("root" === entry.tryLoc) return handle("end");
  1386. if (entry.tryLoc <= this.prev) {
  1387. var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc");
  1388. if (hasCatch && hasFinally) {
  1389. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  1390. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  1391. } else if (hasCatch) {
  1392. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  1393. } else {
  1394. if (!hasFinally) throw new Error("try statement without catch or finally");
  1395. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  1396. }
  1397. }
  1398. }
  1399. },
  1400. abrupt: function abrupt(type, arg) {
  1401. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1402. var entry = this.tryEntries[i];
  1403. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  1404. var finallyEntry = entry;
  1405. break;
  1406. }
  1407. }
  1408. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  1409. var record = finallyEntry ? finallyEntry.completion : {};
  1410. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next",
  1411. this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  1412. },
  1413. complete: function complete(record, afterLoc) {
  1414. if ("throw" === record.type) throw record.arg;
  1415. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg,
  1416. this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc),
  1417. ContinueSentinel;
  1418. },
  1419. finish: function finish(finallyLoc) {
  1420. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1421. var entry = this.tryEntries[i];
  1422. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc),
  1423. resetTryEntry(entry), ContinueSentinel;
  1424. }
  1425. },
  1426. catch: function _catch(tryLoc) {
  1427. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1428. var entry = this.tryEntries[i];
  1429. if (entry.tryLoc === tryLoc) {
  1430. var record = entry.completion;
  1431. if ("throw" === record.type) {
  1432. var thrown = record.arg;
  1433. resetTryEntry(entry);
  1434. }
  1435. return thrown;
  1436. }
  1437. }
  1438. throw new Error("illegal catch attempt");
  1439. },
  1440. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  1441. return this.delegate = {
  1442. iterator: values(iterable),
  1443. resultName: resultName,
  1444. nextLoc: nextLoc
  1445. }, "next" === this.method && (this.arg = void 0), ContinueSentinel;
  1446. }
  1447. }, exports;
  1448. }
  1449. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  1450. try {
  1451. var info = gen[key](arg), value = info.value;
  1452. } catch (error) {
  1453. return void reject(error);
  1454. }
  1455. info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
  1456. }
  1457. function get_url_base(page, quality, video_format, success, error, request_type) {
  1458. var _success, _error;
  1459. _success = "function" == typeof success ? function _success(e) {
  1460. success(e);
  1461. } : function _success(res) {
  1462. return console.log(res);
  1463. }, _error = "function" == typeof error ? function _error(e) {
  1464. message_Message_error("请求失败"), error(e);
  1465. } : function _error(err) {
  1466. return console.error(err);
  1467. };
  1468. var vb = video.base(), _ref = [ vb.aid(page), vb.bvid(page), vb.cid(page), vb.epid(page), quality || video.get_quality().q, vb.type() ], aid = _ref[0], bvid = _ref[1], cid = _ref[2], epid = _ref[3], q = _ref[4], type = _ref[5], format = video_format || config_config.format;
  1469. "auto" === request_type && user.needReplace() && (request_type = "remote");
  1470. var base_api, url_replace_cdn = function url_replace_cdn(url) {
  1471. if ("0" === config_config.host_key) return url;
  1472. var url_tmp = url.split("/"), mapping = hostMap[config_config.host_key];
  1473. return "string" == typeof mapping && mapping.length ? mapping.at(0).match(/[a-z]/) && (url_tmp[2] = mapping) : "function" == typeof mapping && (url_tmp[2] = mapping()),
  1474. url = url_tmp.join("/");
  1475. }, ajax_obj = {
  1476. type: "GET",
  1477. dataType: "json"
  1478. };
  1479. if ("auto" === request_type || "local" === request_type) {
  1480. var fnver, fnval;
  1481. "cheese" === type ? (base_api = "https://api.bilibili.com/pugv/player/web/playurl",
  1482. fnver = "mp4" === format ? 1 : 0, fnval = 80) : (base_api = "video" === type ? "https://api.bilibili.com/x/player/playurl" : "https://api.bilibili.com/pgc/player/web/playurl",
  1483. fnver = 0, fnval = {
  1484. dash: 4048,
  1485. flv: 4049,
  1486. mp4: 0
  1487. }[format] || 0), base_api += "?avid=".concat(aid, "&bvid=").concat(bvid, "&cid=").concat(cid, "&qn=").concat(q, "&fnver=").concat(fnver, "&fnval=").concat(fnval, "&fourk=1&ep_id=").concat(epid, "&type=").concat(format, "&otype=json"),
  1488. base_api += "mp4" === format ? "&platform=html5&high_quality=1" : "", ajax_obj.xhrFields = {
  1489. withCredentials: !0
  1490. };
  1491. } else {
  1492. base_api = config_config.base_api, base_api += "?av=".concat(aid, "&bv=").concat(bvid, "&cid=").concat(cid, "&ep=").concat(epid, "&q=").concat(q, "&type=").concat(type, "&format=").concat(format, "&otype=json"),
  1493. page && (base_api += "&s");
  1494. var _ref2 = [ store.get("auth_id"), store.get("auth_sec") ], auth_id = _ref2[0], auth_sec = _ref2[1];
  1495. auth_id && auth_sec && (base_api += "&auth_id=".concat(auth_id, "&auth_sec=").concat(auth_sec));
  1496. }
  1497. var resultConvertor = function resultConvertor(data, _success) {
  1498. var checkTask = function checkTask(key, backup_key) {
  1499. return data[backup_key] ? _ajax({
  1500. type: "GET",
  1501. url: data[key],
  1502. cache: !1,
  1503. timeout: 1e3,
  1504. success: function success(res) {
  1505. return key;
  1506. },
  1507. error: function error(res) {
  1508. return "timeout" == res.statusText ? key : backup_key;
  1509. }
  1510. }) : Promise.resolve(key);
  1511. };
  1512. new Promise((function(resolve, reject) {
  1513. var promiseList = [], valueList = [];
  1514. data.url ? promiseList.push(checkTask("url", "backup_url")) : (promiseList.push(checkTask("video", "backup_video")),
  1515. promiseList.push(checkTask("audio", "backup_audio")));
  1516. var timer = setTimeout((function() {
  1517. resolve(valueList);
  1518. }), 1500), index = 0;
  1519. promiseList.forEach(function() {
  1520. var _ref3 = function _asyncToGenerator(fn) {
  1521. return function() {
  1522. var self = this, args = arguments;
  1523. return new Promise((function(resolve, reject) {
  1524. var gen = fn.apply(self, args);
  1525. function _next(value) {
  1526. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  1527. }
  1528. function _throw(err) {
  1529. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  1530. }
  1531. _next(void 0);
  1532. }));
  1533. };
  1534. }(_regeneratorRuntime().mark((function _callee(promise) {
  1535. var result;
  1536. return _regeneratorRuntime().wrap((function _callee$(_context) {
  1537. for (;;) switch (_context.prev = _context.next) {
  1538. case 0:
  1539. return _context.prev = 0, _context.next = 3, promise;
  1540.  
  1541. case 3:
  1542. result = _context.sent, _context.next = 9;
  1543. break;
  1544.  
  1545. case 6:
  1546. _context.prev = 6, _context.t0 = _context.catch(0), result = _context.t0;
  1547.  
  1548. case 9:
  1549. console.log("use " + result), valueList[index++] = result, index == promiseList.length && (clearInterval(timer),
  1550. resolve(valueList));
  1551.  
  1552. case 12:
  1553. case "end":
  1554. return _context.stop();
  1555. }
  1556. }), _callee, null, [ [ 0, 6 ] ]);
  1557. })));
  1558. return function(_x) {
  1559. return _ref3.apply(this, arguments);
  1560. };
  1561. }());
  1562. })).then((function(resList) {
  1563. if (console.log("use data key: ", resList), resList) {
  1564. var _step, _iterator = api_createForOfIteratorHelper(resList = api_toConsumableArray(resList));
  1565. try {
  1566. for (_iterator.s(); !(_step = _iterator.n()).done; ) {
  1567. var key = _step.value;
  1568. data[key] && ([ "url", "backup_url" ].includes(key) ? data.url = data[key] : [ "video", "backup_video" ].includes(key) ? data.video = data[key] : [ "audio", "backup_audio" ].includes(key) && (data.audio = data[key]));
  1569. }
  1570. } catch (err) {
  1571. _iterator.e(err);
  1572. } finally {
  1573. _iterator.f();
  1574. }
  1575. }
  1576. })).finally((function() {
  1577. _success(data);
  1578. }));
  1579. };
  1580. ajax_obj.url = base_api, ajax(ajax_obj).then((function(res) {
  1581. var data;
  1582. if (res.code || (data = res.result || res.data), !data) return "auto" === request_type ? void get_url_base(page, quality, video_format, success, error, "remote") : (res.url && (res.url = url_replace_cdn(res.url)),
  1583. res.video && (res.video = url_replace_cdn(res.video)), res.audio && (res.audio = url_replace_cdn(res.audio)),
  1584. void resultConvertor(res, _success));
  1585. if (data.dash) {
  1586. for (var result = {
  1587. code: 0,
  1588. quality: data.quality,
  1589. accept_quality: data.accept_quality,
  1590. video: "",
  1591. audio: ""
  1592. }, videos = data.dash.video, i = 0; i < videos.length; i++) {
  1593. var _video = videos[i];
  1594. if (_video.id <= q) {
  1595. result.video = url_replace_cdn(_video.base_url), result.audio = url_replace_cdn(data.dash.audio[0].base_url),
  1596. result.backup_video = _video.backup_url && url_replace_cdn(_video.backup_url[0]),
  1597. result.backup_audio = data.dash.audio[0].backup_url && url_replace_cdn(data.dash.audio[0].backup_url[0]);
  1598. break;
  1599. }
  1600. }
  1601. resultConvertor(result, _success);
  1602. } else resultConvertor({
  1603. code: 0,
  1604. quality: data.quality,
  1605. accept_quality: data.accept_quality,
  1606. url: url_replace_cdn(data.durl[0].url),
  1607. backup_url: data.durl[0].backup_url && url_replace_cdn(data.durl[0].backup_url[0])
  1608. }, _success);
  1609. })).catch((function(err) {
  1610. return _error(err);
  1611. }));
  1612. }
  1613. function _get_subtitle(p, callback) {
  1614. var to_blob_url = !(arguments.length > 2 && void 0 !== arguments[2]) || arguments[2], vb = video.base(), _ref4 = [ vb.aid(p), vb.cid(p), vb.epid(p) ], aid = _ref4[0], cid = _ref4[1], epid = _ref4[2];
  1615. ajax({
  1616. url: "https://api.bilibili.com/x/player/v2?aid=".concat(aid, "&cid=").concat(cid, "&ep_id=").concat(epid),
  1617. dataType: "json"
  1618. }).then((function(res) {
  1619. !res.code && res.data.subtitle.subtitles[0] ? ajax({
  1620. url: "".concat(res.data.subtitle.subtitles[0].subtitle_url),
  1621. dataType: "json"
  1622. }).then((function(res) {
  1623. var _step2, webvtt = "WEBVTT\n\n", _iterator2 = api_createForOfIteratorHelper(res.body || [ {
  1624. from: 0,
  1625. to: 0,
  1626. content: ""
  1627. } ]);
  1628. try {
  1629. for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
  1630. var data = _step2.value, a = new Date(1e3 * (parseInt(data.from) - 28800)).toTimeString().split(" ")[0] + "." + (data.from.toString().split(".")[1] || "000").padEnd(3, "0"), b = new Date(1e3 * (parseInt(data.to) - 28800)).toTimeString().split(" ")[0] + "." + (data.to.toString().split(".")[1] || "000").padEnd(3, "0");
  1631. webvtt += "".concat(a, " --\x3e ").concat(b, "\n").concat(data.content.trim(), "\n\n");
  1632. }
  1633. } catch (err) {
  1634. _iterator2.e(err);
  1635. } finally {
  1636. _iterator2.f();
  1637. }
  1638. callback(to_blob_url ? URL.createObjectURL(new Blob([ webvtt ], {
  1639. type: "text/vtt"
  1640. })) : webvtt);
  1641. })).catch(callback) : callback();
  1642. })).catch(callback);
  1643. }
  1644. var api = {
  1645. get_url: function get_url(success, error) {
  1646. var request_type = config_config.request_type, format = config_config.format;
  1647. get_url_base(0, parseInt(config_config.video_quality), format, success, error, request_type);
  1648. },
  1649. get_urls: function get_urls(page, quality, format, success, error) {
  1650. get_url_base(page, quality, format, success, error, config_config.request_type);
  1651. },
  1652. get_subtitle_url: function get_subtitle_url(p, callback) {
  1653. _get_subtitle(p, callback, !0);
  1654. },
  1655. get_subtitle_data: function get_subtitle_data(p, callback) {
  1656. _get_subtitle(p, callback, !1);
  1657. }
  1658. };
  1659. function runtime_lib_typeof(obj) {
  1660. return runtime_lib_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
  1661. return typeof obj;
  1662. } : function(obj) {
  1663. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  1664. }, runtime_lib_typeof(obj);
  1665. }
  1666. function runtime_lib_createForOfIteratorHelper(o, allowArrayLike) {
  1667. var it = "undefined" != typeof Symbol && o[Symbol.iterator] || o["@@iterator"];
  1668. if (!it) {
  1669. if (Array.isArray(o) || (it = function runtime_lib_unsupportedIterableToArray(o, minLen) {
  1670. if (!o) return;
  1671. if ("string" == typeof o) return runtime_lib_arrayLikeToArray(o, minLen);
  1672. var n = Object.prototype.toString.call(o).slice(8, -1);
  1673. "Object" === n && o.constructor && (n = o.constructor.name);
  1674. if ("Map" === n || "Set" === n) return Array.from(o);
  1675. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return runtime_lib_arrayLikeToArray(o, minLen);
  1676. }(o)) || allowArrayLike && o && "number" == typeof o.length) {
  1677. it && (o = it);
  1678. var i = 0, F = function F() {};
  1679. return {
  1680. s: F,
  1681. n: function n() {
  1682. return i >= o.length ? {
  1683. done: !0
  1684. } : {
  1685. done: !1,
  1686. value: o[i++]
  1687. };
  1688. },
  1689. e: function e(_e) {
  1690. throw _e;
  1691. },
  1692. f: F
  1693. };
  1694. }
  1695. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1696. }
  1697. var err, normalCompletion = !0, didErr = !1;
  1698. return {
  1699. s: function s() {
  1700. it = it.call(o);
  1701. },
  1702. n: function n() {
  1703. var step = it.next();
  1704. return normalCompletion = step.done, step;
  1705. },
  1706. e: function e(_e2) {
  1707. didErr = !0, err = _e2;
  1708. },
  1709. f: function f() {
  1710. try {
  1711. normalCompletion || null == it.return || it.return();
  1712. } finally {
  1713. if (didErr) throw err;
  1714. }
  1715. }
  1716. };
  1717. }
  1718. function runtime_lib_arrayLikeToArray(arr, len) {
  1719. (null == len || len > arr.length) && (len = arr.length);
  1720. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  1721. return arr2;
  1722. }
  1723. function runtime_lib_regeneratorRuntime() {
  1724. runtime_lib_regeneratorRuntime = function _regeneratorRuntime() {
  1725. return exports;
  1726. };
  1727. var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  1728. function define(obj, key, value) {
  1729. return Object.defineProperty(obj, key, {
  1730. value: value,
  1731. enumerable: !0,
  1732. configurable: !0,
  1733. writable: !0
  1734. }), obj[key];
  1735. }
  1736. try {
  1737. define({}, "");
  1738. } catch (err) {
  1739. define = function define(obj, key, value) {
  1740. return obj[key] = value;
  1741. };
  1742. }
  1743. function wrap(innerFn, outerFn, self, tryLocsList) {
  1744. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
  1745. return generator._invoke = function(innerFn, self, context) {
  1746. var state = "suspendedStart";
  1747. return function(method, arg) {
  1748. if ("executing" === state) throw new Error("Generator is already running");
  1749. if ("completed" === state) {
  1750. if ("throw" === method) throw arg;
  1751. return doneResult();
  1752. }
  1753. for (context.method = method, context.arg = arg; ;) {
  1754. var delegate = context.delegate;
  1755. if (delegate) {
  1756. var delegateResult = maybeInvokeDelegate(delegate, context);
  1757. if (delegateResult) {
  1758. if (delegateResult === ContinueSentinel) continue;
  1759. return delegateResult;
  1760. }
  1761. }
  1762. if ("next" === context.method) context.sent = context._sent = context.arg; else if ("throw" === context.method) {
  1763. if ("suspendedStart" === state) throw state = "completed", context.arg;
  1764. context.dispatchException(context.arg);
  1765. } else "return" === context.method && context.abrupt("return", context.arg);
  1766. state = "executing";
  1767. var record = tryCatch(innerFn, self, context);
  1768. if ("normal" === record.type) {
  1769. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  1770. return {
  1771. value: record.arg,
  1772. done: context.done
  1773. };
  1774. }
  1775. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  1776. }
  1777. };
  1778. }(innerFn, self, context), generator;
  1779. }
  1780. function tryCatch(fn, obj, arg) {
  1781. try {
  1782. return {
  1783. type: "normal",
  1784. arg: fn.call(obj, arg)
  1785. };
  1786. } catch (err) {
  1787. return {
  1788. type: "throw",
  1789. arg: err
  1790. };
  1791. }
  1792. }
  1793. exports.wrap = wrap;
  1794. var ContinueSentinel = {};
  1795. function Generator() {}
  1796. function GeneratorFunction() {}
  1797. function GeneratorFunctionPrototype() {}
  1798. var IteratorPrototype = {};
  1799. define(IteratorPrototype, iteratorSymbol, (function() {
  1800. return this;
  1801. }));
  1802. var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  1803. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  1804. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  1805. function defineIteratorMethods(prototype) {
  1806. [ "next", "throw", "return" ].forEach((function(method) {
  1807. define(prototype, method, (function(arg) {
  1808. return this._invoke(method, arg);
  1809. }));
  1810. }));
  1811. }
  1812. function AsyncIterator(generator, PromiseImpl) {
  1813. function invoke(method, arg, resolve, reject) {
  1814. var record = tryCatch(generator[method], generator, arg);
  1815. if ("throw" !== record.type) {
  1816. var result = record.arg, value = result.value;
  1817. return value && "object" == runtime_lib_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then((function(value) {
  1818. invoke("next", value, resolve, reject);
  1819. }), (function(err) {
  1820. invoke("throw", err, resolve, reject);
  1821. })) : PromiseImpl.resolve(value).then((function(unwrapped) {
  1822. result.value = unwrapped, resolve(result);
  1823. }), (function(error) {
  1824. return invoke("throw", error, resolve, reject);
  1825. }));
  1826. }
  1827. reject(record.arg);
  1828. }
  1829. var previousPromise;
  1830. this._invoke = function(method, arg) {
  1831. function callInvokeWithMethodAndArg() {
  1832. return new PromiseImpl((function(resolve, reject) {
  1833. invoke(method, arg, resolve, reject);
  1834. }));
  1835. }
  1836. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  1837. };
  1838. }
  1839. function maybeInvokeDelegate(delegate, context) {
  1840. var method = delegate.iterator[context.method];
  1841. if (void 0 === method) {
  1842. if (context.delegate = null, "throw" === context.method) {
  1843. if (delegate.iterator.return && (context.method = "return", context.arg = void 0,
  1844. maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  1845. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  1846. }
  1847. return ContinueSentinel;
  1848. }
  1849. var record = tryCatch(method, delegate.iterator, context.arg);
  1850. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg,
  1851. context.delegate = null, ContinueSentinel;
  1852. var info = record.arg;
  1853. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc,
  1854. "return" !== context.method && (context.method = "next", context.arg = void 0),
  1855. context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"),
  1856. context.delegate = null, ContinueSentinel);
  1857. }
  1858. function pushTryEntry(locs) {
  1859. var entry = {
  1860. tryLoc: locs[0]
  1861. };
  1862. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2],
  1863. entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  1864. }
  1865. function resetTryEntry(entry) {
  1866. var record = entry.completion || {};
  1867. record.type = "normal", delete record.arg, entry.completion = record;
  1868. }
  1869. function Context(tryLocsList) {
  1870. this.tryEntries = [ {
  1871. tryLoc: "root"
  1872. } ], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
  1873. }
  1874. function values(iterable) {
  1875. if (iterable) {
  1876. var iteratorMethod = iterable[iteratorSymbol];
  1877. if (iteratorMethod) return iteratorMethod.call(iterable);
  1878. if ("function" == typeof iterable.next) return iterable;
  1879. if (!isNaN(iterable.length)) {
  1880. var i = -1, next = function next() {
  1881. for (;++i < iterable.length; ) if (hasOwn.call(iterable, i)) return next.value = iterable[i],
  1882. next.done = !1, next;
  1883. return next.value = void 0, next.done = !0, next;
  1884. };
  1885. return next.next = next;
  1886. }
  1887. }
  1888. return {
  1889. next: doneResult
  1890. };
  1891. }
  1892. function doneResult() {
  1893. return {
  1894. value: void 0,
  1895. done: !0
  1896. };
  1897. }
  1898. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype),
  1899. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"),
  1900. exports.isGeneratorFunction = function(genFun) {
  1901. var ctor = "function" == typeof genFun && genFun.constructor;
  1902. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  1903. }, exports.mark = function(genFun) {
  1904. return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype,
  1905. define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp),
  1906. genFun;
  1907. }, exports.awrap = function(arg) {
  1908. return {
  1909. __await: arg
  1910. };
  1911. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, (function() {
  1912. return this;
  1913. })), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  1914. void 0 === PromiseImpl && (PromiseImpl = Promise);
  1915. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  1916. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then((function(result) {
  1917. return result.done ? result.value : iter.next();
  1918. }));
  1919. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, (function() {
  1920. return this;
  1921. })), define(Gp, "toString", (function() {
  1922. return "[object Generator]";
  1923. })), exports.keys = function(object) {
  1924. var keys = [];
  1925. for (var key in object) keys.push(key);
  1926. return keys.reverse(), function next() {
  1927. for (;keys.length; ) {
  1928. var key = keys.pop();
  1929. if (key in object) return next.value = key, next.done = !1, next;
  1930. }
  1931. return next.done = !0, next;
  1932. };
  1933. }, exports.values = values, Context.prototype = {
  1934. constructor: Context,
  1935. reset: function reset(skipTempReset) {
  1936. if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1,
  1937. this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(resetTryEntry),
  1938. !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = void 0);
  1939. },
  1940. stop: function stop() {
  1941. this.done = !0;
  1942. var rootRecord = this.tryEntries[0].completion;
  1943. if ("throw" === rootRecord.type) throw rootRecord.arg;
  1944. return this.rval;
  1945. },
  1946. dispatchException: function dispatchException(exception) {
  1947. if (this.done) throw exception;
  1948. var context = this;
  1949. function handle(loc, caught) {
  1950. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next",
  1951. context.arg = void 0), !!caught;
  1952. }
  1953. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1954. var entry = this.tryEntries[i], record = entry.completion;
  1955. if ("root" === entry.tryLoc) return handle("end");
  1956. if (entry.tryLoc <= this.prev) {
  1957. var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc");
  1958. if (hasCatch && hasFinally) {
  1959. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  1960. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  1961. } else if (hasCatch) {
  1962. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  1963. } else {
  1964. if (!hasFinally) throw new Error("try statement without catch or finally");
  1965. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  1966. }
  1967. }
  1968. }
  1969. },
  1970. abrupt: function abrupt(type, arg) {
  1971. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1972. var entry = this.tryEntries[i];
  1973. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  1974. var finallyEntry = entry;
  1975. break;
  1976. }
  1977. }
  1978. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  1979. var record = finallyEntry ? finallyEntry.completion : {};
  1980. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next",
  1981. this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  1982. },
  1983. complete: function complete(record, afterLoc) {
  1984. if ("throw" === record.type) throw record.arg;
  1985. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg,
  1986. this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc),
  1987. ContinueSentinel;
  1988. },
  1989. finish: function finish(finallyLoc) {
  1990. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1991. var entry = this.tryEntries[i];
  1992. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc),
  1993. resetTryEntry(entry), ContinueSentinel;
  1994. }
  1995. },
  1996. catch: function _catch(tryLoc) {
  1997. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1998. var entry = this.tryEntries[i];
  1999. if (entry.tryLoc === tryLoc) {
  2000. var record = entry.completion;
  2001. if ("throw" === record.type) {
  2002. var thrown = record.arg;
  2003. resetTryEntry(entry);
  2004. }
  2005. return thrown;
  2006. }
  2007. }
  2008. throw new Error("illegal catch attempt");
  2009. },
  2010. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  2011. return this.delegate = {
  2012. iterator: values(iterable),
  2013. resultName: resultName,
  2014. nextLoc: nextLoc
  2015. }, "next" === this.method && (this.arg = void 0), ContinueSentinel;
  2016. }
  2017. }, exports;
  2018. }
  2019. function runtime_lib_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  2020. try {
  2021. var info = gen[key](arg), value = info.value;
  2022. } catch (error) {
  2023. return void reject(error);
  2024. }
  2025. info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
  2026. }
  2027. function runtime_lib_asyncToGenerator(fn) {
  2028. return function() {
  2029. var self = this, args = arguments;
  2030. return new Promise((function(resolve, reject) {
  2031. var gen = fn.apply(self, args);
  2032. function _next(value) {
  2033. runtime_lib_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  2034. }
  2035. function _throw(err) {
  2036. runtime_lib_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  2037. }
  2038. _next(void 0);
  2039. }));
  2040. };
  2041. }
  2042. function runtime_lib_defineProperties(target, props) {
  2043. for (var i = 0; i < props.length; i++) {
  2044. var descriptor = props[i];
  2045. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0,
  2046. "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
  2047. }
  2048. }
  2049. var RuntimeLib = function() {
  2050. function RuntimeLib(config) {
  2051. !function runtime_lib_classCallCheck(instance, Constructor) {
  2052. if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
  2053. }(this, RuntimeLib), this.config = config, this.moduleAsync, this.anyResolved = !1;
  2054. }
  2055. return function runtime_lib_createClass(Constructor, protoProps, staticProps) {
  2056. return protoProps && runtime_lib_defineProperties(Constructor.prototype, protoProps),
  2057. staticProps && runtime_lib_defineProperties(Constructor, staticProps), Object.defineProperty(Constructor, "prototype", {
  2058. writable: !1
  2059. }), Constructor;
  2060. }(RuntimeLib, [ {
  2061. key: "getModulePromise",
  2062. value: function getModulePromise() {
  2063. var _this = this, _this$config = this.config, urls = _this$config.urls, errs = (_this$config.getModule,
  2064. []);
  2065. return new Promise((function(resolve, reject) {
  2066. var i = 0;
  2067. urls.forEach((function(url) {
  2068. setTimeout(runtime_lib_asyncToGenerator(runtime_lib_regeneratorRuntime().mark((function _callee() {
  2069. var code;
  2070. return runtime_lib_regeneratorRuntime().wrap((function _callee$(_context) {
  2071. for (;;) switch (_context.prev = _context.next) {
  2072. case 0:
  2073. if (_context.prev = 0, !_this.anyResolved) {
  2074. _context.next = 3;
  2075. break;
  2076. }
  2077. return _context.abrupt("return");
  2078.  
  2079. case 3:
  2080. return console.log("[Runtime Library] Start download from ".concat(url)), _context.next = 6,
  2081. _ajax({
  2082. url: url,
  2083. type: "GET",
  2084. dataType: "text",
  2085. cache: !0
  2086. });
  2087.  
  2088. case 6:
  2089. if (code = _context.sent, !_this.anyResolved) {
  2090. _context.next = 9;
  2091. break;
  2092. }
  2093. return _context.abrupt("return");
  2094.  
  2095. case 9:
  2096. console.log("[Runtime Library] Downloaded from ".concat(url, " , length = ").concat(code.length)),
  2097. _this.anyResolved = !0, resolve(code), _context.next = 20;
  2098. break;
  2099.  
  2100. case 14:
  2101. if (_context.prev = 14, _context.t0 = _context.catch(0), !_this.anyResolved) {
  2102. _context.next = 18;
  2103. break;
  2104. }
  2105. return _context.abrupt("return");
  2106.  
  2107. case 18:
  2108. errs.push({
  2109. url: url,
  2110. err: _context.t0
  2111. }), 0 == --i && (console.error(errs), reject(errs));
  2112.  
  2113. case 20:
  2114. case "end":
  2115. return _context.stop();
  2116. }
  2117. }), _callee, null, [ [ 0, 14 ] ]);
  2118. }))), 1e3 * i++);
  2119. }));
  2120. }));
  2121. }
  2122. } ]), RuntimeLib;
  2123. }(), cdn_map = {
  2124. cloudflare: function cloudflare(name, ver, filename) {
  2125. return "https://cdnjs.cloudflare.com/ajax/libs/".concat(name, "/").concat(ver, "/").concat(filename);
  2126. },
  2127. bootcdn: function bootcdn(name, ver, filename) {
  2128. return "https://cdn.bootcdn.net/ajax/libs/".concat(name, "/").concat(ver, "/").concat(filename);
  2129. },
  2130. jsdelivr: function jsdelivr(name, ver, filename) {
  2131. return "https://cdn.jsdelivr.net/npm/".concat(name, "@").concat(ver, "/").concat(filename);
  2132. },
  2133. staticfile: function staticfile(name, ver, filename) {
  2134. return "https://cdn.staticfile.org/".concat(name, "/").concat(ver, "/").concat(filename);
  2135. }
  2136. }, urls = function urls(_ref2) {
  2137. var name = _ref2.name, ver = _ref2.ver, filename = _ref2.filename, cdn_keys = _ref2.cdn_keys;
  2138. return (cdn_keys = cdn_keys ? cdn_keys.filter((function(key) {
  2139. return key in cdn_map;
  2140. })) : Object.keys(cdn_map)).map((function(k) {
  2141. return cdn_map[k](name, ver, filename);
  2142. }));
  2143. }, runtime_div = document.createElement("div");
  2144. runtime_div.id = "bp_runtime_div", runtime_div.style.display = "none", document.getElementById(runtime_div.id) || document.body.appendChild(runtime_div);
  2145. var JSZip, DPlayer, QRCode, md5, count = 0, scripts = [], getModules = [], initIframe = function initIframe(name, ver, filename, getModule) {
  2146. count++, new RuntimeLib({
  2147. urls: urls({
  2148. name: name,
  2149. ver: ver,
  2150. filename: filename
  2151. }),
  2152. getModule: getModule
  2153. }).getModulePromise().then((function(script) {
  2154. scripts.push(script), getModules.push(getModule);
  2155. })).catch((function(err) {
  2156. console.error("[Runtime Library] Failed to load ".concat(name, " from CDN"), err);
  2157. })).finally((function() {
  2158. 0 == --count && (!function iframeInvoke(scripts, getModules) {
  2159. console.log("[Runtime Library] iframe invoke scripts, size =", scripts.length);
  2160. var scriptTags = scripts.map((function(code) {
  2161. return "<script>".concat(code, "<\/script>");
  2162. })).join(""), html = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Runtime Library</title></head><body>'.concat(scriptTags, "</body></html>"), blobUrl = URL.createObjectURL(new Blob([ html ], {
  2163. type: "text/html"
  2164. })), iframe = document.createElement("iframe"), clearIframe = function clearIframe() {
  2165. clearTimeout(timeoutId), URL.revokeObjectURL(blobUrl), iframe.remove();
  2166. }, timeoutId = setTimeout((function() {
  2167. console.error("[Runtime Library] Script loading timed out"), clearIframe();
  2168. }), 1e4);
  2169. iframe.src = blobUrl, iframe.onload = function() {
  2170. console.log("[Runtime Library] Script loaded in iframe");
  2171. var _step, _iterator = runtime_lib_createForOfIteratorHelper(getModules);
  2172. try {
  2173. for (_iterator.s(); !(_step = _iterator.n()).done; ) {
  2174. var getModule = _step.value;
  2175. try {
  2176. getModule(iframe.contentWindow);
  2177. } catch (err) {
  2178. console.error("[Runtime Library] Error in getModule:", err);
  2179. }
  2180. }
  2181. } catch (err) {
  2182. _iterator.e(err);
  2183. } finally {
  2184. _iterator.f();
  2185. }
  2186. clearIframe();
  2187. }, iframe.onerror = function() {
  2188. console.error("[Runtime Library] Failed to load script in iframe"), clearIframe();
  2189. }, runtime_div.appendChild(iframe);
  2190. }(scripts, getModules), console.log("[Runtime Library] iframe invoke complete"));
  2191. }));
  2192. };
  2193. function get_bili_player_id() {
  2194. return $("#bilibiliPlayer")[0] ? "#bilibiliPlayer" : $("#bilibili-player")[0] ? "#bilibili-player" : $("#edu-player")[0] ? "div.bpx-player-primary-area" : void 0;
  2195. }
  2196. function request_danmaku(options, cid) {
  2197. cid ? ajax({
  2198. url: "https://api.bilibili.com/x/v1/dm/list.so?oid=".concat(cid),
  2199. dataType: "text"
  2200. }).then((function(result) {
  2201. var result_dom = $(result.replace(/[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f]/g, ""));
  2202. if (result_dom) if (result_dom.find("d")[0]) {
  2203. var danmaku_data = result_dom.find("d").map((function(i, el) {
  2204. var item = $(el), p = item.attr("p").split(","), type = 0;
  2205. return "4" === p[1] ? type = 2 : "5" === p[1] && (type = 1), [ {
  2206. author: "",
  2207. time: parseFloat(p[0]),
  2208. type: type,
  2209. color: parseInt(p[3]),
  2210. id: "",
  2211. text: item.text()
  2212. } ];
  2213. })).get();
  2214. options.success(danmaku_data), setTimeout((function() {
  2215. danmaku_config();
  2216. }), 100);
  2217. } else options.error("未发现弹幕"); else options.error("弹幕获取失败");
  2218. })).catch((function() {
  2219. options.error("弹幕请求异常");
  2220. })) : options.error("cid未知,无法获取弹幕");
  2221. }
  2222. function bili_video_tag() {
  2223. return $("bwp-video")[0] ? "bwp-video" : $('video[class!="dplayer-video dplayer-video-current"]')[0] ? 'video[class!="dplayer-video dplayer-video-current"]' : void 0;
  2224. }
  2225. function bili_video_stop() {
  2226. var bili_video = $(bili_video_tag())[0];
  2227. bili_video && (bili_video.pause(), bili_video.currentTime = 0);
  2228. }
  2229. function recover_player() {
  2230. if (window.bp_dplayer) {
  2231. var bili_video = $(bili_video_tag())[0];
  2232. bili_video && bili_video.removeEventListener("play", bili_video_stop, !1), window.bp_dplayer.destroy(),
  2233. window.bp_dplayer = null, $("#bp_dplayer").remove(), window.bp_dplayer_2 && (window.bp_dplayer_2.destroy(),
  2234. window.bp_dplayer_2 = null, $("#bp_dplayer_2").remove()), $(get_bili_player_id()).show();
  2235. }
  2236. }
  2237. function danmaku_config() {
  2238. var style = "" + '<style id="dplayer_danmaku_style">\n .dplayer-danmaku .dplayer-danmaku-right.dplayer-danmaku-move {\n animation-duration: '.concat(parseFloat(config_config.danmaku_speed), "s;\n font-size: ").concat(parseInt(config_config.danmaku_fontsize), "px;\n }\n </style>");
  2239. $("#dplayer_danmaku_style")[0] && $("#dplayer_danmaku_style").remove(), $("body").append(style);
  2240. }
  2241. initIframe("jszip", "3.10.0", "jszip.min.js", (function(w) {
  2242. return JSZip = w.JSZip;
  2243. })), initIframe("flv.js", "1.6.2", "flv.min.js", (function(w) {
  2244. return w.flvjs;
  2245. })), function initLocal(name, ver, filename, getModule, handleScript) {
  2246. handleScript = handleScript || function(script) {
  2247. return script;
  2248. }, new RuntimeLib({
  2249. urls: urls({
  2250. name: name,
  2251. ver: ver,
  2252. filename: filename
  2253. }),
  2254. getModule: getModule
  2255. }).getModulePromise().then((function(script) {
  2256. var blob = new Blob([ handleScript(script) ], {
  2257. type: "text/javascript"
  2258. }), blob_url = URL.createObjectURL(blob), script_tag = document.createElement("script");
  2259. script_tag.src = blob_url, script_tag.onload = function() {
  2260. console.log("[Runtime Library] Loaded ".concat(name, " from local")), getModule(window),
  2261. URL.revokeObjectURL(blob_url);
  2262. }, script_tag.onerror = function() {
  2263. console.error("[Runtime Library] Failed to load ".concat(name, " from local")),
  2264. URL.revokeObjectURL(blob_url);
  2265. }, runtime_div.appendChild(script_tag);
  2266. })).catch((function(err) {
  2267. console.error("[Runtime Library] Failed to load ".concat(name, " from local"), err);
  2268. }));
  2269. }("dplayer", "1.26.0", "DPlayer.min.js", (function(w) {
  2270. return DPlayer = w.DPlayer;
  2271. }), (function(script) {
  2272. return script.replace('"About author"', '"About DIYgod"');
  2273. })), initIframe("qrcodejs", "1.0.0", "qrcode.min.js", (function(w) {
  2274. return QRCode = w.QRCode;
  2275. })), initIframe("blueimp-md5", "2.19.0", "js/md5.min.js", (function(w) {
  2276. return md5 = w.md5;
  2277. }));
  2278. var player = {
  2279. bili_video_tag: bili_video_tag,
  2280. recover_player: recover_player,
  2281. replace_player: function replace_player(url, url_2) {
  2282. recover_player();
  2283. var bili_video = $(bili_video_tag())[0];
  2284. bili_video_stop(), bili_video && bili_video.addEventListener("play", bili_video_stop, !1);
  2285. var bili_player_id = get_bili_player_id();
  2286. $("#bilibiliPlayer")[0] ? ($(bili_player_id).before('<div id="bp_dplayer" class="bilibili-player relative bilibili-player-no-cursor">'),
  2287. $(bili_player_id).hide()) : $("#bilibili-player")[0] ? ($(bili_player_id).before('<div id="bp_dplayer" class="bilibili-player relative bilibili-player-no-cursor" style="width:100%;height:100%;z-index:1000;"></div>'),
  2288. $(bili_player_id).hide()) : $("#edu-player")[0] ? ($(bili_player_id).before('<div id="bp_dplayer" style="width:100%;height:100%;z-index:1000;"></div>'),
  2289. $(bili_player_id).hide()) : MessageBox_alert('<div id="bp_dplayer" style="width:100%;height:100%;"></div>', (function() {
  2290. recover_player();
  2291. })), api.get_subtitle_url(0, (function dplayer_init() {
  2292. var subtitle_url = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "";
  2293. if (window.bp_dplayer = new DPlayer({
  2294. container: $("#bp_dplayer")[0],
  2295. mutex: !1,
  2296. volume: 1,
  2297. autoplay: !0,
  2298. video: {
  2299. url: url,
  2300. type: "auto"
  2301. },
  2302. subtitle: {
  2303. url: subtitle_url,
  2304. type: "webvtt",
  2305. fontSize: "35px",
  2306. bottom: "5%",
  2307. color: "#fff"
  2308. },
  2309. danmaku: !0,
  2310. apiBackend: {
  2311. read: function read(options) {
  2312. request_danmaku(options, video.base().cid());
  2313. },
  2314. send: function send(options) {
  2315. options.error("此脚本无法将弹幕同步到云端");
  2316. }
  2317. },
  2318. contextmenu: [ {
  2319. text: "脚本信息",
  2320. link: "https://github.com/injahow/user.js"
  2321. }, {
  2322. text: "脚本作者",
  2323. link: "https://injahow.com"
  2324. }, {
  2325. text: "恢复播放器",
  2326. click: function click() {
  2327. recover_player();
  2328. }
  2329. } ]
  2330. }), url_2 && "#" !== url_2) {
  2331. $("body").append('<div id="bp_dplayer_2" style="display:none;"></div>'), window.bp_dplayer_2 = new DPlayer({
  2332. container: $("#bp_dplayer_2")[0],
  2333. mutex: !1,
  2334. volume: 1,
  2335. autoplay: !1,
  2336. video: {
  2337. url: url_2,
  2338. type: "auto"
  2339. }
  2340. });
  2341. var _ref = [ window.bp_dplayer, window.bp_dplayer_2 ], bp_dplayer = _ref[0], bp_dplayer_2 = _ref[1];
  2342. bp_dplayer.on("play", (function() {
  2343. !bp_dplayer.paused && bp_dplayer_2.play();
  2344. })), bp_dplayer.on("playing", (function() {
  2345. !bp_dplayer.paused && bp_dplayer_2.play();
  2346. })), bp_dplayer.on("timeupdate", (function() {
  2347. Math.abs(bp_dplayer.video.currentTime - bp_dplayer_2.video.currentTime) > 1 && (bp_dplayer_2.pause(),
  2348. bp_dplayer_2.seek(bp_dplayer.video.currentTime)), !bp_dplayer.paused && bp_dplayer_2.play();
  2349. })), bp_dplayer.on("seeking", (function() {
  2350. bp_dplayer_2.pause(), bp_dplayer_2.seek(bp_dplayer.video.currentTime);
  2351. })), bp_dplayer.on("waiting", (function() {
  2352. bp_dplayer_2.pause(), bp_dplayer_2.seek(bp_dplayer.video.currentTime);
  2353. })), bp_dplayer.on("pause", (function() {
  2354. bp_dplayer_2.pause(), bp_dplayer_2.seek(bp_dplayer.video.currentTime);
  2355. })), bp_dplayer.on("suspend", (function() {
  2356. bp_dplayer_2.speed(bp_dplayer.video.playbackRate);
  2357. })), bp_dplayer.on("volumechange", (function() {
  2358. bp_dplayer_2.volume(bp_dplayer.video.volume), bp_dplayer_2.video.muted = bp_dplayer.video.muted;
  2359. }));
  2360. }
  2361. }));
  2362. },
  2363. danmaku: {
  2364. config: danmaku_config
  2365. }
  2366. };
  2367. function check_defineProperties(target, props) {
  2368. for (var i = 0; i < props.length; i++) {
  2369. var descriptor = props[i];
  2370. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0,
  2371. "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
  2372. }
  2373. }
  2374. var check = new (function() {
  2375. function Check() {
  2376. !function check_classCallCheck(instance, Constructor) {
  2377. if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
  2378. }(this, Check), this.href = "", this.aid = "", this.cid = "", this.q = "", this.epid = "",
  2379. this.locked = !1;
  2380. }
  2381. return function check_createClass(Constructor, protoProps, staticProps) {
  2382. return protoProps && check_defineProperties(Constructor.prototype, protoProps),
  2383. staticProps && check_defineProperties(Constructor, staticProps), Object.defineProperty(Constructor, "prototype", {
  2384. writable: !1
  2385. }), Constructor;
  2386. }(Check, [ {
  2387. key: "refresh",
  2388. value: function refresh() {
  2389. if (!this.locked) {
  2390. this.lock = !0, console.log("refresh..."), $("#video_download").hide(), $("#video_download_2").hide(),
  2391. player.recover_player();
  2392. try {
  2393. this.href = location.href;
  2394. var vb = video.base();
  2395. this.aid = vb.aid(), this.cid = vb.cid(), this.epid = vb.epid(), this.q = video.get_quality().q;
  2396. } catch (err) {
  2397. console.log(err);
  2398. } finally {
  2399. this.lock = !1;
  2400. }
  2401. }
  2402. }
  2403. } ]), Check;
  2404. }());
  2405. function download_createForOfIteratorHelper(o, allowArrayLike) {
  2406. var it = "undefined" != typeof Symbol && o[Symbol.iterator] || o["@@iterator"];
  2407. if (!it) {
  2408. if (Array.isArray(o) || (it = download_unsupportedIterableToArray(o)) || allowArrayLike && o && "number" == typeof o.length) {
  2409. it && (o = it);
  2410. var i = 0, F = function F() {};
  2411. return {
  2412. s: F,
  2413. n: function n() {
  2414. return i >= o.length ? {
  2415. done: !0
  2416. } : {
  2417. done: !1,
  2418. value: o[i++]
  2419. };
  2420. },
  2421. e: function e(_e) {
  2422. throw _e;
  2423. },
  2424. f: F
  2425. };
  2426. }
  2427. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2428. }
  2429. var err, normalCompletion = !0, didErr = !1;
  2430. return {
  2431. s: function s() {
  2432. it = it.call(o);
  2433. },
  2434. n: function n() {
  2435. var step = it.next();
  2436. return normalCompletion = step.done, step;
  2437. },
  2438. e: function e(_e2) {
  2439. didErr = !0, err = _e2;
  2440. },
  2441. f: function f() {
  2442. try {
  2443. normalCompletion || null == it.return || it.return();
  2444. } finally {
  2445. if (didErr) throw err;
  2446. }
  2447. }
  2448. };
  2449. }
  2450. function download_toConsumableArray(arr) {
  2451. return function download_arrayWithoutHoles(arr) {
  2452. if (Array.isArray(arr)) return download_arrayLikeToArray(arr);
  2453. }(arr) || function download_iterableToArray(iter) {
  2454. if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
  2455. }(arr) || download_unsupportedIterableToArray(arr) || function download_nonIterableSpread() {
  2456. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2457. }();
  2458. }
  2459. function download_unsupportedIterableToArray(o, minLen) {
  2460. if (o) {
  2461. if ("string" == typeof o) return download_arrayLikeToArray(o, minLen);
  2462. var n = Object.prototype.toString.call(o).slice(8, -1);
  2463. return "Object" === n && o.constructor && (n = o.constructor.name), "Map" === n || "Set" === n ? Array.from(o) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? download_arrayLikeToArray(o, minLen) : void 0;
  2464. }
  2465. }
  2466. function download_arrayLikeToArray(arr, len) {
  2467. (null == len || len > arr.length) && (len = arr.length);
  2468. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  2469. return arr2;
  2470. }
  2471. function rpc_type() {
  2472. return config_config.rpc_domain.match("https://") || config_config.rpc_domain.match(/localhost|127\.0\.0\.1/) ? "post" : "ariang";
  2473. }
  2474. var download_rpc_clicked = !1;
  2475. function download_rpc_post(video) {
  2476. download_rpc_post_all([ video ]);
  2477. }
  2478. function download_rpc_post_all(videos) {
  2479. if (download_rpc_clicked) message_Message_miaow(); else {
  2480. download_rpc_clicked = !0;
  2481. var data = download_toConsumableArray(videos);
  2482. ajax(function get_rpc_post(data) {
  2483. data instanceof Array || (data = data instanceof Object ? [ data ] : []);
  2484. var rpc = {
  2485. domain: config_config.rpc_domain,
  2486. port: config_config.rpc_port,
  2487. token: config_config.rpc_token,
  2488. dir: config_config.rpc_dir
  2489. };
  2490. return {
  2491. url: "".concat(rpc.domain, ":").concat(rpc.port, "/jsonrpc"),
  2492. type: "POST",
  2493. dataType: "json",
  2494. data: JSON.stringify(data.map((function(_ref4) {
  2495. var url = _ref4.url, filename = _ref4.filename, rpc_dir = _ref4.rpc_dir, param = {
  2496. out: filename,
  2497. header: [ "User-Agent: ".concat(window.navigator.userAgent), "Referer: ".concat(window.location.href) ]
  2498. };
  2499. return (rpc_dir || rpc.dir) && (param.dir = rpc_dir || rpc.dir), {
  2500. id: window.btoa("BParse_".concat(Date.now(), "_").concat(Math.random())),
  2501. jsonrpc: "2.0",
  2502. method: "aria2.addUri",
  2503. params: [ "token:".concat(rpc.token), [ url ], param ]
  2504. };
  2505. })))
  2506. };
  2507. }(data)).then((function(res) {
  2508. res.length === data.length ? message_Message_success("RPC请求成功") : message_Message_warning("请检查RPC参数");
  2509. })).catch((function() {
  2510. message_Message_error("请检查RPC服务配置");
  2511. })).finally((function() {
  2512. return download_rpc_clicked = !1;
  2513. })), message_Message_info("发送RPC下载请求");
  2514. }
  2515. }
  2516. function open_ariang(rpc) {
  2517. var hash_tag = rpc ? "#!/settings/rpc/set/".concat(rpc.domain.replace("://", "/"), "/").concat(rpc.port, "/jsonrpc/").concat(window.btoa(rpc.token)) : "", url = config_config.ariang_host + hash_tag, a = document.createElement("a");
  2518. a.setAttribute("target", "_blank"), a.setAttribute("onclick", "window.bp_aria2_window=window.open('".concat(url, "');")),
  2519. a.click();
  2520. }
  2521. function download_rpc_ariang_send(video) {
  2522. var bp_aria2_window = window.bp_aria2_window, time = 100;
  2523. bp_aria2_window && !bp_aria2_window.closed || (open_ariang(), time = 3e3), setTimeout((function() {
  2524. var bp_aria2_window = window.bp_aria2_window, task_hash = "#!/new/task?" + [ "url=".concat(encodeURIComponent(window.btoa(video.url))), "out=".concat(encodeURIComponent(video.filename)), "header=User-Agent:".concat(window.navigator.userAgent), "header=Referer:".concat(window.location.href) ].join("&");
  2525. bp_aria2_window && !bp_aria2_window.closed ? (bp_aria2_window.location.href = config_config.ariang_host + task_hash,
  2526. message_Message_success("发送RPC请求")) : message_Message_warning("AriaNG页面未打开");
  2527. }), time);
  2528. }
  2529. function download_rpc_ariang() {
  2530. for (var _len = arguments.length, videos = new Array(_len), _key = 0; _key < _len; _key++) videos[_key] = arguments[_key];
  2531. 0 != videos.length && (1 == videos.length && videos[0] instanceof Array ? download_rpc_ariang.apply(void 0, download_toConsumableArray(videos[0])) : (download_rpc_ariang_send(videos.pop()),
  2532. setTimeout((function() {
  2533. download_rpc_ariang.apply(void 0, videos);
  2534. }), 100)));
  2535. }
  2536. var download_blob_clicked = !1, need_show_progress = !0;
  2537. function download_blob(url, filename) {
  2538. if (download_blob_clicked) return message_Message_miaow(), void (need_show_progress = !0);
  2539. var xhr = new XMLHttpRequest;
  2540. xhr.open("get", url), xhr.responseType = "blob", xhr.onload = function() {
  2541. if (200 === this.status || 304 === this.status) {
  2542. if ("msSaveOrOpenBlob" in navigator) return void navigator.msSaveOrOpenBlob(this.response, filename);
  2543. var blob_url = URL.createObjectURL(this.response), a = document.createElement("a");
  2544. a.style.display = "none", a.href = blob_url, a.download = filename, a.click(), URL.revokeObjectURL(blob_url);
  2545. }
  2546. }, need_show_progress = !0, xhr.onprogress = function(evt) {
  2547. if (4 != this.state) {
  2548. var loaded = evt.loaded, tot = evt.total;
  2549. !function show_progress(_ref5) {
  2550. var total = _ref5.total, loaded = _ref5.loaded, percent = _ref5.percent;
  2551. need_show_progress && MessageBox_alert("文件大小:".concat(Math.floor(total / 1048576), "MB(").concat(total, "Byte)<br/>") + "已经下载:".concat(Math.floor(loaded / 1048576), "MB(").concat(loaded, "Byte)<br/>") + "当前进度:".concat(percent, "%<br/>下载中请勿操作浏览器,刷新或离开页面会导致下载取消!<br/>再次点击下载按钮可查看下载进度。"), (function() {
  2552. need_show_progress = !1;
  2553. })), total === loaded && (MessageBox_alert("下载完成,请等待浏览器保存!"), download_blob_clicked = !1);
  2554. }({
  2555. total: tot,
  2556. loaded: loaded,
  2557. percent: Math.floor(100 * loaded / tot)
  2558. });
  2559. }
  2560. }, xhr.send(), download_blob_clicked = !0, message_Message_info("准备开始下载");
  2561. }
  2562. function _download_danmaku_ass(cid, title) {
  2563. var return_type = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : null, callback = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : null;
  2564. ajax({
  2565. url: "https://api.bilibili.com/x/v1/dm/list.so?oid=".concat(cid),
  2566. dataType: "text"
  2567. }).then((function(result) {
  2568. var result_dom = $(result.replace(/[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f]/g, ""));
  2569. if (!result_dom || !result_dom.find("d")[0]) return "callback" === return_type && callback ? void callback() : void message_Message_warning("未发现弹幕");
  2570. var _step2, danmaku_data = result_dom.find("d").map((function(i, el) {
  2571. var item = $(el), p = item.attr("p").split(","), type = 0;
  2572. return "4" === p[1] ? type = 2 : "5" === p[1] && (type = 1), [ {
  2573. time: parseFloat(p[0]),
  2574. type: type,
  2575. color: parseInt(p[3]),
  2576. text: item.text()
  2577. } ];
  2578. })).get().sort((function(a, b) {
  2579. return a.time - b.time;
  2580. })), dialogue = function dialogue(danmaku, scroll_id, fix_id) {
  2581. var text = danmaku.text, time = danmaku.time, commands = [ 0 === danmaku.type ? function scrollCommand(top, left_a, left_b) {
  2582. return "\\move(".concat(left_a, ",").concat(top, ",").concat(left_b, ",").concat(top, ")");
  2583. }(50 * (1 + Math.floor(15 * Math.random())), 1920 + 50 * danmaku.text.length / 2, 0 - 50 * danmaku.text.length / 2) : function fixCommand(top, left) {
  2584. return "\\pos(".concat(left, ",").concat(top, ")");
  2585. }(50 * (1 + fix_id % 15), 960), function isWhite(color) {
  2586. return 16777215 === color;
  2587. }(danmaku.color) ? "" : function colorCommand(color) {
  2588. return "\\c&H".concat(((255 & color) << 16 | (color >> 8 & 255) << 8 | color >> 16 & 255).toString(16), "&");
  2589. }(danmaku.color) ], formatTime = function formatTime(seconds) {
  2590. var div = function div(i, j) {
  2591. return Math.floor(i / j);
  2592. }, pad = function pad(n) {
  2593. return n < 10 ? "0" + n : "" + n;
  2594. }, integer = Math.floor(seconds), hour = div(integer, 3600), minute = div(integer, 60) % 60, second = integer % 60, minorSecond = Math.floor(100 * (seconds - integer));
  2595. return "".concat(hour, ":").concat(pad(minute), ":").concat(pad(second), ".").concat(minorSecond);
  2596. }, fields = [ 0, formatTime(time), formatTime(time + (0 === danmaku.type ? 8 : 4)), "Medium", "", "0", "0", "0", "", "{" + commands.join("") + "}" + function encode(text) {
  2597. return text.replace(/\{/g, "{").replace(/\}/g, "}").replace(/\r|\n/g, "");
  2598. }(text) ];
  2599. return "Dialogue: " + fields.join(",");
  2600. }, content = [ "[Script Info]", "; Script generated by injahow/user.js", "; https://github.com/injahow/user.js", "Title: ".concat(title), "ScriptType: v4.00+", "PlayResX: ".concat(1920), "PlayResY: ".concat(1080), "Timer: 10.0000", "WrapStyle: 2", "ScaledBorderAndShadow: no", "", "[V4+ Styles]", "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding", "Style: Small,微软雅黑,36,&H66FFFFFF,&H66FFFFFF,&H66000000,&H66000000,0,0,0,0,100,100,0,0,1,1.2,0,5,0,0,0,0", "Style: Medium,微软雅黑,52,&H66FFFFFF,&H66FFFFFF,&H66000000,&H66000000,0,0,0,0,100,100,0,0,1,1.2,0,5,0,0,0,0", "Style: Large,微软雅黑,64,&H66FFFFFF,&H66FFFFFF,&H66000000,&H66000000,0,0,0,0,100,100,0,0,1,1.2,0,5,0,0,0,0", "Style: Larger,微软雅黑,72,&H66FFFFFF,&H66FFFFFF,&H66000000,&H66000000,0,0,0,0,100,100,0,0,1,1.2,0,5,0,0,0,0", "Style: ExtraLarge,微软雅黑,90,&H66FFFFFF,&H66FFFFFF,&H66000000,&H66000000,0,0,0,0,100,100,0,0,1,1.2,0,5,0,0,0,0", "", "[Events]", "Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text" ], fix_id = 0, _iterator2 = download_createForOfIteratorHelper(danmaku_data);
  2601. try {
  2602. for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
  2603. var danmaku = _step2.value;
  2604. 0 === danmaku.type ? 0 : fix_id++, content.push(dialogue(danmaku, 0, fix_id));
  2605. }
  2606. } catch (err) {
  2607. _iterator2.e(err);
  2608. } finally {
  2609. _iterator2.f();
  2610. }
  2611. var data = content.join("\n");
  2612. if (null === return_type || "file" === return_type) {
  2613. var blob_url = URL.createObjectURL(new Blob([ data ], {
  2614. type: "text/ass"
  2615. })), a = document.createElement("a");
  2616. a.style.display = "none", a.href = blob_url, a.download = title + ".ass", a.click(),
  2617. URL.revokeObjectURL(blob_url);
  2618. } else "callback" === return_type && callback && callback(data);
  2619. })).catch((function() {
  2620. "callback" === return_type && callback && callback();
  2621. }));
  2622. }
  2623. function download_danmaku_ass(cid, title) {
  2624. _download_danmaku_ass(cid, title, "file");
  2625. }
  2626. function download_subtitle_vtt() {
  2627. var p = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, file_name = arguments.length > 1 ? arguments[1] : void 0, download_subtitle = function download_subtitle(blob_url) {
  2628. if (blob_url) {
  2629. var a = document.createElement("a");
  2630. a.setAttribute("target", "_blank"), a.setAttribute("href", blob_url), a.setAttribute("download", file_name + ".vtt"),
  2631. a.click(), URL.revokeObjectURL(blob_url);
  2632. } else message_Message_warning("未发现字幕");
  2633. };
  2634. api.get_subtitle_url(p, download_subtitle);
  2635. }
  2636. function download_blob_zip(blob_data, filename) {
  2637. if (blob_data) {
  2638. var blob_url = URL.createObjectURL(blob_data), a = document.createElement("a");
  2639. a.setAttribute("target", "_blank"), a.setAttribute("href", blob_url), a.setAttribute("download", filename + ".zip"),
  2640. a.click(), URL.revokeObjectURL(blob_url);
  2641. }
  2642. }
  2643. function download_danmaku_ass_zip(videos, zip) {
  2644. if (videos) {
  2645. if (0 === videos.length) return 0 === Object.keys(zip.files).length ? void message_Message_warning("未发现弹幕") : void zip.generateAsync({
  2646. type: "blob"
  2647. }).then((function(data) {
  2648. return download_blob_zip(data, video.base().getFilename() + "_ass");
  2649. }));
  2650. var _videos$pop = videos.pop(), cid = _videos$pop.cid, filename = _videos$pop.filename;
  2651. _download_danmaku_ass(cid, filename, "callback", (function(data) {
  2652. data && zip.file(filename + ".ass", data), setTimeout((function() {
  2653. download_danmaku_ass_zip(videos, zip);
  2654. }), 1e3);
  2655. }));
  2656. }
  2657. }
  2658. function download_subtitle_vtt_zip(videos, zip) {
  2659. if (videos) {
  2660. if (0 === videos.length) return 0 === Object.keys(zip.files).length ? void message_Message_warning("未发现字幕") : void zip.generateAsync({
  2661. type: "blob"
  2662. }).then((function(data) {
  2663. return download_blob_zip(data, video.base().getFilename() + "_vtt");
  2664. }));
  2665. var _videos$pop2 = videos.pop(), p = _videos$pop2.p, filename = _videos$pop2.filename;
  2666. api.get_subtitle_data(p, (function(data) {
  2667. data && zip.file(filename + ".vtt", data), setTimeout((function() {
  2668. download_subtitle_vtt_zip(videos, zip);
  2669. }), 1e3);
  2670. }));
  2671. }
  2672. }
  2673. function format(url) {
  2674. return url ? url.match(".mp4|.m4s") ? ".mp4" : url.match(".flv") ? ".flv" : ".mp4" : "";
  2675. }
  2676. var _document$head$innerH, Download = {
  2677. url_format: format,
  2678. download: function download(url, filename, type) {
  2679. filename = filename.replace(/[\/\\*|]+/g, "-").replace(/:/g, ":").replace(/\?/g, "?").replace(/"/g, "'").replace(/</g, "《").replace(/>/g, "》"),
  2680. "blob" === type ? download_blob(url, filename) : "rpc" === type && function download_rpc(url, filename) {
  2681. var type = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "post";
  2682. "post" === type ? download_rpc_post({
  2683. url: url,
  2684. filename: filename
  2685. }) : "ariang" === type && download_rpc_ariang({
  2686. url: url,
  2687. filename: filename
  2688. });
  2689. }(url, filename, rpc_type());
  2690. },
  2691. download_all: function download_all() {
  2692. var vb = video.base(), _ref = [ video.get_quality().q, vb.total() ], q = _ref[0], total = _ref[1];
  2693. $("body").on("click", 'input[name="option_video"]', (function(event) {
  2694. function get_option_index(element) {
  2695. return element && parseInt(element.id.split("_")[1]) || 0;
  2696. }
  2697. if ($(this).is(":checked") ? $(this).parent().css("color", "rgba(0,0,0,1)") : $(this).parent().css("color", "rgba(0,0,0,0.5)"),
  2698. event.ctrlKey || event.altKey) {
  2699. var current_select_option_index = get_option_index(event.target), option_videos = download_toConsumableArray(document.getElementsByName("option_video"));
  2700. if (event.target.checked) for (var i = get_option_index(option_videos.filter((function(e) {
  2701. return e.checked && get_option_index(e) < current_select_option_index;
  2702. })).slice(-1)[0]); i < current_select_option_index; i++) option_videos[i].checked = !0,
  2703. option_videos[i].parentNode.style.color = "rgba(0,0,0,1)"; else for (var _i = get_option_index(option_videos.filter((function(e) {
  2704. return !e.checked && get_option_index(e) < current_select_option_index;
  2705. })).slice(-1)[0]); _i < current_select_option_index; _i++) option_videos[_i].checked = !1,
  2706. option_videos[_i].parentNode.style.color = "rgba(0,0,0,0.5)";
  2707. }
  2708. }));
  2709. for (var video_html = "", i = 0; i < total; i++) video_html += "" + '<label for="option_'.concat(i, '"><div style="color:rgba(0,0,0,0.5);">\n <input type="checkbox" id="option_').concat(i, '" name="option_video" value="').concat(i, '">\n P').concat(i + 1, " ").concat(vb.title(i + 1), "\n </div></label><hr>");
  2710. var all_checked = !1;
  2711. $("body").on("click", "button#checkbox_btn", (function() {
  2712. all_checked ? (all_checked = !1, $('input[name="option_video"]').prop("checked", all_checked),
  2713. $('input[name="option_video"]').parent().css("color", "rgba(0,0,0,0.5)")) : (all_checked = !0,
  2714. $('input[name="option_video"]').prop("checked", all_checked), $('input[name="option_video"]').parent().css("color", "rgb(0,0,0)"));
  2715. }));
  2716. var _step, option_support_html = "", _iterator = download_createForOfIteratorHelper(video.get_quality_support());
  2717. try {
  2718. for (_iterator.s(); !(_step = _iterator.n()).done; ) {
  2719. var item = _step.value;
  2720. option_support_html += '<option value="'.concat(item, '">').concat(videoQualityMap[item], "</option>");
  2721. }
  2722. } catch (err) {
  2723. _iterator.e(err);
  2724. } finally {
  2725. _iterator.f();
  2726. }
  2727. var msg = "" + '<div style="margin:2% 0;">\n <label>视频格式:</label>\n <select id="dl_format">\n <option value="mp4" selected>MP4</option>\n <option value="flv">FLV</option>\n <option value="dash">DASH</option>\n </select>\n &nbsp;&nbsp;无法设置MP4清晰度\n </div>\n <div style="margin:2% 0;">\n <label>视频质量:</label>\n <select id="dl_quality">\n '.concat(option_support_html, '\n </select>\n </div>\n <div style="margin:2% 0;">\n <label>下载选择:</label>\n <label style="color:rgba(0,0,0,1);">\n <input type="checkbox" id="dl_video" name="dl_option" checked="checked">\n <label for="dl_video">视频</label>\n </label>\n <label style="color:rgba(0,0,0,0.5);">\n <input type="checkbox" id="dl_subtitle" name="dl_option">\n <label for="dl_subtitle">字幕</label>\n </label>\n <label style="color:rgba(0,0,0,0.5);">\n <input type="checkbox" id="dl_danmaku" name="dl_option">\n <label for="dl_danmaku">弹幕</label>\n </label>\n </div>\n <div style="margin:2% 0;">\n <label>保存目录:</label>\n <input id="dl_rpc_dir" placeholder="').concat(config_config.rpc_dir || "为空使用默认目录", '"/>\n </div>\n <b>\n <span style="color:red;">为避免请求被拦截,设置了延时且不支持下载无法播放的视频;请勿频繁下载过多视频,可能触发风控导致不可再下载!</span>\n </b><br />\n <div style="height:240px;width:100%;overflow:auto;background:rgba(0,0,0,0.1);">\n ').concat(video_html, '\n </div>\n <div style="margin:2% 0;">\n <button id="checkbox_btn">全选</button>\n </div>');
  2728. function download_videos(video_tasks, i, videos) {
  2729. if (video_tasks.length) {
  2730. if (i >= video_tasks.length) return MessageBox_alert("视频地址请求完成!"), void ("post" === rpc_type() && videos.length > 0 && (download_rpc_post_all(videos),
  2731. videos.length = 0));
  2732. var task = video_tasks[i], msg = "第".concat(i + 1, "(").concat(i + 1, "/").concat(video_tasks.length, ")个视频");
  2733. MessageBox_alert("".concat(msg, ":获取中..."));
  2734. api.get_urls(task.p, task.q, task.format, (function success(res) {
  2735. if (setTimeout((function() {
  2736. download_videos(video_tasks, ++i, videos);
  2737. }), 4e3), !res.code) {
  2738. message_Message_success("请求成功" + (res.times ? "<br/>今日剩余请求次数".concat(res.times) : "")),
  2739. MessageBox_alert("".concat(msg, ":获取成功!"));
  2740. var _ref3 = [ res.url, rpc_type(), res.video, res.audio ], url = _ref3[0], type = _ref3[1], video_url = _ref3[2], audio_url = _ref3[3];
  2741. "post" === type ? ("dash" === task.format ? videos.push({
  2742. url: video_url,
  2743. filename: task.filename + format(video_url),
  2744. rpc_dir: task.rpc_dir
  2745. }, {
  2746. url: audio_url,
  2747. filename: task.filename + ".m4a",
  2748. rpc_dir: task.rpc_dir
  2749. }) : videos.push({
  2750. url: url,
  2751. filename: task.filename + format(url),
  2752. rpc_dir: task.rpc_dir
  2753. }), videos.length > 3 && (download_rpc_post_all(videos), videos.length = 0)) : "ariang" === type && ("dash" === task.format ? download_rpc_ariang({
  2754. url: video_url,
  2755. filename: task.filename + format(video_url)
  2756. }, {
  2757. url: audio_url,
  2758. filename: task.filename + ".m4a"
  2759. }) : download_rpc_ariang({
  2760. url: url,
  2761. filename: task.filename + format(url)
  2762. }));
  2763. }
  2764. }), (function error() {
  2765. download_videos(video_tasks, ++i, videos);
  2766. }));
  2767. }
  2768. }
  2769. MessageBox_confirm(msg, (function() {
  2770. for (var _ref2 = [ $("#dl_video").is(":checked"), $("#dl_subtitle").is(":checked"), $("#dl_danmaku").is(":checked"), $("#dl_format").val(), $("#dl_quality").val() || q, $("#dl_rpc_dir").val() ], dl_video = _ref2[0], dl_subtitle = _ref2[1], dl_danmaku = _ref2[2], dl_format = _ref2[3], dl_quality = _ref2[4], dl_rpc_dir = _ref2[5], videos = [], _i2 = 0; _i2 < total; _i2++) if ($("input#option_".concat(_i2)).is(":checked")) {
  2771. var p = _i2 + 1;
  2772. videos.push({
  2773. cid: vb.cid(p),
  2774. p: p,
  2775. q: dl_quality,
  2776. format: dl_format,
  2777. filename: vb.filename(p),
  2778. rpc_dir: dl_rpc_dir
  2779. });
  2780. }
  2781. dl_video && download_videos(videos, 0, []), dl_subtitle && (1 === videos.length ? download_subtitle_vtt(videos[0].p, videos[0].filename) : download_subtitle_vtt_zip([].concat(videos), new JSZip)),
  2782. dl_danmaku && (1 === videos.length ? download_danmaku_ass(videos[0].cid, videos[0].filename) : download_danmaku_ass_zip([].concat(videos), new JSZip));
  2783. })), $("#dl_quality").val(q), $("body").on("click", 'input[name="dl_option"]', (function() {
  2784. $(this).is(":checked") ? $(this).parent().css("color", "rgba(0,0,0,1)") : $(this).parent().css("color", "rgba(0,0,0,0.5)");
  2785. }));
  2786. },
  2787. download_danmaku_ass: download_danmaku_ass,
  2788. download_subtitle_vtt: download_subtitle_vtt,
  2789. open_ariang: open_ariang
  2790. }, config = '<div id="bp_config"> <div class="config-mark"></div> <div class="config-bg"> <span style="font-size:20px"> <b>bilibili视频下载 参数设置</b> <b> <a href="javascript:;" id="reset_config"> [重置] </a> <a style="text-decoration:underline" href="javascript:;" id="show_help">&lt;通知/帮助&gt;</a> </b> </span> <div style="margin:2% 0"> <label>请求地址:</label> <input id="base_api" style="width:30%"/>&nbsp;&nbsp;&nbsp;&nbsp; <label>请求方式:</label> <select id="request_type"> <option value="auto">自动判断</option> <option value="local">本地请求</option> <option value="remote">远程请求</option> </select><br/> <small>注意:普通使用请勿修改;默认使用混合请求</small> </div> <div style="margin:2% 0"> <label>视频格式:</label> <select id="format"> <option value="mp4">MP4</option> <option value="flv">FLV</option> <option value="dash">DASH</option> </select>&nbsp;&nbsp;&nbsp;&nbsp; <label>切换CDN:</label> <select id="host_key"> {{host_key_options}} </select><br/> <small>注意:无法选择MP4清晰度;建议特殊地区或播放异常时切换(自行选择合适线路)</small> </div> <div style="margin:2% 0"> <label>下载方式:</label> <select id="download_type"> <option value="a">URL链接</option> <option value="web">Web浏览器</option> <option value="blob">Blob请求</option> <option value="rpc">RPC接口</option> <option value="aria">Aria2命令</option> </select>&nbsp;&nbsp;&nbsp;&nbsp; <label>AriaNg地址:</label> <input id="ariang_host" style="width:30%"/><br/> <small>提示:建议使用RPC请求下载;非HTTPS或非本地RPC域名使用AriaNg下载</small> </div> <div style="margin:2% 0"> <label>RPC配置:[ 域名 : 端口 | 密钥 | 保存目录 ]</label><br/> <input id="rpc_domain" placeholder="ws://192.168.1.2" style="width:25%"/> : <input id="rpc_port" placeholder="6800" style="width:10%"/> | <input id="rpc_token" placeholder="未设置不填" style="width:15%"/> | <input id="rpc_dir" placeholder="留空使用默认目录" style="width:20%"/><br/> <small>注意:RPC默认使用Motrix(需要安装并运行)下载,其他软件请修改参数</small> </div> <div style="margin:2% 0"> <label>Aria2配置:</label> <label>最大连接数:</label> <select id="aria2c_connection_level"> <option value="min">1</option> <option value="mid">8</option> <option value="max">16</option> </select>&nbsp;&nbsp;&nbsp;&nbsp; <label>附加参数:</label> <input id="aria2c_addition_parameters" placeholder="见Aria2c文档" style="width:20%"/><br/> <small>说明:用于配置Aria命令下载方式的参数</small> </div> <div style="margin:2% 0"> <label>强制换源:</label> <select id="replace_force"> <option value="0">关闭</option> <option value="1">开启</option> </select> &nbsp;&nbsp;&nbsp;&nbsp; <label>弹幕速度:</label> <input id="danmaku_speed" style="width:5%"/> s &nbsp;&nbsp;&nbsp;&nbsp; <label>弹幕字号:</label> <input id="danmaku_fontsize" style="width:5%"/> px<br/> <small>说明:使用请求到的视频地址在DPlayer进行播放;弹幕速度为弹幕滑过DPlayer的时间</small> </div> <div style="margin:2% 0"> <label>自动下载:</label> <select id="auto_download"> <option value="0">关闭</option> <option value="1">开启</option> </select> &nbsp;&nbsp;&nbsp;&nbsp; <label>视频质量:</label> <select id="video_quality"> {{video_quality_options}} </select><br/> <small>说明:请求地址成功后将自动点击下载视频按钮</small> </div> <div style="margin:2% 0"> <label>授权状态:</label> <select id="auth" disabled="disabled"> <option value="0">未授权</option> <option value="1">已授权</option> </select> <a class="setting-context" href="javascript:;" id="show_login">扫码授权</a> <a class="setting-context" href="javascript:;" id="show_login_2">网页授权</a> <a class="setting-context" href="javascript:;" id="show_logout">取消授权</a> <a class="setting-context" href="javascript:;" id="show_login_help">这是什么?</a> </div> <br/> <div style="text-align:right"> <button class="setting-button" id="save_config">确定</button> </div> </div> <style>#bp_config{opacity:0;display:none;position:fixed;inset:0px;top:0;left:0;width:100%;height:100%;z-index:10000}#bp_config .config-bg{position:absolute;background:#fff;border-radius:10px;padding:20px;top:50%;left:50%;transform:translate(-50%,-50%);width:600px;z-index:10001}#bp_config .config-mark{width:100%;height:100%;position:fixed;top:0;left:0;background:rgba(0,0,0,.5);z-index:10000}#bp_config .setting-button{width:120px;height:40px;border-width:0;border-radius:3px;background:#1e90ff;cursor:pointer;outline:0;color:#fff;font-size:17px}#bp_config .setting-button:hover{background:#59f}#bp_config .setting-context{margin:0 1%;color:#00f}#bp_config .setting-context:hover{color:red}</style> </div> ';
  2791. function config_ownKeys(object, enumerableOnly) {
  2792. var keys = Object.keys(object);
  2793. if (Object.getOwnPropertySymbols) {
  2794. var symbols = Object.getOwnPropertySymbols(object);
  2795. enumerableOnly && (symbols = symbols.filter((function(sym) {
  2796. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  2797. }))), keys.push.apply(keys, symbols);
  2798. }
  2799. return keys;
  2800. }
  2801. function config_objectSpread(target) {
  2802. for (var i = 1; i < arguments.length; i++) {
  2803. var source = null != arguments[i] ? arguments[i] : {};
  2804. i % 2 ? config_ownKeys(Object(source), !0).forEach((function(key) {
  2805. config_defineProperty(target, key, source[key]);
  2806. })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : config_ownKeys(Object(source)).forEach((function(key) {
  2807. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  2808. }));
  2809. }
  2810. return target;
  2811. }
  2812. function config_defineProperty(obj, key, value) {
  2813. return key in obj ? Object.defineProperty(obj, key, {
  2814. value: value,
  2815. enumerable: !0,
  2816. configurable: !0,
  2817. writable: !0
  2818. }) : obj[key] = value, obj;
  2819. }
  2820. var config_config = {
  2821. base_api: "https://api.injahow.cn/bparse/",
  2822. request_type: "auto",
  2823. format: "mp4",
  2824. host_key: "0",
  2825. replace_force: "0",
  2826. download_type: "web",
  2827. rpc_domain: "http://localhost",
  2828. rpc_port: "16800",
  2829. rpc_token: "",
  2830. rpc_dir: "",
  2831. aria2c_connection_level: "min",
  2832. aria2c_addition_parameters: "",
  2833. ariang_host: "http://ariang.injahow.com/",
  2834. auto_download: "0",
  2835. video_quality: "0",
  2836. danmaku_speed: "15",
  2837. danmaku_fontsize: "22"
  2838. }, default_config = Object.assign({}, config_config), hostMap = {
  2839. local: (null === (_document$head$innerH = document.head.innerHTML.match(/up[\w-]+\.bilivideo\.com/)) || void 0 === _document$head$innerH ? void 0 : _document$head$innerH[0]) || "未发现本地CDN",
  2840. bd: "upos-sz-mirrorbd.bilivideo.com",
  2841. ks3: "upos-sz-mirrorks3.bilivideo.com",
  2842. ks3b: "upos-sz-mirrorks3b.bilivideo.com",
  2843. ks3c: "upos-sz-mirrorks3c.bilivideo.com",
  2844. ks32: "upos-sz-mirrorks32.bilivideo.com",
  2845. kodo: "upos-sz-mirrorkodo.bilivideo.com",
  2846. kodob: "upos-sz-mirrorkodob.bilivideo.com",
  2847. cos: "upos-sz-mirrorcos.bilivideo.com",
  2848. cosb: "upos-sz-mirrorcosb.bilivideo.com",
  2849. bos: "upos-sz-mirrorbos.bilivideo.com",
  2850. wcs: "upos-sz-mirrorwcs.bilivideo.com",
  2851. wcsb: "upos-sz-mirrorwcsb.bilivideo.com",
  2852. hw: "upos-sz-mirrorhw.bilivideo.com",
  2853. hwb: "upos-sz-mirrorhwb.bilivideo.com",
  2854. upbda2: "upos-sz-upcdnbda2.bilivideo.com",
  2855. upws: "upos-sz-upcdnws.bilivideo.com",
  2856. uptx: "upos-sz-upcdntx.bilivideo.com",
  2857. uphw: "upos-sz-upcdnhw.bilivideo.com",
  2858. js: "upos-tf-all-js.bilivideo.com",
  2859. hk: "cn-hk-eq-bcache-01.bilivideo.com",
  2860. akamai: "upos-hz-mirrorakam.akamaized.net"
  2861. }, videoQualityMap = {
  2862. 127: "8K 超高清",
  2863. 120: "4K 超清",
  2864. 116: "1080P 60帧",
  2865. 112: "1080P 高码率",
  2866. 80: "1080P 高清",
  2867. 74: "720P 60帧",
  2868. 64: "720P 高清",
  2869. 48: "720P 高清(MP4)",
  2870. 32: "480P 清晰",
  2871. 16: "360P 流畅"
  2872. }, help_clicked = !1, config_functions = {
  2873. save_config: function save_config() {
  2874. var old_config;
  2875. try {
  2876. old_config = JSON.parse(store.get("config_str"));
  2877. } catch (err) {
  2878. old_config = {};
  2879. } finally {
  2880. old_config = config_objectSpread(config_objectSpread({}, default_config), old_config);
  2881. }
  2882. var config_str = {};
  2883. for (var key in default_config) config_config[key] !== default_config[key] && (config_str[key] = config_config[key]);
  2884. store.set("config_str", JSON.stringify(config_str));
  2885. for (var _i = 0, _arr = [ "base_api", "format", "video_quality" ]; _i < _arr.length; _i++) {
  2886. var _key = _arr[_i];
  2887. if (config_config[_key] !== old_config[_key]) {
  2888. $("#video_download").hide(), $("#video_download_2").hide();
  2889. break;
  2890. }
  2891. }
  2892. config_config.host_key !== old_config.host_key && (check.refresh(), $("#video_url").attr("href", "#"),
  2893. $("#video_url_2").attr("href", "#")), config_config.rpc_domain !== old_config.rpc_domain && (config_config.rpc_domain.match("https://") || config_config.rpc_domain.match(/(localhost|127\.0\.0\.1)/) || MessageBox_alert("检测到当前RPC不是localhost本地接口,即将跳转到AriaNg网页控制台页面;请查看控制台RPC接口参数是否正确,第一次加载可能较慢请耐心等待;配置好后即可使用脚本进行远程下载,使用期间不用关闭AriaNg页面!", (function() {
  2894. Download.open_ariang({
  2895. domain: config_config.rpc_domain,
  2896. port: config_config.rpc_port,
  2897. token: config_config.rpc_token
  2898. });
  2899. })));
  2900. for (var _i2 = 0, _arr2 = [ "danmaku_speed", "danmaku_fontsize" ]; _i2 < _arr2.length; _i2++) {
  2901. var _key2 = _arr2[_i2];
  2902. if (config_config[_key2] !== old_config[_key2]) {
  2903. player.danmaku.config();
  2904. break;
  2905. }
  2906. }
  2907. $("#bp_config").hide(), $("#bp_config").css("opacity", 0), scroll_scroll.show();
  2908. },
  2909. reset_config: function reset_config() {
  2910. for (var key in default_config) config_config[key] = default_config[key], $("#".concat(key)).val(default_config[key]);
  2911. },
  2912. show_help: function show_help() {
  2913. help_clicked ? message_Message_miaow() : (help_clicked = !0, ajax({
  2914. url: "".concat(config_config.base_api).concat(config_config.base_api.endsWith("/") ? "" : "/", "auth/?act=help"),
  2915. dataType: "text"
  2916. }).then((function(res) {
  2917. res ? MessageBox_alert(res) : message_Message_warning("获取失败");
  2918. })).finally((function() {
  2919. help_clicked = !1;
  2920. })));
  2921. },
  2922. show_login: function show_login() {
  2923. auth.login("1");
  2924. },
  2925. show_login_2: function show_login_2() {
  2926. auth.login("0");
  2927. },
  2928. show_logout: function show_logout() {
  2929. auth.logout();
  2930. },
  2931. show_login_help: function show_login_help() {
  2932. MessageBox_confirm("进行授权之后在远程请求时拥有用户账号原有的权限,例如能够获取用户已经付费或承包的番剧,是否需要授权?", (function() {
  2933. auth.login();
  2934. }));
  2935. }
  2936. };
  2937. function getCookie(cookieName) {
  2938. for (var cookieList = document.cookie.split(";"), i = 0; i < cookieList.length; ++i) {
  2939. var arr = cookieList[i].split("=");
  2940. if (cookieName === arr[0].trim()) return arr[1];
  2941. }
  2942. return null;
  2943. }
  2944. function auth_ownKeys(object, enumerableOnly) {
  2945. var keys = Object.keys(object);
  2946. if (Object.getOwnPropertySymbols) {
  2947. var symbols = Object.getOwnPropertySymbols(object);
  2948. enumerableOnly && (symbols = symbols.filter((function(sym) {
  2949. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  2950. }))), keys.push.apply(keys, symbols);
  2951. }
  2952. return keys;
  2953. }
  2954. function auth_objectSpread(target) {
  2955. for (var i = 1; i < arguments.length; i++) {
  2956. var source = null != arguments[i] ? arguments[i] : {};
  2957. i % 2 ? auth_ownKeys(Object(source), !0).forEach((function(key) {
  2958. auth_defineProperty(target, key, source[key]);
  2959. })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : auth_ownKeys(Object(source)).forEach((function(key) {
  2960. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  2961. }));
  2962. }
  2963. return target;
  2964. }
  2965. function auth_defineProperty(obj, key, value) {
  2966. return key in obj ? Object.defineProperty(obj, key, {
  2967. value: value,
  2968. enumerable: !0,
  2969. configurable: !0,
  2970. writable: !0
  2971. }) : obj[key] = value, obj;
  2972. }
  2973. function auth_defineProperties(target, props) {
  2974. for (var i = 0; i < props.length; i++) {
  2975. var descriptor = props[i];
  2976. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0,
  2977. "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
  2978. }
  2979. }
  2980. var Auth = function() {
  2981. function Auth() {
  2982. !function auth_classCallCheck(instance, Constructor) {
  2983. if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
  2984. }(this, Auth), this.auth_clicked = !1, this.auth_window = null, this.TV_KEY = "4409e2ce8ffd12b8",
  2985. this.TV_SEC = "59b43e04ad6965f34319062b478f83dd";
  2986. }
  2987. return function auth_createClass(Constructor, protoProps, staticProps) {
  2988. return protoProps && auth_defineProperties(Constructor.prototype, protoProps), staticProps && auth_defineProperties(Constructor, staticProps),
  2989. Object.defineProperty(Constructor, "prototype", {
  2990. writable: !1
  2991. }), Constructor;
  2992. }(Auth, [ {
  2993. key: "hasAuth",
  2994. value: function hasAuth() {
  2995. return store.get("auth_id") && store.get("auth_sec");
  2996. }
  2997. }, {
  2998. key: "checkLoginStatus",
  2999. value: function checkLoginStatus() {
  3000. var _this = this, _ref = [ store.get("auth_id"), store.get("auth_sec"), store.get("access_key"), store.get("auth_time") || 0 ], auth_id = _ref[0], auth_sec = _ref[1], access_key = _ref[2], auth_time = _ref[3];
  3001. if (auth_id || auth_sec) {
  3002. if (config_config.base_api !== store.get("pre_base_api") || Date.now() - parseInt(auth_time) > 864e5) {
  3003. if (!access_key) return message_Message_info("授权已失效"), void this.reLogin();
  3004. ajax({
  3005. url: "https://passport.bilibili.com/api/oauth?access_key=".concat(access_key),
  3006. type: "GET",
  3007. dataType: "json"
  3008. }).then((function(res) {
  3009. if (res.code) return message_Message_info("授权已过期,准备重新授权"), void _this.reLogin();
  3010. store.set("auth_time", Date.now()), ajax({
  3011. url: "".concat(config_config.base_api).concat(config_config.base_api.endsWith("/") ? "" : "/", "auth/?act=check&auth_id=").concat(auth_id, "&auth_sec=").concat(auth_sec),
  3012. type: "GET",
  3013. dataType: "json"
  3014. }).then((function(res) {
  3015. res.code && (message_Message_info("检查失败,准备重新授权"), _this.reLogin());
  3016. }));
  3017. }));
  3018. }
  3019. store.set("pre_base_api", config_config.base_api);
  3020. }
  3021. }
  3022. }, {
  3023. key: "makeAPIData",
  3024. value: function makeAPIData(param, sec) {
  3025. return auth_objectSpread(auth_objectSpread({}, param), {}, {
  3026. sign: md5("".concat(Object.entries(param).map((function(e) {
  3027. return "".concat(e[0], "=").concat(e[1]);
  3028. })).join("&")).concat(sec))
  3029. });
  3030. }
  3031. }, {
  3032. key: "_login",
  3033. value: function _login(resolve) {
  3034. var _this2 = this;
  3035. this.auth_clicked ? message_Message_miaow() : (this.auth_clicked = !0, ajax({
  3036. url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/auth_code",
  3037. type: "POST",
  3038. data: this.makeAPIData({
  3039. appkey: this.TV_KEY,
  3040. csrf: getCookie("bili_jct") || "",
  3041. local_id: "0",
  3042. ts: Date.now()
  3043. }, this.TV_SEC)
  3044. }).then(resolve).catch((function() {
  3045. return _this2.auth_clicked = !1;
  3046. })));
  3047. }
  3048. }, {
  3049. key: "login",
  3050. value: function login() {
  3051. var useApp = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "1", do_login = "1" === useApp ? this.loginApp.bind(this) : this.loginWeb.bind(this);
  3052. store.get("auth_id") ? MessageBox_confirm("发现授权记录,是否重新授权?", do_login) : do_login();
  3053. }
  3054. }, {
  3055. key: "reLogin",
  3056. value: function reLogin() {
  3057. this.logout(), store.set("auth_time", "0"), this.loginApp();
  3058. }
  3059. }, {
  3060. key: "loginApp",
  3061. value: function loginApp() {
  3062. var _this3 = this;
  3063. this._login((function(res) {
  3064. if (res && !res.code) {
  3065. var _res$data = res.data, url = _res$data.url, auth_code = _res$data.auth_code, is_login = 0, box = MessageBox_alert('<p>请使用<a href="https://app.bilibili.com/" target="_blank">哔哩哔哩客户端</a>扫码登录(不可用)</p><div id="login_qrcode"></div>', (function() {
  3066. is_login || message_Message_info("登陆失败!"), clearInterval(timer), _this3.auth_clicked = !1;
  3067. }));
  3068. new QRCode(document.getElementById("login_qrcode"), url);
  3069. var timer = setInterval((function() {
  3070. _ajax({
  3071. url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/poll",
  3072. type: "POST",
  3073. data: _this3.makeAPIData({
  3074. appkey: _this3.TV_KEY,
  3075. auth_code: auth_code,
  3076. csrf: getCookie("bili_jct") || "",
  3077. local_id: "0",
  3078. ts: Date.now().toString()
  3079. }, _this3.TV_SEC)
  3080. }).then((function(res) {
  3081. !res.code && res.data ? (console.log("login success"), is_login = 1, _this3.doAuth(res.data),
  3082. box.affirm()) : 86038 === res.code && box.affirm();
  3083. }));
  3084. }), 3e3);
  3085. }
  3086. }));
  3087. }
  3088. }, {
  3089. key: "loginWeb",
  3090. value: function loginWeb() {
  3091. var _this4 = this;
  3092. this._login((function(res) {
  3093. if (res && !res.code) {
  3094. var _res$data2 = res.data, url = _res$data2.url, auth_code = _res$data2.auth_code;
  3095. _this4.auth_window = window.open(url);
  3096. var is_login = 0, timer = setInterval((function() {
  3097. if (!_this4.auth_window || _this4.auth_window.closed) return clearInterval(timer),
  3098. _this4.auth_clicked = !1, void (is_login || message_Message_info("登陆失败!"));
  3099. _ajax({
  3100. url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/poll",
  3101. type: "POST",
  3102. data: _this4.makeAPIData({
  3103. appkey: _this4.TV_KEY,
  3104. auth_code: auth_code,
  3105. csrf: getCookie("bili_jct") || "",
  3106. local_id: "0",
  3107. ts: Date.now().toString()
  3108. }, _this4.TV_SEC)
  3109. }).then((function(res) {
  3110. !res.code && res.data ? (console.log("login success"), _this4.doAuth(res.data),
  3111. is_login = 1, _this4.auth_window.close()) : 86038 === res.code && _this4.auth_window.close();
  3112. })).catch((function() {
  3113. return _this4.auth_window.close();
  3114. }));
  3115. }), 3e3);
  3116. }
  3117. }));
  3118. }
  3119. }, {
  3120. key: "logout",
  3121. value: function logout() {
  3122. var _this5 = this;
  3123. if (store.get("auth_id")) if (this.auth_clicked) message_Message_miaow(); else {
  3124. var _ref2 = [ store.get("auth_id"), store.get("auth_sec") ], auth_id = _ref2[0], auth_sec = _ref2[1];
  3125. ajax({
  3126. url: "".concat(config_config.base_api).concat(config_config.base_api.endsWith("/") ? "" : "/", "auth/?act=logout&auth_id=").concat(auth_id, "&auth_sec=").concat(auth_sec),
  3127. type: "GET",
  3128. dataType: "json"
  3129. }).then((function(res) {
  3130. res.code ? message_Message_warning("注销失败") : (message_Message_success("注销成功"), store.set("auth_id", ""),
  3131. store.set("auth_sec", ""), store.set("auth_time", "0"), store.set("access_key", ""),
  3132. $("#auth").val("0"));
  3133. })).finally((function() {
  3134. return _this5.auth_clicked = !1;
  3135. }));
  3136. } else MessageBox_alert("没有发现授权记录");
  3137. }
  3138. }, {
  3139. key: "doAuth",
  3140. value: function doAuth(param) {
  3141. var _this6 = this;
  3142. this.auth_window && !this.auth_window.closed && (this.auth_window.close(), this.auth_window = null),
  3143. ajax({
  3144. url: "".concat(config_config.base_api).concat(config_config.base_api.endsWith("/") ? "" : "/", "auth/?act=login&").concat(Object.entries({
  3145. auth_id: store.get("auth_id"),
  3146. auth_sec: store.get("auth_sec")
  3147. }).map((function(e) {
  3148. return "".concat(e[0], "=").concat(e[1]);
  3149. })).join("&")),
  3150. type: "POST",
  3151. contentType: "application/json",
  3152. data: JSON.stringify(auth_objectSpread({}, param))
  3153. }).then((function(res) {
  3154. res.code ? message_Message_warning("授权失败") : (message_Message_success("授权成功"), res.auth_id && res.auth_sec && (store.set("auth_id", res.auth_id),
  3155. store.set("auth_sec", res.auth_sec)), store.set("access_key", param.access_token),
  3156. store.set("auth_time", Date.now()), $("#auth").val("1"));
  3157. })).finally((function() {
  3158. return _this6.auth_clicked = !1;
  3159. }));
  3160. }
  3161. } ]), Auth;
  3162. }(), auth = new Auth, more_style = "<style>.more{float:right;padding:1px;cursor:pointer;color:#757575;font-size:16px;transition:all .3s;position:relative;text-align:center}.more:hover .more-ops-list{display:block}.more-ops-list{display:none;position:absolute;width:80px;left:-15px;z-index:30;text-align:center;padding:10px 0;background:#fff;border:1px solid #e5e9ef;box-shadow:0 2px 4px 0 rgba(0,0,0,.14);border-radius:2px;font-size:14px;color:#222}.more-ops-list li{position:relative;height:34px;line-height:34px;cursor:pointer;transition:all .3s}.more-ops-list li:hover{color:#00a1d6;background:#e7e7e7}</style> ", btn_list = {
  3163. setting_btn: "脚本设置",
  3164. bilibili_parse: "请求地址",
  3165. video_download: "下载视频",
  3166. video_download_2: "下载音频",
  3167. video_download_all: "批量下载",
  3168. more: {
  3169. download_danmaku: "下载弹幕",
  3170. download_subtitle: "下载字幕"
  3171. }
  3172. }, download_svg = '<svg class width="28" height="28" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 32 32" xml:space="preserve">\n <path fill="#757575" d="M16.015,0C7.186,0,0.03,7.157,0.03,15.985 S7.186,31.97,16.015,31.97S32,24.814,32,15.985S24.843,0,16.015,0z"/>\n <path style="fill:#FFFFFF;" d="M16.942,23.642H9.109C8.496,23.642,8,24.17,8,24.821v0C8,25.472,8.496,26,9.109,26h14.783 C24.504,26,25,25.472,25,24.821v0c0-0.651-0.496-1.179-1.109-1.179H16.942z"/>\n <path style="fill:#FFFFFF;" d="M8.798,16.998l6.729,6.33c0.398,0.375,1.029,0.375,1.427,0l6.729-6.33 c0.666-0.627,0.212-1.726-0.714-1.726h-3.382c-0.568,0-1.028-0.449-1.028-1.003V8.003C18.56,7.449,18.099,7,17.532,7h-2.582 c-0.568,0-1.028,0.449-1.028,1.003v6.266c0,0.554-0.46,1.003-1.028,1.003H9.511C8.586,15.273,8.132,16.372,8.798,16.998z"/>\n </svg>', svg_map = {
  3173. setting_btn: '<svg class width="28" height="28" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 32 32" xml:space="preserve">\n <path fill="#757575" style="stroke-miterlimit:10;" d="M16,29.5L16,29.5c-0.828,0-1.5-0.672-1.5-1.5V4c0-0.828,0.672-1.5,1.5-1.5h0 c0.828,0,1.5,0.672,1.5,1.5v24C17.5,28.828,16.828,29.5,16,29.5z"/>\n <path fill="#757575" style="stroke-miterlimit:10;" d="M29.5,16L29.5,16c0,0.828-0.672,1.5-1.5,1.5H4c-0.828,0-1.5-0.672-1.5-1.5v0 c0-0.828,0.672-1.5,1.5-1.5h24C28.828,14.5,29.5,15.172,29.5,16z"/>\n </svg>',
  3174. bilibili_parse: '<svg class width="28" height="28" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 32 32" xml:space="preserve">\n <path fill="#757575" d="M28.282,13.508c-0.623-6.932-6.627-12.036-13.41-11.399C8.947,2.665,4.254,7.465,3.716,13.521 c0.786,0.404,1.283,1.226,1.284,2.126v4.157c-0.023,0.565-0.49,1.004-1.043,0.98c-0.521-0.022-0.938-0.448-0.959-0.98v-4.157 c0-0.188-0.113-0.452-0.508-0.452s-0.492,0.275-0.492,0.452v8.176c0,2.446,1.94,4.428,4.333,4.428c0,0,0,0,0,0h7.191 c0.552-1.396,2.107-2.07,3.473-1.505s2.025,2.154,1.473,3.549c-0.552,1.396-2.107,2.07-3.473,1.505 c-0.67-0.277-1.202-0.82-1.473-1.505h-7.19c-3.497,0-6.332-2.897-6.333-6.471l0,0v-8.178c0-1.077,0.706-2.02,1.723-2.303C2.429,5.285,9.393-0.662,17.278,0.059c6.952,0.636,12.445,6.297,13.009,13.407c1.032,0.404,1.713,1.416,1.712,2.545v4.088 c-0.038,1.505-1.262,2.694-2.735,2.656c-1.42-0.037-2.562-1.205-2.599-2.656l0,0v-4.085C26.667,14.924,27.302,13.939,28.282,13.508zM11.334,14.653c-1.105,0-2-0.915-2-2.044s0.896-2.044,2-2.044l0,0c1.105,0,2,0.915,2,2.044S12.439,14.653,11.334,14.653z M20.666,14.653c-1.105,0-2-0.915-2-2.044s0.896-2.044,2-2.044l0,0c1.105,0,2,0.915,2,2.044S21.771,14.653,20.666,14.653z M13.629,21.805c-2.167,0-3.962-1.653-3.962-3.748c0-0.564,0.448-1.022,1-1.022c0.552,0,1,0.458,1,1.022 c0,0.916,0.856,1.704,1.962,1.704c0.612,0.012,1.198-0.253,1.602-0.723c0.352-0.433,0.982-0.493,1.406-0.132 c0,0,0.001,0.001,0.001,0.001c0.047,0.039,0.09,0.083,0.128,0.131c0.404,0.47,0.99,0.734,1.602,0.723 c1.106,0,1.964-0.788,1.964-1.704c0-0.564,0.448-1.022,1-1.022c0.552,0,1,0.458,1,1.022c0,2.095-1.797,3.748-3.964,3.748 c-0.844,0.003-1.67-0.256-2.368-0.742C15.302,21.55,14.475,21.809,13.629,21.805z M29.332,15.333c-0.368,0-0.666,0.305-0.666,0.68 v4.088c-0.001,0.376,0.297,0.681,0.665,0.681c0.368,0.001,0.666-0.304,0.666-0.679c0-0.001,0-0.001,0-0.002v-4.088 c0.002-0.374-0.293-0.678-0.659-0.68c-0.001,0-0.002,0-0.003,0H29.332z"/>\n </svg>',
  3175. video_download: download_svg,
  3176. video_download_2: download_svg,
  3177. video_download_all: download_svg
  3178. };
  3179. function showVideoToolbar(toolbar_id) {
  3180. var toolbar_obj = $("#".concat(toolbar_id)), toolbar_obj_2 = toolbar_obj.clone();
  3181. toolbar_obj_2.attr("id", "".concat(toolbar_id, "_2"));
  3182. var left = toolbar_obj_2.find(".video-toolbar-left"), right = toolbar_obj_2.find(".video-toolbar-right");
  3183. left.children().remove(), right.children().remove(), Object.keys(btn_list).map((function(key) {
  3184. if ("more" !== key) {
  3185. var item = toolbar_obj.find(".toolbar-left-item-wrap").eq(0).clone();
  3186. item.attr("id", key);
  3187. var svg = svg_map[key].replaceAll("#757575", "currentColor").replace("class", 'class="'.concat(item.find("svg").attr("class"), '"')), span = item.find("span").text(btn_list[key]), item_div = item.find("div").eq(0);
  3188. item_div.attr("title", btn_list[key]), item_div.removeClass("on"), item_div.children().remove(),
  3189. item_div.append(svg).append(span), left.append(item);
  3190. } else {
  3191. var more_map = btn_list[key], el = "" + '<div class="more">更多<div class="more-ops-list">\n <ul>'.concat(Object.keys(more_map).map((function(key) {
  3192. return '<li><span id="'.concat(key, '">').concat(more_map[key], "</span></li>");
  3193. })).join(""), "</ul>\n </div>");
  3194. right.append(el + more_style);
  3195. }
  3196. })), toolbar_obj.after(toolbar_obj_2);
  3197. }
  3198. function initToolbar() {
  3199. if ($("#arc_toolbar_report")[0]) showVideoToolbar("arc_toolbar_report"); else if ($("#playlistToolbar")[0]) showVideoToolbar("playlistToolbar"); else if ($("#videoToolbar")[0]) !function showFestivalToolbar(toolbar_id) {
  3200. var toolbar_obj = $("#".concat(toolbar_id)), toolbar_obj_2 = toolbar_obj.clone();
  3201. toolbar_obj_2.attr("id", "".concat(toolbar_id, "_2"));
  3202. var left = toolbar_obj_2.find(".video-toolbar-content_left"), right = toolbar_obj_2.find(".video-toolbar-content_right");
  3203. toolbar_obj_2.find(".video-toobar_title").remove(), left.children().remove();
  3204. var watchlater = right.find(".watchlater").clone();
  3205. right.children().remove(), right.append(watchlater), toolbar_obj_2.find(".video-desc-wrapper").remove(),
  3206. Object.keys(btn_list).map((function(key) {
  3207. if ("more" !== key) {
  3208. var item = toolbar_obj.find(".video-toolbar-content_item").eq(0).clone();
  3209. item.attr("id", key), item.attr("title", btn_list[key]);
  3210. var svg = svg_map[key].replaceAll("#757575", "currentColor"), item_icon = item.find(".content-item_icon").eq(0);
  3211. item_icon.removeClass("ic_like"), item_icon.html(svg), item.html(""), item.append(item_icon),
  3212. item.append(btn_list[key]), left.append(item);
  3213. } else {
  3214. var list = watchlater.find(".more-list"), list_li = list.children().eq(0);
  3215. list.children().remove();
  3216. var more_map = btn_list[key];
  3217. Object.keys(more_map).map((function(key) {
  3218. var li = list_li.clone();
  3219. li.html('<span id="'.concat(key, '">').concat(more_map[key], "</span>")), list.append(li);
  3220. }));
  3221. }
  3222. })), toolbar_obj.after(toolbar_obj_2);
  3223. }("videoToolbar"); else if ($(".toolbar")[0]) !function showBangumiToolbar(toolbar_class) {
  3224. var toolbar_obj = $(".".concat(toolbar_class)).eq(0), toolbar_obj_2 = toolbar_obj.clone(), left = toolbar_obj_2.find(".toolbar-left"), right = toolbar_obj_2.find(".toolbar-right");
  3225. left.children().remove(), right.children().remove(), Object.keys(btn_list).map((function(key) {
  3226. if ("more" !== key) {
  3227. var item = toolbar_obj.find(".toolbar-left").children().eq(0).clone();
  3228. item.attr("id", key), item.attr("title", btn_list[key]);
  3229. var svg = svg_map[key].replaceAll("#757575", "currentColor").replace("class", 'class="'.concat(item.find("svg").attr("class"), '"')), span = item.find("span").text(btn_list[key]);
  3230. item.children().remove(), item.append(svg).append(span), left.append(item);
  3231. } else {
  3232. var more_map = btn_list[key], el = "" + '<div class="more">更多<div class="more-ops-list">\n <ul>'.concat(Object.keys(more_map).map((function(key) {
  3233. return '<li><span id="'.concat(key, '">').concat(more_map[key], "</span></li>");
  3234. })).join(""), "</ul>\n </div>");
  3235. right.append(el + more_style);
  3236. }
  3237. })), toolbar_obj.after(toolbar_obj_2);
  3238. }("toolbar"); else if ($(".edu-play-left")[0]) {
  3239. var toolbar_obj = $(".edu-play-left").children().eq(1), toolbar_class = toolbar_obj.attr("class"), span_class = toolbar_obj.children().eq(0).attr("class"), span_class_svg = toolbar_obj.children().eq(0).children().eq(0).attr("class"), span_class_text = toolbar_obj.children().eq(0).children().eq(1).attr("class");
  3240. toolbar_obj.after(function make_toolbar_bangumi(main_class_name, sub_class_names) {
  3241. var toolbar_elements = Object.keys(btn_list).map((function(key) {
  3242. if ("more" === key) {
  3243. var more_map = btn_list[key];
  3244. return "" + '<div class="more">更多<div class="more-ops-list">\n <ul>'.concat(Object.keys(more_map).map((function(key) {
  3245. return function more_element(id, name) {
  3246. return '<li><span id="'.concat(id, '">').concat(name, "</span></li>");
  3247. }(key, more_map[key]);
  3248. })).join(""), "</ul>\n </div>");
  3249. }
  3250. return function list_element(id, class_names, svg, name) {
  3251. return "" + '<div id="'.concat(id, '" mr-show="" class="').concat(class_names[0], '">\n <span class="').concat(class_names[1], '">\n ').concat(svg, '\n </span>\n <span class="').concat(class_names[2], '">').concat(name, "</span>\n </div>");
  3252. }(key, sub_class_names, svg_map[key], btn_list[key]);
  3253. })).join("");
  3254. return "" + '<div class="'.concat(main_class_name, '">\n ').concat(toolbar_elements, "\n ").concat(more_style, "\n </div>");
  3255. }(toolbar_class, [ span_class, span_class_svg, span_class_text ]));
  3256. } else $("#toolbar_module")[0] && $("#toolbar_module").after('<div id="toolbar_module_2" class="tool-bar clearfix report-wrap-module report-scroll-module media-info" scrollshow="true"> <div id="setting_btn" class="like-info"> <i class="iconfont icon-add"></i><span>脚本设置</span> </div> <div id="bilibili_parse" class="like-info"> <i class="iconfont icon-customer-serv"></i><span>请求地址</span> </div> <div id="video_download" class="like-info" style="display:none"> <i class="iconfont icon-download"></i><span>下载视频</span> </div> <div id="video_download_2" class="like-info" style="display:none"> <i class="iconfont icon-download"></i><span>下载音频</span> </div> <div id="video_download_all" class="like-info"> <i class="iconfont icon-download"></i><span>批量下载</span> </div> <div class="more">更多<div class="more-ops-list"> <ul> <li><span id="download_danmaku">下载弹幕</span></li> <li><span id="download_subtitle">下载字幕</span></li> </ul> </div> </div> <style>.tool-bar .more{float:right;cursor:pointer;color:#757575;font-size:16px;transition:all .3s;position:relative;text-align:center}.tool-bar .more:hover .more-ops-list{display:block}.tool-bar:after{display:block;content:"";clear:both}.more-ops-list{display:none;position:absolute;width:80px;left:-65px;z-index:30;text-align:center;padding:10px 0;background:#fff;border:1px solid #e5e9ef;box-shadow:0 2px 4px 0 rgba(0,0,0,.14);border-radius:2px;font-size:14px;color:#222}.more-ops-list li{position:relative;height:34px;line-height:34px;cursor:pointer;transition:all .3s}.more-ops-list li:hover{color:#00a1d6;background:#e7e7e7}</style> </div> ');
  3257. $("#limit-mask-wall")[0] && $("#limit-mask-wall").remove();
  3258. }
  3259. function main_slicedToArray(arr, i) {
  3260. return function main_arrayWithHoles(arr) {
  3261. if (Array.isArray(arr)) return arr;
  3262. }(arr) || function main_iterableToArrayLimit(arr, i) {
  3263. var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
  3264. if (null == _i) return;
  3265. var _s, _e, _arr = [], _n = !0, _d = !1;
  3266. try {
  3267. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0) ;
  3268. } catch (err) {
  3269. _d = !0, _e = err;
  3270. } finally {
  3271. try {
  3272. _n || null == _i.return || _i.return();
  3273. } finally {
  3274. if (_d) throw _e;
  3275. }
  3276. }
  3277. return _arr;
  3278. }(arr, i) || function main_unsupportedIterableToArray(o, minLen) {
  3279. if (!o) return;
  3280. if ("string" == typeof o) return main_arrayLikeToArray(o, minLen);
  3281. var n = Object.prototype.toString.call(o).slice(8, -1);
  3282. "Object" === n && o.constructor && (n = o.constructor.name);
  3283. if ("Map" === n || "Set" === n) return Array.from(o);
  3284. if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return main_arrayLikeToArray(o, minLen);
  3285. }(arr, i) || function main_nonIterableRest() {
  3286. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3287. }();
  3288. }
  3289. function main_arrayLikeToArray(arr, len) {
  3290. (null == len || len > arr.length) && (len = arr.length);
  3291. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  3292. return arr2;
  3293. }
  3294. function main_defineProperties(target, props) {
  3295. for (var i = 0; i < props.length; i++) {
  3296. var descriptor = props[i];
  3297. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0,
  3298. "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
  3299. }
  3300. }
  3301. var Main = function() {
  3302. function Main() {
  3303. !function main_classCallCheck(instance, Constructor) {
  3304. if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
  3305. }(this, Main), console.log("\n".concat(" %c bilibili-parse-download.user.js v", "2.6.3", " ").concat("ce166b3", " %c https://github.com/injahow/user.js ", "\n", "\n"), "color: #fadfa3; background: #030307; padding:5px 0;", "background: #fadfa3; padding:5px 0;");
  3306. }
  3307. return function main_createClass(Constructor, protoProps, staticProps) {
  3308. return protoProps && main_defineProperties(Constructor.prototype, protoProps), staticProps && main_defineProperties(Constructor, staticProps),
  3309. Object.defineProperty(Constructor, "prototype", {
  3310. writable: !1
  3311. }), Constructor;
  3312. }(Main, [ {
  3313. key: "init",
  3314. value: function init() {
  3315. initToolbar();
  3316. var root_div = document.createElement("div");
  3317. root_div.id = "bp_root", document.body.append(root_div), function initConfig(el) {
  3318. var options = '<option value="0">关闭</option>';
  3319. for (var k in hostMap) options += '<option value="'.concat(k, '">').concat(hostMap[k], "</option>");
  3320. for (var _k in config = config.replace("{{host_key_options}}", options), options = '<option value="0">与播放器相同</option>',
  3321. videoQualityMap) options += '<option value="'.concat(_k, '">').concat(videoQualityMap[_k], "</option>");
  3322. config = config.replace("{{video_quality_options}}", options), el && $(el)[0] ? $(el).append(config) : $("body").append(config);
  3323. var config_str = store.get("config_str");
  3324. try {
  3325. var old_config = JSON.parse(config_str);
  3326. for (var key in old_config) Object.hasOwnProperty.call(config_config, key) && (config_config[key] = old_config[key]);
  3327. } catch (_unused) {
  3328. console.log("初始化脚本配置"), store.set("config_str", "{}");
  3329. }
  3330. var _loop = function _loop(_key3) {
  3331. $("#".concat(_key3)).on("input", (function(e) {
  3332. config_config[_key3] = e.delegateTarget.value;
  3333. }));
  3334. };
  3335. for (var _key3 in config_config) _loop(_key3);
  3336. for (var _k2 in config_functions) {
  3337. var e = $("#".concat(_k2))[0];
  3338. e && (e.onclick = config_functions[_k2]);
  3339. }
  3340. for (var _key4 in config_config) $("#".concat(_key4)).val(config_config[_key4]);
  3341. window.onbeforeunload = function() {
  3342. var bp_aria2_window = window.bp_aria2_window;
  3343. bp_aria2_window && !bp_aria2_window.closed && bp_aria2_window.close();
  3344. };
  3345. }("#".concat(root_div.id)), function initMessage(el) {
  3346. el && $(el)[0] ? $(el).append(message) : $("body").append(message);
  3347. }("#".concat(root_div.id)), user.lazyInit(), auth.checkLoginStatus(), check.refresh(),
  3348. $("#".concat(root_div.id)).append('<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/dplayer/1.25.0/DPlayer.min.css">'),
  3349. $("#".concat(root_div.id)).append('<a id="video_url" style="display:none;" target="_blank" href="#"></a>'),
  3350. $("#".concat(root_div.id)).append('<a id="video_url_2" style="display:none;" target="_blank" href="#"></a>');
  3351. }
  3352. }, {
  3353. key: "run",
  3354. value: function run() {
  3355. var api_url, api_url_temp;
  3356. this.init();
  3357. var evt = {
  3358. setting_btn: function setting_btn() {
  3359. for (var key in user.lazyInit(!0), config_config) $("#".concat(key)).val(config_config[key]);
  3360. $("#auth").val(auth.hasAuth() ? "1" : "0"), $("#bp_config").show(), $("#bp_config").animate({
  3361. opacity: "1"
  3362. }, 300), scroll_scroll.hide();
  3363. },
  3364. bilibili_parse: function bilibili_parse() {
  3365. user.lazyInit(!0);
  3366. var vb = video.base(), _ref = [ vb.type(), vb.aid(), vb.p(), vb.cid(), vb.epid() ], type = _ref[0], aid = _ref[1], p = _ref[2], cid = _ref[3], epid = _ref[4], q = video.get_quality().q;
  3367. api_url = "".concat(config_config.base_api, "?av=").concat(aid, "&p=").concat(p, "&cid=").concat(cid, "&ep=").concat(epid, "&q=").concat(q, "&type=").concat(type, "&format=").concat(config_config.format, "&otype=json&_host=").concat(config_config.host_key, "&_req=").concat(config_config.request_type, "&_q=").concat(config_config.video_quality);
  3368. var _ref2 = [ store.get("auth_id"), store.get("auth_sec") ], auth_id = _ref2[0], auth_sec = _ref2[1];
  3369. if (auth_id && auth_sec && (api_url += "&auth_id=".concat(auth_id, "&auth_sec=").concat(auth_sec)),
  3370. api_url !== api_url_temp || "local" === config_config.request_type) $("#video_url").attr("href", "#"),
  3371. $("#video_url_2").attr("href", "#"), api_url_temp = api_url, message_Message_info("开始请求"),
  3372. api.get_url((function(res) {
  3373. if (res && !res.code) {
  3374. var _url, _url_;
  3375. if (message_Message_success("请求成功"), res.times && message_Message_info("剩余请求次数:".concat(res.times)),
  3376. res.url) _url = res.url.replace("http://", "https://"), _url_ = "#"; else {
  3377. if (!res.video || !res.audio) return void message_Message_warning("数据错误");
  3378. _url = res.video.replace("http://", "https://"), _url_ = res.audio.replace("http://", "https://");
  3379. }
  3380. $("#video_url").attr("href", _url), $("#video_url").attr("download", vb.filename() + Download.url_format(_url)),
  3381. $("#video_download").show(), "#" !== _url_ && ($("#video_url_2").attr("href", _url_),
  3382. $("#video_url_2").attr("download", vb.filename() + "_audio.mp4"), $("#video_download_2").show()),
  3383. (user.needReplace() || vb.isLimited() || "1" === config_config.replace_force) && player.replace_player(_url, _url_),
  3384. "1" === config_config.auto_download && $("#video_download").click();
  3385. }
  3386. })); else {
  3387. message_Message_miaow();
  3388. var url = $("#video_url").attr("href"), url_2 = $("#video_url_2").attr("href");
  3389. url && "#" !== url && ($("#video_download").show(), "dash" === config_config.format && $("#video_download_2").show(),
  3390. (user.needReplace() || vb.isLimited() || "1" === config_config.replace_force) && !$("#bp_dplayer")[0] && player.replace_player(url, url_2),
  3391. "1" === config_config.auto_download && $("#video_download").click());
  3392. }
  3393. },
  3394. download_danmaku: function download_danmaku() {
  3395. var vb = video.base();
  3396. Download.download_danmaku_ass(vb.cid(), vb.filename());
  3397. },
  3398. download_subtitle: function download_subtitle() {
  3399. Download.download_subtitle_vtt(0, video.base().filename());
  3400. },
  3401. video_download_all: function video_download_all() {
  3402. user.lazyInit(!0), auth.hasAuth() ? "rpc" === config_config.download_type ? Download.download_all() : MessageBox_confirm("仅支持使用RPC接口批量下载,请确保RPC环境正常,是否继续?", (function() {
  3403. Download.download_all();
  3404. })) : MessageBox_confirm("批量下载仅支持授权用户使用RPC接口下载,是否进行授权?", (function() {
  3405. auth.login();
  3406. }));
  3407. },
  3408. video_download: function video_download() {
  3409. var type = config_config.download_type;
  3410. if ("web" === type) $("#video_url")[0].click(); else if ("a" === type) {
  3411. var _ref3 = [ $("#video_url").attr("href"), $("#video_url_2").attr("href"), $("#video_url").attr("download"), $("#video_url_2").attr("download") ], video_url_2 = _ref3[1], file_name = _ref3[2], file_name_2 = _ref3[3], msg = "建议使用IDM、FDM等软件安装其浏览器插件后,鼠标右键点击链接下载~<br/><br/>" + '<a href="'.concat(_ref3[0], '" download="').concat(file_name, '" target="_blank" style="text-decoration:underline;">&gt视频地址&lt</a><br/><br/>') + ("dash" === config_config.format ? '<a href="'.concat(video_url_2, '" download="').concat(file_name_2, '" target="_blank" style="text-decoration:underline;">&gt音频地址&lt</a>') : "");
  3412. MessageBox_alert(msg);
  3413. } else if ("aria" === type) {
  3414. var _ref4 = [ $("#video_url").attr("href"), $("#video_url_2").attr("href") ], _video_url = _ref4[0], _video_url_ = _ref4[1], video_title = video.base().filename(), _file_name = video_title + Download.url_format(_video_url), _file_name_ = video_title + ".m4a", aria2c_header = '--header "User-Agent: '.concat(window.navigator.userAgent, '" --header "Referer: ').concat(window.location.href, '"'), _ref6 = main_slicedToArray({
  3415. min: [ 1, 5 ],
  3416. mid: [ 16, 8 ],
  3417. max: [ 32, 16 ]
  3418. }[config_config.aria2c_connection_level] || [ 1, 5 ], 2), url_max_connection = _ref6[0], server_max_connection = _ref6[1], aria2c_max_connection_parameters = "--max-concurrent-downloads ".concat(url_max_connection, " --max-connection-per-server ").concat(server_max_connection), _map = [ 'aria2c "'.concat(_video_url, '" --out "').concat(_file_name, '"'), 'aria2c "'.concat(_video_url_, '" --out "').concat(_file_name_, '"') ].map((function(code) {
  3419. return "".concat(code, " ").concat(aria2c_header, " ").concat(aria2c_max_connection_parameters, " ").concat(config_config.aria2c_addition_parameters);
  3420. })), _map2 = main_slicedToArray(_map, 2), code = _map2[0], code_2 = _map2[1], _msg = "点击文本框即可复制下载命令!<br/><br/>" + '视频:<br/><input id="aria2_code" value=\''.concat(code, '\' onclick="bp_clip_btn(\'aria2_code\')" style="width:100%;"></br></br>') + ("dash" === config_config.format ? '音频:<br/><input id="aria2_code_2" value=\''.concat(code_2, '\' onclick="bp_clip_btn(\'aria2_code_2\')" style="width:100%;"><br/><br/>') + '全部:<br/><textarea id="aria2_code_all" onclick="bp_clip_btn(\'aria2_code_all\')" style="min-width:100%;max-width:100%;min-height:100px;max-height:100px;">'.concat(code, "\n").concat(code_2, "</textarea>") : "");
  3421. !window.bp_clip_btn && (window.bp_clip_btn = function(id) {
  3422. $("#".concat(id)).select(), document.execCommand("copy") ? message_Message_success("复制成功") : message_Message_warning("复制失败");
  3423. }), MessageBox_alert(_msg);
  3424. } else {
  3425. var url = $("#video_url").attr("href"), filename = video.base().filename() + Download.url_format(url);
  3426. Download.download(url, filename, type);
  3427. }
  3428. },
  3429. video_download_2: function video_download_2() {
  3430. var type = config_config.download_type;
  3431. if ("web" === type) $("#video_url_2")[0].click(); else if ("a" === type) $("#video_download").click(); else if ("aria" === type) $("#video_download").click(); else {
  3432. var url = $("#video_url_2").attr("href"), filename = video.base().filename() + ".m4a";
  3433. Download.download(url, filename, type);
  3434. }
  3435. }
  3436. };
  3437. window.bpd = evt, Object.entries(evt).forEach((function(_ref7) {
  3438. var _ref8 = main_slicedToArray(_ref7, 2), k = _ref8[0], v = _ref8[1];
  3439. return $("body").on("click", "#".concat(k), v);
  3440. })), $("body").on("click", "a.router-link-active", (function() {
  3441. this !== $('li[class="on"]').find("a")[0] && check.refresh();
  3442. })), $("body").on("click", "li.ep-item", (function() {
  3443. check.refresh();
  3444. })), $("body").on("click", "button.bilibili-player-iconfont-next", (function() {
  3445. check.refresh();
  3446. })), $("body").on("click", "li.bui-select-item", (function() {
  3447. check.refresh();
  3448. })), $("body").on("click", ".rec-list", (function() {
  3449. check.refresh();
  3450. })), $("body").on("click", ".bilibili-player-ending-panel-box-videos", (function() {
  3451. check.refresh();
  3452. })), setInterval((function() {
  3453. check.href !== location.href && check.refresh();
  3454. }), 500), setInterval((function() {
  3455. var vb = video.base();
  3456. check.aid === vb.aid() && check.cid === vb.cid() || check.refresh();
  3457. }), 1500);
  3458. }
  3459. } ]), Main;
  3460. }(), main = Main;
  3461. window.bp_fun_locked || (window.bp_fun_locked = !0, $(".error-text")[0] || setTimeout((function() {
  3462. (new main).run();
  3463. }), 5e3));
  3464. }();

QingJ © 2025

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