Greasy Fork is available in English.

iqiyi-player-switch

爱奇艺flash播放器与html5播放器随意切换,改善html5播放器播放体验。

  1. // ==UserScript==
  2. // @name iqiyi-player-switch
  3. // @namespace https://github.com/gooyie/userscript-iqiyi-player-switch
  4. // @homepageURL https://github.com/gooyie/userscript-iqiyi-player-switch
  5. // @supportURL https://github.com/gooyie/userscript-iqiyi-player-switch/issues
  6. // @description 爱奇艺flash播放器与html5播放器随意切换,改善html5播放器播放体验。
  7. // @version 1.14.0
  8. // @compatible chrome >= 43
  9. // @compatible firefox >= 45
  10. // @compatible edge >= 15
  11. // @author gooyie
  12. // @license MIT License
  13. //
  14. // @include *://*.iqiyi.com/*
  15. // @include *://v.baidu.com/*
  16. // @include *://music.baidu.com/mv/*
  17. // @include *://www.zybus.com/*
  18. // @grant GM_registerMenuCommand
  19. // @grant GM_xmlhttpRequest
  20. // @grant GM_addStyle
  21. // @grant GM_getValue
  22. // @grant GM_setValue
  23. // @grant GM_info
  24. // @grant unsafeWindow
  25. // @connect qiyi.com
  26. // @run-at document-start
  27. // ==/UserScript==
  28.  
  29. /******/ (function(modules) { // webpackBootstrap
  30. /******/ // The module cache
  31. /******/ var installedModules = {};
  32. /******/
  33. /******/ // The require function
  34. /******/ function __webpack_require__(moduleId) {
  35. /******/
  36. /******/ // Check if module is in cache
  37. /******/ if(installedModules[moduleId]) {
  38. /******/ return installedModules[moduleId].exports;
  39. /******/ }
  40. /******/ // Create a new module (and put it into the cache)
  41. /******/ var module = installedModules[moduleId] = {
  42. /******/ i: moduleId,
  43. /******/ l: false,
  44. /******/ exports: {}
  45. /******/ };
  46. /******/
  47. /******/ // Execute the module function
  48. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  49. /******/
  50. /******/ // Flag the module as loaded
  51. /******/ module.l = true;
  52. /******/
  53. /******/ // Return the exports of the module
  54. /******/ return module.exports;
  55. /******/ }
  56. /******/
  57. /******/
  58. /******/ // expose the modules object (__webpack_modules__)
  59. /******/ __webpack_require__.m = modules;
  60. /******/
  61. /******/ // expose the module cache
  62. /******/ __webpack_require__.c = installedModules;
  63. /******/
  64. /******/ // define getter function for harmony exports
  65. /******/ __webpack_require__.d = function(exports, name, getter) {
  66. /******/ if(!__webpack_require__.o(exports, name)) {
  67. /******/ Object.defineProperty(exports, name, {
  68. /******/ configurable: false,
  69. /******/ enumerable: true,
  70. /******/ get: getter
  71. /******/ });
  72. /******/ }
  73. /******/ };
  74. /******/
  75. /******/ // getDefaultExport function for compatibility with non-harmony modules
  76. /******/ __webpack_require__.n = function(module) {
  77. /******/ var getter = module && module.__esModule ?
  78. /******/ function getDefault() { return module['default']; } :
  79. /******/ function getModuleExports() { return module; };
  80. /******/ __webpack_require__.d(getter, 'a', getter);
  81. /******/ return getter;
  82. /******/ };
  83. /******/
  84. /******/ // Object.prototype.hasOwnProperty.call
  85. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  86. /******/
  87. /******/ // __webpack_public_path__
  88. /******/ __webpack_require__.p = "";
  89. /******/
  90. /******/ // Load entry module and return exports
  91. /******/ return __webpack_require__(__webpack_require__.s = 5);
  92. /******/ })
  93. /************************************************************************/
  94. /******/ ([
  95. /* 0 */
  96. /***/ (function(module, exports, __webpack_require__) {
  97.  
  98. "use strict";
  99.  
  100.  
  101. Object.defineProperty(exports, "__esModule", {
  102. value: true
  103. });
  104.  
  105. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  106.  
  107. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  108.  
  109. var _logger = __webpack_require__(1);
  110.  
  111. var _logger2 = _interopRequireDefault(_logger);
  112.  
  113. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  114.  
  115. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  116.  
  117. var Hooker = function () {
  118. function Hooker() {
  119. _classCallCheck(this, Hooker);
  120. }
  121.  
  122. _createClass(Hooker, null, [{
  123. key: '_hookCall',
  124. value: function _hookCall(cb) {
  125. var call = Function.prototype.call;
  126. Function.prototype.call = function () {
  127. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  128. args[_key] = arguments[_key];
  129. }
  130.  
  131. var ret = call.apply(this, args);
  132. try {
  133. if (args && cb(args)) {
  134. Function.prototype.call = call;
  135. cb = function cb() {};
  136. _logger2.default.info(`The native function call has been restored`);
  137. }
  138. } catch (err) {
  139. _logger2.default.error(err.stack);
  140. }
  141. return ret;
  142. };
  143. this._hookCall = null;
  144. }
  145. }, {
  146. key: '_isModuleCall',
  147. value: function _isModuleCall(args) {
  148. // module.exports, module, module.exports, require
  149. return args.length === 4 && args[1] && Object.getPrototypeOf(args[1]) === Object.prototype && args[1].hasOwnProperty('exports');
  150. }
  151. }, {
  152. key: '_hookModuleCall',
  153. value: function _hookModuleCall(cb, pred) {
  154. var _this = this;
  155.  
  156. var callbacksMap = new Map([[pred, [cb]]]);
  157. this._hookCall(function (args) {
  158. if (!_this._isModuleCall(args)) return;
  159.  
  160. var exports = args[1].exports;
  161. var _iteratorNormalCompletion = true;
  162. var _didIteratorError = false;
  163. var _iteratorError = undefined;
  164.  
  165. try {
  166. for (var _iterator = callbacksMap[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  167. var _ref = _step.value;
  168.  
  169. var _ref2 = _slicedToArray(_ref, 2);
  170.  
  171. var _pred = _ref2[0];
  172. var callbacks = _ref2[1];
  173.  
  174. if (!_pred.apply(_this, [exports])) continue;
  175. callbacks.forEach(function (cb) {
  176. return cb(exports, args);
  177. });
  178. _this.keepalive || callbacksMap.delete(_pred);
  179. !callbacksMap.size && (_this._hookModuleCall = null);
  180. break;
  181. }
  182. } catch (err) {
  183. _didIteratorError = true;
  184. _iteratorError = err;
  185. } finally {
  186. try {
  187. if (!_iteratorNormalCompletion && _iterator.return) {
  188. _iterator.return();
  189. }
  190. } finally {
  191. if (_didIteratorError) {
  192. throw _iteratorError;
  193. }
  194. }
  195. }
  196.  
  197. return !callbacksMap.size;
  198. });
  199.  
  200. this._hookModuleCall = function (cb, pred) {
  201. if (callbacksMap.has(pred)) {
  202. callbacksMap.get(pred).push(cb);
  203. } else {
  204. callbacksMap.set(pred, [cb]);
  205. }
  206. };
  207. }
  208. }, {
  209. key: '_isJqueryModuleCall',
  210. value: function _isJqueryModuleCall(exports) {
  211. return exports.hasOwnProperty('fn') && exports.fn.hasOwnProperty('jquery');
  212. }
  213. }, {
  214. key: 'hookJquery',
  215. value: function hookJquery() {
  216. var cb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
  217.  
  218. this._hookModuleCall(cb, this._isJqueryModuleCall);
  219. }
  220. }, {
  221. key: 'hookJqueryAjax',
  222. value: function hookJqueryAjax(cb) {
  223. this.hookJquery(function (exports) {
  224. var ajax = exports.ajax.bind(exports);
  225. exports.ajax = function (url) {
  226. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  227.  
  228. if (typeof url === 'object') {
  229. var _ref3 = [url.url, url];
  230. url = _ref3[0];
  231. options = _ref3[1];
  232. }
  233. var isHijacked = cb(url, options);
  234. if (isHijacked) return;
  235. return ajax(url, options);
  236. };
  237. });
  238. }
  239. }, {
  240. key: '_isHttpModuleCall',
  241. value: function _isHttpModuleCall(exports) {
  242. return exports.hasOwnProperty('jsonp') && exports.hasOwnProperty('ajax');
  243. }
  244. }, {
  245. key: 'hookHttp',
  246. value: function hookHttp(cb) {
  247. this._hookModuleCall(cb, this._isHttpModuleCall);
  248. }
  249. }, {
  250. key: 'hookHttpJsonp',
  251. value: function hookHttpJsonp(cb) {
  252. this.hookHttp(function (exports) {
  253. var jsonp = exports.jsonp.bind(exports);
  254. exports.jsonp = function (options) {
  255. var isHijacked = cb(options);
  256. if (isHijacked) return;
  257. return jsonp(options);
  258. };
  259. });
  260. }
  261. }, {
  262. key: '_isLogoModuleCall',
  263. value: function _isLogoModuleCall(exports) {
  264. return 'function' === typeof exports && exports.prototype.hasOwnProperty('showLogo');
  265. }
  266. }, {
  267. key: 'hookLogo',
  268. value: function hookLogo(cb) {
  269. this._hookModuleCall(cb, this._isLogoModuleCall);
  270. }
  271. }, {
  272. key: '_isFullScreenModuleCall',
  273. value: function _isFullScreenModuleCall(exports) {
  274. return exports.__proto__ && exports.__proto__.hasOwnProperty('isFullScreen');
  275. }
  276. }, {
  277. key: 'hookFullScreen',
  278. value: function hookFullScreen(cb) {
  279. this._hookModuleCall(cb, this._isFullScreenModuleCall);
  280. }
  281. }, {
  282. key: '_isWebFullScreenModuleCall',
  283. value: function _isWebFullScreenModuleCall(exports) {
  284. return exports.__proto__ && exports.__proto__.hasOwnProperty('isWebFullScreen');
  285. }
  286. }, {
  287. key: 'hookWebFullScreen',
  288. value: function hookWebFullScreen(cb) {
  289. this._hookModuleCall(cb, this._isWebFullScreenModuleCall);
  290. }
  291. }, {
  292. key: 'hookWebFullScreenInit',
  293. value: function hookWebFullScreenInit(cb) {
  294. this.hookWebFullScreen(function (exports) {
  295. var init = exports.__proto__.init;
  296. exports.__proto__.init = function (wrapper, btn) {
  297. cb(this, wrapper, btn);
  298. init.apply(this, [wrapper, btn]);
  299. };
  300. });
  301. }
  302. }, {
  303. key: '_isPluginControlsModuleCall',
  304. value: function _isPluginControlsModuleCall(exports) {
  305. return 'function' === typeof exports && exports.prototype.hasOwnProperty('initFullScreen');
  306. }
  307. }, {
  308. key: 'hookPluginControls',
  309. value: function hookPluginControls(cb) {
  310. this._hookModuleCall(cb, this._isPluginControlsModuleCall);
  311. }
  312. }, {
  313. key: 'hookPluginControlsInit',
  314. value: function hookPluginControlsInit(cb) {
  315. this.hookPluginControls(function (exports) {
  316. var init = exports.prototype.init;
  317. exports.prototype.init = function () {
  318. cb(this);
  319. init.apply(this);
  320. };
  321. });
  322. }
  323. }, {
  324. key: 'hookInitFullScreen',
  325. value: function hookInitFullScreen(cb) {
  326. this.hookPluginControls(function (exports) {
  327. var initFullScreen = exports.prototype.initFullScreen;
  328. exports.prototype.initFullScreen = function () {
  329. cb(this);
  330. initFullScreen.apply(this);
  331. };
  332. });
  333. }
  334. }, {
  335. key: '_isCoreModuleCall',
  336. value: function _isCoreModuleCall(exports) {
  337. return 'function' === typeof exports && exports.prototype.hasOwnProperty('getdefaultvds') && exports.prototype.hasOwnProperty('getMovieInfo');
  338. }
  339. }, {
  340. key: 'hookCore',
  341. value: function hookCore(cb) {
  342. this._hookModuleCall(cb, this._isCoreModuleCall);
  343. }
  344. }, {
  345. key: '_isSkinBaseModuleCall',
  346. value: function _isSkinBaseModuleCall(exports) {
  347. return 'function' === typeof exports && exports.prototype.hasOwnProperty('_checkPlugin');
  348. }
  349. }, {
  350. key: 'hookSkinBase',
  351. value: function hookSkinBase(cb) {
  352. this._hookModuleCall(cb, this._isSkinBaseModuleCall);
  353. }
  354. }, {
  355. key: '_isPluginHotKeysModuleCall',
  356. value: function _isPluginHotKeysModuleCall(exports) {
  357. return 'function' === typeof exports && exports.prototype.hasOwnProperty('_keydown');
  358. }
  359. }, {
  360. key: 'hookPluginHotKeys',
  361. value: function hookPluginHotKeys(cb) {
  362. this._hookModuleCall(cb, this._isPluginHotKeysModuleCall);
  363. }
  364. }, {
  365. key: '_isFragmentModuleCall',
  366. value: function _isFragmentModuleCall(exports) {
  367. return 'function' === typeof exports && exports.prototype.hasOwnProperty('parseData');
  368. }
  369. }, {
  370. key: 'hookFragment',
  371. value: function hookFragment(cb) {
  372. this._hookModuleCall(cb, this._isFragmentModuleCall);
  373. }
  374. }, {
  375. key: 'hookParseData',
  376. value: function hookParseData(cb) {
  377. this.hookFragment(function (exports) {
  378. var parseData = exports.prototype.parseData;
  379. exports.prototype.parseData = function () {
  380. for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  381. args[_key2] = arguments[_key2];
  382. }
  383.  
  384. parseData.apply(this, args);
  385. cb(this);
  386. };
  387. });
  388. }
  389. }, {
  390. key: '_isUserModuleCall',
  391. value: function _isUserModuleCall(exports) {
  392. return exports.__proto__ && exports.__proto__.hasOwnProperty('isVip');
  393. }
  394. }, {
  395. key: 'hookUser',
  396. value: function hookUser(cb) {
  397. this._hookModuleCall(cb, this._isUserModuleCall);
  398. }
  399. }, {
  400. key: '_isShowRequestModuleCall',
  401. value: function _isShowRequestModuleCall(exports) {
  402. return 'function' === typeof exports && exports.compressRequestKey && exports.prototype.hasOwnProperty('request');
  403. }
  404. }, {
  405. key: 'hookShowRequest',
  406. value: function hookShowRequest(cb) {
  407. this._hookModuleCall(cb, this._isShowRequestModuleCall);
  408. }
  409. }, {
  410. key: '_isDefaultSkinModuleCall',
  411. value: function _isDefaultSkinModuleCall(exports) {
  412. return 'function' === typeof exports && exports.prototype.hasOwnProperty('_initDBClicks');
  413. }
  414. }, {
  415. key: 'hookDefaultSkin',
  416. value: function hookDefaultSkin(cb) {
  417. this._hookModuleCall(cb, this._isDefaultSkinModuleCall);
  418. }
  419. }, {
  420. key: '_isConfigModuleCall',
  421. value: function _isConfigModuleCall(exports) {
  422. return exports.loadType && exports.dispatchCfg;
  423. }
  424. }, {
  425. key: 'hookConfig',
  426. value: function hookConfig(cb) {
  427. this._hookModuleCall(cb, this._isConfigModuleCall);
  428. }
  429. }]);
  430.  
  431. return Hooker;
  432. }();
  433.  
  434. Hooker.keepalive = false;
  435.  
  436. exports.default = Hooker;
  437.  
  438. /***/ }),
  439. /* 1 */
  440. /***/ (function(module, exports, __webpack_require__) {
  441.  
  442. "use strict";
  443.  
  444.  
  445. Object.defineProperty(exports, "__esModule", {
  446. value: true
  447. });
  448.  
  449. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  450.  
  451. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  452.  
  453. /* eslint-disable no-console */
  454. var Logger = function () {
  455. function Logger(tag) {
  456. _classCallCheck(this, Logger);
  457.  
  458. this._tag = tag;
  459. }
  460.  
  461. _createClass(Logger, [{
  462. key: 'log',
  463. value: function log() {
  464. var _console;
  465.  
  466. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  467. args[_key] = arguments[_key];
  468. }
  469.  
  470. (_console = console).log.apply(_console, [this.tag + args.shift()].concat(args));
  471. }
  472. }, {
  473. key: 'info',
  474. value: function info() {
  475. var _console2;
  476.  
  477. for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  478. args[_key2] = arguments[_key2];
  479. }
  480.  
  481. (_console2 = console).log.apply(_console2, ['%c' + this.tag + '%c' + args.shift(), 'color: green; font-weight: bolder', 'color: blue'].concat(args));
  482. }
  483. }, {
  484. key: 'debug',
  485. value: function debug() {
  486. var _console3;
  487.  
  488. for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  489. args[_key3] = arguments[_key3];
  490. }
  491.  
  492. (_console3 = console).debug.apply(_console3, [this.tag + args.shift()].concat(args));
  493. }
  494. }, {
  495. key: 'warn',
  496. value: function warn() {
  497. var _console4;
  498.  
  499. for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  500. args[_key4] = arguments[_key4];
  501. }
  502.  
  503. (_console4 = console).warn.apply(_console4, [this.tag + args.shift()].concat(args));
  504. }
  505. }, {
  506. key: 'error',
  507. value: function error() {
  508. var _console5;
  509.  
  510. for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  511. args[_key5] = arguments[_key5];
  512. }
  513.  
  514. (_console5 = console).error.apply(_console5, [this.tag + args.shift()].concat(args));
  515. }
  516. }, {
  517. key: 'tag',
  518. get: function get() {
  519. return this._tag;
  520. }
  521. }]);
  522.  
  523. return Logger;
  524. }();
  525.  
  526. exports.default = new Logger(`[${GM_info.script.name}]`);
  527.  
  528. /***/ }),
  529. /* 2 */
  530. /***/ (function(module, exports, __webpack_require__) {
  531.  
  532. "use strict";
  533.  
  534.  
  535. Object.defineProperty(exports, "__esModule", {
  536. value: true
  537. });
  538.  
  539. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  540.  
  541. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  542.  
  543. var Detector = function () {
  544. function Detector() {
  545. _classCallCheck(this, Detector);
  546. }
  547.  
  548. _createClass(Detector, null, [{
  549. key: 'isSupportHtml5',
  550. value: function isSupportHtml5() {
  551. var v = document.createElement('video');
  552. return !!(v.canPlayType('audio/mp4; codecs="mp4a.40.2"') && v.canPlayType('video/mp4; codecs="avc1.640029"') && v.canPlayType('video/mp4; codecs="avc1.640029, mp4a.40.2"'));
  553. }
  554. }, {
  555. key: 'isSupportVms',
  556. value: function isSupportVms() {
  557. return !!(window.MediaSource && window.URL && window.WebSocket && window.ReadableStream && (window.RTCSessionDescription || window.webkitRTCSessionDescription) && (window.RTCPeerConnection || window.webkitRTCPeerConnection) && (window.RTCIceCandidate || window.webkitRTCIceCandidate));
  558. }
  559. }, {
  560. key: 'isSupportM3u8',
  561. value: function isSupportM3u8() {
  562. var v = document.createElement('video');
  563. return !!(v.canPlayType('application/x-mpegurl') && v.canPlayType('application/vnd.apple.mpegurl'));
  564. }
  565. }, {
  566. key: 'isChrome',
  567. value: function isChrome() {
  568. return (/chrome/i.test(navigator.userAgent)
  569. );
  570. }
  571. }, {
  572. key: 'isFirefox',
  573. value: function isFirefox() {
  574. return (/firefox/i.test(navigator.userAgent)
  575. );
  576. }
  577. }, {
  578. key: 'isEdge',
  579. value: function isEdge() {
  580. return (/edge/i.test(navigator.userAgent)
  581. );
  582. }
  583. }, {
  584. key: 'isInIFrame',
  585. value: function isInIFrame() {
  586. return window.top !== window.self;
  587. }
  588. }, {
  589. key: 'isOutsite',
  590. value: function isOutsite() {
  591. return !/\.iqiyi\.com$/.test(location.host);
  592. }
  593. }, {
  594. key: 'isOutsideLink',
  595. value: function isOutsideLink() {
  596. return location.hash === '#outsidelink';
  597. }
  598. }, {
  599. key: 'hasFlashPlugin',
  600. value: function hasFlashPlugin() {
  601. var plugins = unsafeWindow.navigator.plugins;
  602. return !!(plugins['Shockwave Flash'] && plugins['Shockwave Flash'].description);
  603. }
  604. }]);
  605.  
  606. return Detector;
  607. }();
  608.  
  609. exports.default = Detector;
  610.  
  611. /***/ }),
  612. /* 3 */
  613. /***/ (function(module, exports, __webpack_require__) {
  614.  
  615. "use strict";
  616.  
  617.  
  618. Object.defineProperty(exports, "__esModule", {
  619. value: true
  620. });
  621.  
  622. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  623.  
  624. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  625.  
  626. var Faker = function () {
  627. function Faker() {
  628. _classCallCheck(this, Faker);
  629. }
  630.  
  631. _createClass(Faker, null, [{
  632. key: 'fakeMacPlatform',
  633. value: function fakeMacPlatform() {
  634. var PLAFORM_MAC = 'mac';
  635. Object.defineProperty(unsafeWindow.navigator, 'platform', { get: function get() {
  636. return PLAFORM_MAC;
  637. } });
  638. }
  639. }, {
  640. key: 'fakeSafari',
  641. value: function fakeSafari() {
  642. var UA_SAFARY = 'safari';
  643. Object.defineProperty(unsafeWindow.navigator, 'userAgent', { get: function get() {
  644. return UA_SAFARY;
  645. } });
  646. }
  647. }, {
  648. key: 'fakeChrome',
  649. value: function fakeChrome() {
  650. var ver = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  651.  
  652. var UA_CHROME = `Chrome/${ver}`;
  653. Object.defineProperty(unsafeWindow.navigator, 'userAgent', { get: function get() {
  654. return UA_CHROME;
  655. } });
  656. }
  657. }, {
  658. key: 'fakeFlashPlugin',
  659. value: function fakeFlashPlugin() {
  660. var plugin = {
  661. description: 'Shockwave Flash 26.0 r0',
  662. filename: 'pepflashplayer64_26_0_0_131.dll',
  663. length: 0,
  664. name: 'Shockwave Flash'
  665. };
  666.  
  667. Reflect.setPrototypeOf(plugin, Plugin.prototype);
  668. unsafeWindow.navigator.plugins['Shockwave Flash'] = plugin;
  669. }
  670. }]);
  671.  
  672. return Faker;
  673. }();
  674.  
  675. exports.default = Faker;
  676.  
  677. /***/ }),
  678. /* 4 */
  679. /***/ (function(module, exports) {
  680.  
  681. var g;
  682.  
  683. // This works in non-strict mode
  684. g = (function() {
  685. return this;
  686. })();
  687.  
  688. try {
  689. // This works if eval is allowed (see CSP)
  690. g = g || Function("return this")() || (1,eval)("this");
  691. } catch(e) {
  692. // This works if the window reference is available
  693. if(typeof window === "object")
  694. g = window;
  695. }
  696.  
  697. // g can still be undefined, but nothing to do about it...
  698. // We return undefined, instead of nothing here, so it's
  699. // easier to handle this case. if(!global) { ...}
  700.  
  701. module.exports = g;
  702.  
  703.  
  704. /***/ }),
  705. /* 5 */
  706. /***/ (function(module, exports, __webpack_require__) {
  707.  
  708. "use strict";
  709.  
  710.  
  711. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  712.  
  713. var _logger = __webpack_require__(1);
  714.  
  715. var _logger2 = _interopRequireDefault(_logger);
  716.  
  717. var _cookies = __webpack_require__(6);
  718.  
  719. var _cookies2 = _interopRequireDefault(_cookies);
  720.  
  721. var _detector = __webpack_require__(2);
  722.  
  723. var _detector2 = _interopRequireDefault(_detector);
  724.  
  725. var _faker = __webpack_require__(3);
  726.  
  727. var _faker2 = _interopRequireDefault(_faker);
  728.  
  729. var _outsite = __webpack_require__(7);
  730.  
  731. var _patch = __webpack_require__(12);
  732.  
  733. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  734.  
  735. var PLAYER_TYPE = {
  736. Html5VOD: 'h5_VOD',
  737. FlashVOD: 'flash_VOD'
  738. };
  739.  
  740. function forceHtml5() {
  741. _cookies2.default.set('player_forcedType', PLAYER_TYPE.Html5VOD, { domain: '.iqiyi.com' });
  742. _logger2.default.info(`The 'player_forcedType' cookie has been set as '${PLAYER_TYPE.Html5VOD}'`);
  743. }
  744.  
  745. function forceFlash() {
  746. _cookies2.default.set('player_forcedType', PLAYER_TYPE.FlashVOD, { domain: '.iqiyi.com' });
  747. _logger2.default.info(`The 'player_forcedType' cookie has been set as '${PLAYER_TYPE.FlashVOD}'`);
  748. }
  749.  
  750. function clean() {
  751. _cookies2.default.remove('player_forcedType', { domain: '.iqiyi.com' });
  752. _logger2.default.info(`Removed the 'player_forcedType' cookie`);
  753. }
  754.  
  755. function switchTo(type) {
  756. _logger2.default.info(`Switching to ${type} ...`);
  757. GM_setValue('player_forcedType', type);
  758. document.location.reload();
  759. }
  760.  
  761. function registerMenu() {
  762. var MENU_NAME = {
  763. HTML5: 'HTML5播放器',
  764. FLASH: 'Flash播放器'
  765. };
  766.  
  767. var currType = GM_getValue('player_forcedType', PLAYER_TYPE.Html5VOD); // 默认为Html5播放器,免去切换。
  768.  
  769. var _ref = currType === PLAYER_TYPE.Html5VOD ? [PLAYER_TYPE.FlashVOD, MENU_NAME.FLASH] : [PLAYER_TYPE.Html5VOD, MENU_NAME.HTML5],
  770. _ref2 = _slicedToArray(_ref, 2),
  771. type = _ref2[0],
  772. name = _ref2[1];
  773.  
  774. GM_registerMenuCommand(name, function () {
  775. return switchTo(type);
  776. }, null);
  777. _logger2.default.info(`Registered the menu.`);
  778. }
  779.  
  780. function mustKeepHooking() {
  781. return location.search.includes('list'); // https://github.com/gooyie/userscript-iqiyi-player-switch/issues/15
  782. }
  783.  
  784. //=============================================================================
  785.  
  786. registerMenu();
  787.  
  788. var currType = GM_getValue('player_forcedType', PLAYER_TYPE.Html5VOD);
  789. if (currType === PLAYER_TYPE.Html5VOD) {
  790. if (_detector2.default.isSupportHtml5()) {
  791. if (_detector2.default.isOutsite()) {
  792. (0, _outsite.replaceFlash)();
  793. } else {
  794. forceHtml5();
  795.  
  796. if (_detector2.default.isFirefox()) {
  797. // Fake Chrome with a version number less than 43
  798. // to use the data engine to play videos better than HD and to use the XHR loader
  799. // because Firefox has not yet implemented ReadableStream to support the Fetch loader.
  800. _faker2.default.fakeChrome(42);
  801. }
  802.  
  803. if (mustKeepHooking()) {
  804. _patch.keepHookingPatch.install();
  805. }
  806. _patch.adsPatch.install();
  807. _patch.controlsPatch.install();
  808. _patch.watermarksPatch.install();
  809. _patch.vipPatch.install();
  810. _patch.keyShortcutsPatch.install();
  811. _patch.mouseShortcutsPatch.install();
  812. _patch.useWebSocketLoaderPatch.install();
  813.  
  814. if (_detector2.default.isInIFrame() && _detector2.default.isOutsideLink()) {
  815. (0, _outsite.adaptIframe)();
  816. }
  817. }
  818. } else {
  819. alert('╮(╯▽╰)╭ 你的浏览器播放不了html5视频~~~~');
  820. }
  821. } else {
  822. forceFlash();
  823. }
  824.  
  825. window.addEventListener('unload', function () {
  826. return clean();
  827. });
  828.  
  829. /***/ }),
  830. /* 6 */
  831. /***/ (function(module, exports, __webpack_require__) {
  832.  
  833. "use strict";
  834.  
  835.  
  836. Object.defineProperty(exports, "__esModule", {
  837. value: true
  838. });
  839.  
  840. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  841.  
  842. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  843.  
  844. var Cookies = function () {
  845. function Cookies() {
  846. _classCallCheck(this, Cookies);
  847. }
  848.  
  849. _createClass(Cookies, null, [{
  850. key: 'get',
  851. value: function get(key) {
  852. var value = void 0;
  853. if (new RegExp('^[^\\x00-\\x20\\x7f\\(\\)<>@,;:\\\\\\"\\[\\]\\?=\\{\\}\\/\\u0080-\\uffff]+$').test(key)) {
  854. // eslint-disable-line no-control-regex
  855. var re = new RegExp('(^| )' + key + '=([^;]*)(;|$)');
  856. var rs = re.exec(document.cookie);
  857. value = rs ? rs[2] : '';
  858. }
  859. return value ? decodeURIComponent(value) : '';
  860. }
  861. }, {
  862. key: 'set',
  863. value: function set(k, v) {
  864. var o = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  865.  
  866. var n = o.expires;
  867. if ('number' == typeof o.expires) {
  868. n = new Date();
  869. n.setTime(n.getTime() + o.expires);
  870. }
  871. var key = k;
  872. var value = encodeURIComponent(v);
  873. var path = o.path ? '; path=' + o.path : '';
  874. var expires = n ? '; expires=' + n.toGMTString() : '';
  875. var domain = o.domain ? '; domain=' + o.domain : '';
  876. document.cookie = `${key}=${value}${path}${expires}${domain}`;
  877. }
  878. }, {
  879. key: 'remove',
  880. value: function remove(k) {
  881. var o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  882.  
  883. o.expires = new Date(0);
  884. this.set(k, '', o);
  885. }
  886. }]);
  887.  
  888. return Cookies;
  889. }();
  890.  
  891. exports.default = Cookies;
  892.  
  893. /***/ }),
  894. /* 7 */
  895. /***/ (function(module, exports, __webpack_require__) {
  896.  
  897. "use strict";
  898.  
  899.  
  900. Object.defineProperty(exports, "__esModule", {
  901. value: true
  902. });
  903. exports.adaptIframe = exports.replaceFlash = undefined;
  904.  
  905. var _regenerator = __webpack_require__(8);
  906.  
  907. var _regenerator2 = _interopRequireDefault(_regenerator);
  908.  
  909. var embedSrc = function () {
  910. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(targetNode, _ref) {
  911. var tvid = _ref.tvid,
  912. vid = _ref.vid;
  913. var url;
  914. return _regenerator2.default.wrap(function _callee$(_context) {
  915. while (1) {
  916. switch (_context.prev = _context.next) {
  917. case 0:
  918. targetNode.innerHTML = `<div class="${GM_info.script.name} info">正在获取视频源...</div>`;
  919.  
  920. _context.prev = 1;
  921. _context.next = 4;
  922. return (0, _utils.getVideoUrl)(tvid, vid);
  923.  
  924. case 4:
  925. url = _context.sent;
  926.  
  927. _logger2.default.info('source url: %s', url);
  928. targetNode.innerHTML = `<iframe id="outsidelink" src="${url}#outsidelink" frameborder="0" allowfullscreen="true" width="100%" height="100%"></iframe>`;
  929. _context.next = 12;
  930. break;
  931.  
  932. case 9:
  933. _context.prev = 9;
  934. _context.t0 = _context['catch'](1);
  935.  
  936. targetNode.innerHTML = `<div class="${GM_info.script.name} error"><p>获取视频源出错!</p><p>${_context.t0.message}</p></div>`;
  937.  
  938. case 12:
  939. case 'end':
  940. return _context.stop();
  941. }
  942. }
  943. }, _callee, this, [[1, 9]]);
  944. }));
  945.  
  946. return function embedSrc(_x, _x2) {
  947. return _ref2.apply(this, arguments);
  948. };
  949. }();
  950.  
  951. var _logger = __webpack_require__(1);
  952.  
  953. var _logger2 = _interopRequireDefault(_logger);
  954.  
  955. var _hooker = __webpack_require__(0);
  956.  
  957. var _hooker2 = _interopRequireDefault(_hooker);
  958.  
  959. var _faker = __webpack_require__(3);
  960.  
  961. var _faker2 = _interopRequireDefault(_faker);
  962.  
  963. var _detector = __webpack_require__(2);
  964.  
  965. var _detector2 = _interopRequireDefault(_detector);
  966.  
  967. var _utils = __webpack_require__(11);
  968.  
  969. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  970.  
  971. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  972.  
  973. function replaceFlash() {
  974. if (!_detector2.default.hasFlashPlugin()) _faker2.default.fakeFlashPlugin();
  975.  
  976. var observer = new MutationObserver(function (records, self) {
  977. var _iteratorNormalCompletion = true;
  978. var _didIteratorError = false;
  979. var _iteratorError = undefined;
  980.  
  981. try {
  982. for (var _iterator = records[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  983. var record = _step.value;
  984.  
  985. if (record.type !== 'childList' || !record.addedNodes) continue;
  986.  
  987. var _iteratorNormalCompletion2 = true;
  988. var _didIteratorError2 = false;
  989. var _iteratorError2 = undefined;
  990.  
  991. try {
  992. for (var _iterator2 = record.addedNodes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  993. var node = _step2.value;
  994.  
  995. if (node.nodeName !== 'OBJECT' && node.nodeName !== 'EMBED') continue;
  996. _logger2.default.info('found node', node);
  997.  
  998. var text = node.outerHTML;
  999. var vid = (0, _utils.findVid)(text);
  1000. var tvid = (0, _utils.findTvid)(text);
  1001.  
  1002. if (tvid && vid) {
  1003. _logger2.default.info('found tvid: %s, vid: %s', tvid, vid);
  1004. embedSrc(node.parentNode, { tvid, vid });
  1005. self.disconnect();
  1006. _logger2.default.info('stoped observation');
  1007. }
  1008. }
  1009. } catch (err) {
  1010. _didIteratorError2 = true;
  1011. _iteratorError2 = err;
  1012. } finally {
  1013. try {
  1014. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  1015. _iterator2.return();
  1016. }
  1017. } finally {
  1018. if (_didIteratorError2) {
  1019. throw _iteratorError2;
  1020. }
  1021. }
  1022. }
  1023. }
  1024. } catch (err) {
  1025. _didIteratorError = true;
  1026. _iteratorError = err;
  1027. } finally {
  1028. try {
  1029. if (!_iteratorNormalCompletion && _iterator.return) {
  1030. _iterator.return();
  1031. }
  1032. } finally {
  1033. if (_didIteratorError) {
  1034. throw _iteratorError;
  1035. }
  1036. }
  1037. }
  1038. });
  1039.  
  1040. observer.observe(document.body || document.documentElement, { subtree: true, childList: true });
  1041. _logger2.default.info('started observation');
  1042. }
  1043.  
  1044. function adaptIframe() {
  1045. var style = `
  1046. body[class|="qypage"] {
  1047. overflow: hidden !important;
  1048. background: #000 !important;
  1049. visibility: hidden;
  1050. }
  1051.  
  1052. .mod-func {
  1053. display: none !important;
  1054. }
  1055.  
  1056. .${GM_info.script.name}.info {
  1057. width: 20em;
  1058. height: 5em;
  1059. position: absolute;
  1060. top: 0;
  1061. bottom: 0;
  1062. left: 0;
  1063. right: 0;
  1064. margin: auto;
  1065. text-align: center;
  1066. line-height: 5em;
  1067. font-size: 1em;
  1068. color: #ccc;
  1069. }
  1070.  
  1071. .${GM_info.script.name}.error {
  1072. height: 3em;
  1073. position: absolute;
  1074. top: 0;
  1075. bottom: 0;
  1076. left: 0;
  1077. right: 0;
  1078. margin: auto;
  1079. text-align: center;
  1080. font-size: 1em;
  1081. color: #c00;
  1082. }
  1083. `;
  1084.  
  1085. GM_addStyle(style);
  1086.  
  1087. _hooker2.default.hookWebFullScreen(function (exports) {
  1088. var init = exports.__proto__.init;
  1089. exports.__proto__.init = function (wrapper, btn) {
  1090. init.apply(this, [wrapper, btn]);
  1091. this.enter();
  1092.  
  1093. btn[0].style.display = 'none';
  1094. document.body.style.visibility = 'visible';
  1095. };
  1096.  
  1097. exports.__proto__.exit = function () {};
  1098. });
  1099.  
  1100. _hooker2.default.hookCore(function (exports) {
  1101. exports.prototype.hasNextVideo = function () {
  1102. return null;
  1103. };
  1104. });
  1105. }
  1106.  
  1107. exports.replaceFlash = replaceFlash;
  1108. exports.adaptIframe = adaptIframe;
  1109.  
  1110. /***/ }),
  1111. /* 8 */
  1112. /***/ (function(module, exports, __webpack_require__) {
  1113.  
  1114. module.exports = __webpack_require__(9);
  1115.  
  1116.  
  1117. /***/ }),
  1118. /* 9 */
  1119. /***/ (function(module, exports, __webpack_require__) {
  1120.  
  1121. /* WEBPACK VAR INJECTION */(function(global) {// This method of obtaining a reference to the global object needs to be
  1122. // kept identical to the way it is obtained in runtime.js
  1123. var g =
  1124. typeof global === "object" ? global :
  1125. typeof window === "object" ? window :
  1126. typeof self === "object" ? self : this;
  1127.  
  1128. // Use `getOwnPropertyNames` because not all browsers support calling
  1129. // `hasOwnProperty` on the global `self` object in a worker. See #183.
  1130. var hadRuntime = g.regeneratorRuntime &&
  1131. Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
  1132.  
  1133. // Save the old regeneratorRuntime in case it needs to be restored later.
  1134. var oldRuntime = hadRuntime && g.regeneratorRuntime;
  1135.  
  1136. // Force reevalutation of runtime.js.
  1137. g.regeneratorRuntime = undefined;
  1138.  
  1139. module.exports = __webpack_require__(10);
  1140.  
  1141. if (hadRuntime) {
  1142. // Restore the original runtime.
  1143. g.regeneratorRuntime = oldRuntime;
  1144. } else {
  1145. // Remove the global property added by runtime.js.
  1146. try {
  1147. delete g.regeneratorRuntime;
  1148. } catch(e) {
  1149. g.regeneratorRuntime = undefined;
  1150. }
  1151. }
  1152.  
  1153. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  1154.  
  1155. /***/ }),
  1156. /* 10 */
  1157. /***/ (function(module, exports, __webpack_require__) {
  1158.  
  1159. /* WEBPACK VAR INJECTION */(function(global) {/**
  1160. * Copyright (c) 2014, Facebook, Inc.
  1161. * All rights reserved.
  1162. *
  1163. * This source code is licensed under the BSD-style license found in the
  1164. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  1165. * additional grant of patent rights can be found in the PATENTS file in
  1166. * the same directory.
  1167. */
  1168.  
  1169. !(function(global) {
  1170. "use strict";
  1171.  
  1172. var Op = Object.prototype;
  1173. var hasOwn = Op.hasOwnProperty;
  1174. var undefined; // More compressible than void 0.
  1175. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  1176. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  1177. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  1178. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  1179.  
  1180. var inModule = typeof module === "object";
  1181. var runtime = global.regeneratorRuntime;
  1182. if (runtime) {
  1183. if (inModule) {
  1184. // If regeneratorRuntime is defined globally and we're in a module,
  1185. // make the exports object identical to regeneratorRuntime.
  1186. module.exports = runtime;
  1187. }
  1188. // Don't bother evaluating the rest of this file if the runtime was
  1189. // already defined globally.
  1190. return;
  1191. }
  1192.  
  1193. // Define the runtime globally (as expected by generated code) as either
  1194. // module.exports (if we're in a module) or a new, empty object.
  1195. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  1196.  
  1197. function wrap(innerFn, outerFn, self, tryLocsList) {
  1198. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  1199. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  1200. var generator = Object.create(protoGenerator.prototype);
  1201. var context = new Context(tryLocsList || []);
  1202.  
  1203. // The ._invoke method unifies the implementations of the .next,
  1204. // .throw, and .return methods.
  1205. generator._invoke = makeInvokeMethod(innerFn, self, context);
  1206.  
  1207. return generator;
  1208. }
  1209. runtime.wrap = wrap;
  1210.  
  1211. // Try/catch helper to minimize deoptimizations. Returns a completion
  1212. // record like context.tryEntries[i].completion. This interface could
  1213. // have been (and was previously) designed to take a closure to be
  1214. // invoked without arguments, but in all the cases we care about we
  1215. // already have an existing method we want to call, so there's no need
  1216. // to create a new function object. We can even get away with assuming
  1217. // the method takes exactly one argument, since that happens to be true
  1218. // in every case, so we don't have to touch the arguments object. The
  1219. // only additional allocation required is the completion record, which
  1220. // has a stable shape and so hopefully should be cheap to allocate.
  1221. function tryCatch(fn, obj, arg) {
  1222. try {
  1223. return { type: "normal", arg: fn.call(obj, arg) };
  1224. } catch (err) {
  1225. return { type: "throw", arg: err };
  1226. }
  1227. }
  1228.  
  1229. var GenStateSuspendedStart = "suspendedStart";
  1230. var GenStateSuspendedYield = "suspendedYield";
  1231. var GenStateExecuting = "executing";
  1232. var GenStateCompleted = "completed";
  1233.  
  1234. // Returning this object from the innerFn has the same effect as
  1235. // breaking out of the dispatch switch statement.
  1236. var ContinueSentinel = {};
  1237.  
  1238. // Dummy constructor functions that we use as the .constructor and
  1239. // .constructor.prototype properties for functions that return Generator
  1240. // objects. For full spec compliance, you may wish to configure your
  1241. // minifier not to mangle the names of these two functions.
  1242. function Generator() {}
  1243. function GeneratorFunction() {}
  1244. function GeneratorFunctionPrototype() {}
  1245.  
  1246. // This is a polyfill for %IteratorPrototype% for environments that
  1247. // don't natively support it.
  1248. var IteratorPrototype = {};
  1249. IteratorPrototype[iteratorSymbol] = function () {
  1250. return this;
  1251. };
  1252.  
  1253. var getProto = Object.getPrototypeOf;
  1254. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  1255. if (NativeIteratorPrototype &&
  1256. NativeIteratorPrototype !== Op &&
  1257. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  1258. // This environment has a native %IteratorPrototype%; use it instead
  1259. // of the polyfill.
  1260. IteratorPrototype = NativeIteratorPrototype;
  1261. }
  1262.  
  1263. var Gp = GeneratorFunctionPrototype.prototype =
  1264. Generator.prototype = Object.create(IteratorPrototype);
  1265. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  1266. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  1267. GeneratorFunctionPrototype[toStringTagSymbol] =
  1268. GeneratorFunction.displayName = "GeneratorFunction";
  1269.  
  1270. // Helper for defining the .next, .throw, and .return methods of the
  1271. // Iterator interface in terms of a single ._invoke method.
  1272. function defineIteratorMethods(prototype) {
  1273. ["next", "throw", "return"].forEach(function(method) {
  1274. prototype[method] = function(arg) {
  1275. return this._invoke(method, arg);
  1276. };
  1277. });
  1278. }
  1279.  
  1280. runtime.isGeneratorFunction = function(genFun) {
  1281. var ctor = typeof genFun === "function" && genFun.constructor;
  1282. return ctor
  1283. ? ctor === GeneratorFunction ||
  1284. // For the native GeneratorFunction constructor, the best we can
  1285. // do is to check its .name property.
  1286. (ctor.displayName || ctor.name) === "GeneratorFunction"
  1287. : false;
  1288. };
  1289.  
  1290. runtime.mark = function(genFun) {
  1291. if (Object.setPrototypeOf) {
  1292. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  1293. } else {
  1294. genFun.__proto__ = GeneratorFunctionPrototype;
  1295. if (!(toStringTagSymbol in genFun)) {
  1296. genFun[toStringTagSymbol] = "GeneratorFunction";
  1297. }
  1298. }
  1299. genFun.prototype = Object.create(Gp);
  1300. return genFun;
  1301. };
  1302.  
  1303. // Within the body of any async function, `await x` is transformed to
  1304. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  1305. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  1306. // meant to be awaited.
  1307. runtime.awrap = function(arg) {
  1308. return { __await: arg };
  1309. };
  1310.  
  1311. function AsyncIterator(generator) {
  1312. function invoke(method, arg, resolve, reject) {
  1313. var record = tryCatch(generator[method], generator, arg);
  1314. if (record.type === "throw") {
  1315. reject(record.arg);
  1316. } else {
  1317. var result = record.arg;
  1318. var value = result.value;
  1319. if (value &&
  1320. typeof value === "object" &&
  1321. hasOwn.call(value, "__await")) {
  1322. return Promise.resolve(value.__await).then(function(value) {
  1323. invoke("next", value, resolve, reject);
  1324. }, function(err) {
  1325. invoke("throw", err, resolve, reject);
  1326. });
  1327. }
  1328.  
  1329. return Promise.resolve(value).then(function(unwrapped) {
  1330. // When a yielded Promise is resolved, its final value becomes
  1331. // the .value of the Promise<{value,done}> result for the
  1332. // current iteration. If the Promise is rejected, however, the
  1333. // result for this iteration will be rejected with the same
  1334. // reason. Note that rejections of yielded Promises are not
  1335. // thrown back into the generator function, as is the case
  1336. // when an awaited Promise is rejected. This difference in
  1337. // behavior between yield and await is important, because it
  1338. // allows the consumer to decide what to do with the yielded
  1339. // rejection (swallow it and continue, manually .throw it back
  1340. // into the generator, abandon iteration, whatever). With
  1341. // await, by contrast, there is no opportunity to examine the
  1342. // rejection reason outside the generator function, so the
  1343. // only option is to throw it from the await expression, and
  1344. // let the generator function handle the exception.
  1345. result.value = unwrapped;
  1346. resolve(result);
  1347. }, reject);
  1348. }
  1349. }
  1350.  
  1351. if (typeof global.process === "object" && global.process.domain) {
  1352. invoke = global.process.domain.bind(invoke);
  1353. }
  1354.  
  1355. var previousPromise;
  1356.  
  1357. function enqueue(method, arg) {
  1358. function callInvokeWithMethodAndArg() {
  1359. return new Promise(function(resolve, reject) {
  1360. invoke(method, arg, resolve, reject);
  1361. });
  1362. }
  1363.  
  1364. return previousPromise =
  1365. // If enqueue has been called before, then we want to wait until
  1366. // all previous Promises have been resolved before calling invoke,
  1367. // so that results are always delivered in the correct order. If
  1368. // enqueue has not been called before, then it is important to
  1369. // call invoke immediately, without waiting on a callback to fire,
  1370. // so that the async generator function has the opportunity to do
  1371. // any necessary setup in a predictable way. This predictability
  1372. // is why the Promise constructor synchronously invokes its
  1373. // executor callback, and why async functions synchronously
  1374. // execute code before the first await. Since we implement simple
  1375. // async functions in terms of async generators, it is especially
  1376. // important to get this right, even though it requires care.
  1377. previousPromise ? previousPromise.then(
  1378. callInvokeWithMethodAndArg,
  1379. // Avoid propagating failures to Promises returned by later
  1380. // invocations of the iterator.
  1381. callInvokeWithMethodAndArg
  1382. ) : callInvokeWithMethodAndArg();
  1383. }
  1384.  
  1385. // Define the unified helper method that is used to implement .next,
  1386. // .throw, and .return (see defineIteratorMethods).
  1387. this._invoke = enqueue;
  1388. }
  1389.  
  1390. defineIteratorMethods(AsyncIterator.prototype);
  1391. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  1392. return this;
  1393. };
  1394. runtime.AsyncIterator = AsyncIterator;
  1395.  
  1396. // Note that simple async functions are implemented on top of
  1397. // AsyncIterator objects; they just return a Promise for the value of
  1398. // the final result produced by the iterator.
  1399. runtime.async = function(innerFn, outerFn, self, tryLocsList) {
  1400. var iter = new AsyncIterator(
  1401. wrap(innerFn, outerFn, self, tryLocsList)
  1402. );
  1403.  
  1404. return runtime.isGeneratorFunction(outerFn)
  1405. ? iter // If outerFn is a generator, return the full iterator.
  1406. : iter.next().then(function(result) {
  1407. return result.done ? result.value : iter.next();
  1408. });
  1409. };
  1410.  
  1411. function makeInvokeMethod(innerFn, self, context) {
  1412. var state = GenStateSuspendedStart;
  1413.  
  1414. return function invoke(method, arg) {
  1415. if (state === GenStateExecuting) {
  1416. throw new Error("Generator is already running");
  1417. }
  1418.  
  1419. if (state === GenStateCompleted) {
  1420. if (method === "throw") {
  1421. throw arg;
  1422. }
  1423.  
  1424. // Be forgiving, per 25.3.3.3.3 of the spec:
  1425. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  1426. return doneResult();
  1427. }
  1428.  
  1429. context.method = method;
  1430. context.arg = arg;
  1431.  
  1432. while (true) {
  1433. var delegate = context.delegate;
  1434. if (delegate) {
  1435. var delegateResult = maybeInvokeDelegate(delegate, context);
  1436. if (delegateResult) {
  1437. if (delegateResult === ContinueSentinel) continue;
  1438. return delegateResult;
  1439. }
  1440. }
  1441.  
  1442. if (context.method === "next") {
  1443. // Setting context._sent for legacy support of Babel's
  1444. // function.sent implementation.
  1445. context.sent = context._sent = context.arg;
  1446.  
  1447. } else if (context.method === "throw") {
  1448. if (state === GenStateSuspendedStart) {
  1449. state = GenStateCompleted;
  1450. throw context.arg;
  1451. }
  1452.  
  1453. context.dispatchException(context.arg);
  1454.  
  1455. } else if (context.method === "return") {
  1456. context.abrupt("return", context.arg);
  1457. }
  1458.  
  1459. state = GenStateExecuting;
  1460.  
  1461. var record = tryCatch(innerFn, self, context);
  1462. if (record.type === "normal") {
  1463. // If an exception is thrown from innerFn, we leave state ===
  1464. // GenStateExecuting and loop back for another invocation.
  1465. state = context.done
  1466. ? GenStateCompleted
  1467. : GenStateSuspendedYield;
  1468.  
  1469. if (record.arg === ContinueSentinel) {
  1470. continue;
  1471. }
  1472.  
  1473. return {
  1474. value: record.arg,
  1475. done: context.done
  1476. };
  1477.  
  1478. } else if (record.type === "throw") {
  1479. state = GenStateCompleted;
  1480. // Dispatch the exception by looping back around to the
  1481. // context.dispatchException(context.arg) call above.
  1482. context.method = "throw";
  1483. context.arg = record.arg;
  1484. }
  1485. }
  1486. };
  1487. }
  1488.  
  1489. // Call delegate.iterator[context.method](context.arg) and handle the
  1490. // result, either by returning a { value, done } result from the
  1491. // delegate iterator, or by modifying context.method and context.arg,
  1492. // setting context.delegate to null, and returning the ContinueSentinel.
  1493. function maybeInvokeDelegate(delegate, context) {
  1494. var method = delegate.iterator[context.method];
  1495. if (method === undefined) {
  1496. // A .throw or .return when the delegate iterator has no .throw
  1497. // method always terminates the yield* loop.
  1498. context.delegate = null;
  1499.  
  1500. if (context.method === "throw") {
  1501. if (delegate.iterator.return) {
  1502. // If the delegate iterator has a return method, give it a
  1503. // chance to clean up.
  1504. context.method = "return";
  1505. context.arg = undefined;
  1506. maybeInvokeDelegate(delegate, context);
  1507.  
  1508. if (context.method === "throw") {
  1509. // If maybeInvokeDelegate(context) changed context.method from
  1510. // "return" to "throw", let that override the TypeError below.
  1511. return ContinueSentinel;
  1512. }
  1513. }
  1514.  
  1515. context.method = "throw";
  1516. context.arg = new TypeError(
  1517. "The iterator does not provide a 'throw' method");
  1518. }
  1519.  
  1520. return ContinueSentinel;
  1521. }
  1522.  
  1523. var record = tryCatch(method, delegate.iterator, context.arg);
  1524.  
  1525. if (record.type === "throw") {
  1526. context.method = "throw";
  1527. context.arg = record.arg;
  1528. context.delegate = null;
  1529. return ContinueSentinel;
  1530. }
  1531.  
  1532. var info = record.arg;
  1533.  
  1534. if (! info) {
  1535. context.method = "throw";
  1536. context.arg = new TypeError("iterator result is not an object");
  1537. context.delegate = null;
  1538. return ContinueSentinel;
  1539. }
  1540.  
  1541. if (info.done) {
  1542. // Assign the result of the finished delegate to the temporary
  1543. // variable specified by delegate.resultName (see delegateYield).
  1544. context[delegate.resultName] = info.value;
  1545.  
  1546. // Resume execution at the desired location (see delegateYield).
  1547. context.next = delegate.nextLoc;
  1548.  
  1549. // If context.method was "throw" but the delegate handled the
  1550. // exception, let the outer generator proceed normally. If
  1551. // context.method was "next", forget context.arg since it has been
  1552. // "consumed" by the delegate iterator. If context.method was
  1553. // "return", allow the original .return call to continue in the
  1554. // outer generator.
  1555. if (context.method !== "return") {
  1556. context.method = "next";
  1557. context.arg = undefined;
  1558. }
  1559.  
  1560. } else {
  1561. // Re-yield the result returned by the delegate method.
  1562. return info;
  1563. }
  1564.  
  1565. // The delegate iterator is finished, so forget it and continue with
  1566. // the outer generator.
  1567. context.delegate = null;
  1568. return ContinueSentinel;
  1569. }
  1570.  
  1571. // Define Generator.prototype.{next,throw,return} in terms of the
  1572. // unified ._invoke helper method.
  1573. defineIteratorMethods(Gp);
  1574.  
  1575. Gp[toStringTagSymbol] = "Generator";
  1576.  
  1577. // A Generator should always return itself as the iterator object when the
  1578. // @@iterator function is called on it. Some browsers' implementations of the
  1579. // iterator prototype chain incorrectly implement this, causing the Generator
  1580. // object to not be returned from this call. This ensures that doesn't happen.
  1581. // See https://github.com/facebook/regenerator/issues/274 for more details.
  1582. Gp[iteratorSymbol] = function() {
  1583. return this;
  1584. };
  1585.  
  1586. Gp.toString = function() {
  1587. return "[object Generator]";
  1588. };
  1589.  
  1590. function pushTryEntry(locs) {
  1591. var entry = { tryLoc: locs[0] };
  1592.  
  1593. if (1 in locs) {
  1594. entry.catchLoc = locs[1];
  1595. }
  1596.  
  1597. if (2 in locs) {
  1598. entry.finallyLoc = locs[2];
  1599. entry.afterLoc = locs[3];
  1600. }
  1601.  
  1602. this.tryEntries.push(entry);
  1603. }
  1604.  
  1605. function resetTryEntry(entry) {
  1606. var record = entry.completion || {};
  1607. record.type = "normal";
  1608. delete record.arg;
  1609. entry.completion = record;
  1610. }
  1611.  
  1612. function Context(tryLocsList) {
  1613. // The root entry object (effectively a try statement without a catch
  1614. // or a finally block) gives us a place to store values thrown from
  1615. // locations where there is no enclosing try statement.
  1616. this.tryEntries = [{ tryLoc: "root" }];
  1617. tryLocsList.forEach(pushTryEntry, this);
  1618. this.reset(true);
  1619. }
  1620.  
  1621. runtime.keys = function(object) {
  1622. var keys = [];
  1623. for (var key in object) {
  1624. keys.push(key);
  1625. }
  1626. keys.reverse();
  1627.  
  1628. // Rather than returning an object with a next method, we keep
  1629. // things simple and return the next function itself.
  1630. return function next() {
  1631. while (keys.length) {
  1632. var key = keys.pop();
  1633. if (key in object) {
  1634. next.value = key;
  1635. next.done = false;
  1636. return next;
  1637. }
  1638. }
  1639.  
  1640. // To avoid creating an additional object, we just hang the .value
  1641. // and .done properties off the next function object itself. This
  1642. // also ensures that the minifier will not anonymize the function.
  1643. next.done = true;
  1644. return next;
  1645. };
  1646. };
  1647.  
  1648. function values(iterable) {
  1649. if (iterable) {
  1650. var iteratorMethod = iterable[iteratorSymbol];
  1651. if (iteratorMethod) {
  1652. return iteratorMethod.call(iterable);
  1653. }
  1654.  
  1655. if (typeof iterable.next === "function") {
  1656. return iterable;
  1657. }
  1658.  
  1659. if (!isNaN(iterable.length)) {
  1660. var i = -1, next = function next() {
  1661. while (++i < iterable.length) {
  1662. if (hasOwn.call(iterable, i)) {
  1663. next.value = iterable[i];
  1664. next.done = false;
  1665. return next;
  1666. }
  1667. }
  1668.  
  1669. next.value = undefined;
  1670. next.done = true;
  1671.  
  1672. return next;
  1673. };
  1674.  
  1675. return next.next = next;
  1676. }
  1677. }
  1678.  
  1679. // Return an iterator with no values.
  1680. return { next: doneResult };
  1681. }
  1682. runtime.values = values;
  1683.  
  1684. function doneResult() {
  1685. return { value: undefined, done: true };
  1686. }
  1687.  
  1688. Context.prototype = {
  1689. constructor: Context,
  1690.  
  1691. reset: function(skipTempReset) {
  1692. this.prev = 0;
  1693. this.next = 0;
  1694. // Resetting context._sent for legacy support of Babel's
  1695. // function.sent implementation.
  1696. this.sent = this._sent = undefined;
  1697. this.done = false;
  1698. this.delegate = null;
  1699.  
  1700. this.method = "next";
  1701. this.arg = undefined;
  1702.  
  1703. this.tryEntries.forEach(resetTryEntry);
  1704.  
  1705. if (!skipTempReset) {
  1706. for (var name in this) {
  1707. // Not sure about the optimal order of these conditions:
  1708. if (name.charAt(0) === "t" &&
  1709. hasOwn.call(this, name) &&
  1710. !isNaN(+name.slice(1))) {
  1711. this[name] = undefined;
  1712. }
  1713. }
  1714. }
  1715. },
  1716.  
  1717. stop: function() {
  1718. this.done = true;
  1719.  
  1720. var rootEntry = this.tryEntries[0];
  1721. var rootRecord = rootEntry.completion;
  1722. if (rootRecord.type === "throw") {
  1723. throw rootRecord.arg;
  1724. }
  1725.  
  1726. return this.rval;
  1727. },
  1728.  
  1729. dispatchException: function(exception) {
  1730. if (this.done) {
  1731. throw exception;
  1732. }
  1733.  
  1734. var context = this;
  1735. function handle(loc, caught) {
  1736. record.type = "throw";
  1737. record.arg = exception;
  1738. context.next = loc;
  1739.  
  1740. if (caught) {
  1741. // If the dispatched exception was caught by a catch block,
  1742. // then let that catch block handle the exception normally.
  1743. context.method = "next";
  1744. context.arg = undefined;
  1745. }
  1746.  
  1747. return !! caught;
  1748. }
  1749.  
  1750. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1751. var entry = this.tryEntries[i];
  1752. var record = entry.completion;
  1753.  
  1754. if (entry.tryLoc === "root") {
  1755. // Exception thrown outside of any try block that could handle
  1756. // it, so set the completion value of the entire function to
  1757. // throw the exception.
  1758. return handle("end");
  1759. }
  1760.  
  1761. if (entry.tryLoc <= this.prev) {
  1762. var hasCatch = hasOwn.call(entry, "catchLoc");
  1763. var hasFinally = hasOwn.call(entry, "finallyLoc");
  1764.  
  1765. if (hasCatch && hasFinally) {
  1766. if (this.prev < entry.catchLoc) {
  1767. return handle(entry.catchLoc, true);
  1768. } else if (this.prev < entry.finallyLoc) {
  1769. return handle(entry.finallyLoc);
  1770. }
  1771.  
  1772. } else if (hasCatch) {
  1773. if (this.prev < entry.catchLoc) {
  1774. return handle(entry.catchLoc, true);
  1775. }
  1776.  
  1777. } else if (hasFinally) {
  1778. if (this.prev < entry.finallyLoc) {
  1779. return handle(entry.finallyLoc);
  1780. }
  1781.  
  1782. } else {
  1783. throw new Error("try statement without catch or finally");
  1784. }
  1785. }
  1786. }
  1787. },
  1788.  
  1789. abrupt: function(type, arg) {
  1790. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1791. var entry = this.tryEntries[i];
  1792. if (entry.tryLoc <= this.prev &&
  1793. hasOwn.call(entry, "finallyLoc") &&
  1794. this.prev < entry.finallyLoc) {
  1795. var finallyEntry = entry;
  1796. break;
  1797. }
  1798. }
  1799.  
  1800. if (finallyEntry &&
  1801. (type === "break" ||
  1802. type === "continue") &&
  1803. finallyEntry.tryLoc <= arg &&
  1804. arg <= finallyEntry.finallyLoc) {
  1805. // Ignore the finally entry if control is not jumping to a
  1806. // location outside the try/catch block.
  1807. finallyEntry = null;
  1808. }
  1809.  
  1810. var record = finallyEntry ? finallyEntry.completion : {};
  1811. record.type = type;
  1812. record.arg = arg;
  1813.  
  1814. if (finallyEntry) {
  1815. this.method = "next";
  1816. this.next = finallyEntry.finallyLoc;
  1817. return ContinueSentinel;
  1818. }
  1819.  
  1820. return this.complete(record);
  1821. },
  1822.  
  1823. complete: function(record, afterLoc) {
  1824. if (record.type === "throw") {
  1825. throw record.arg;
  1826. }
  1827.  
  1828. if (record.type === "break" ||
  1829. record.type === "continue") {
  1830. this.next = record.arg;
  1831. } else if (record.type === "return") {
  1832. this.rval = this.arg = record.arg;
  1833. this.method = "return";
  1834. this.next = "end";
  1835. } else if (record.type === "normal" && afterLoc) {
  1836. this.next = afterLoc;
  1837. }
  1838.  
  1839. return ContinueSentinel;
  1840. },
  1841.  
  1842. finish: function(finallyLoc) {
  1843. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1844. var entry = this.tryEntries[i];
  1845. if (entry.finallyLoc === finallyLoc) {
  1846. this.complete(entry.completion, entry.afterLoc);
  1847. resetTryEntry(entry);
  1848. return ContinueSentinel;
  1849. }
  1850. }
  1851. },
  1852.  
  1853. "catch": function(tryLoc) {
  1854. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1855. var entry = this.tryEntries[i];
  1856. if (entry.tryLoc === tryLoc) {
  1857. var record = entry.completion;
  1858. if (record.type === "throw") {
  1859. var thrown = record.arg;
  1860. resetTryEntry(entry);
  1861. }
  1862. return thrown;
  1863. }
  1864. }
  1865.  
  1866. // The context.catch method must only be called with a location
  1867. // argument that corresponds to a known catch block.
  1868. throw new Error("illegal catch attempt");
  1869. },
  1870.  
  1871. delegateYield: function(iterable, resultName, nextLoc) {
  1872. this.delegate = {
  1873. iterator: values(iterable),
  1874. resultName: resultName,
  1875. nextLoc: nextLoc
  1876. };
  1877.  
  1878. if (this.method === "next") {
  1879. // Deliberately forget the last sent value so that we don't
  1880. // accidentally pass it on to the delegate.
  1881. this.arg = undefined;
  1882. }
  1883.  
  1884. return ContinueSentinel;
  1885. }
  1886. };
  1887. })(
  1888. // Among the various tricks for obtaining a reference to the global
  1889. // object, this seems to be the most reliable technique that does not
  1890. // use indirect eval (which violates Content Security Policy).
  1891. typeof global === "object" ? global :
  1892. typeof window === "object" ? window :
  1893. typeof self === "object" ? self : this
  1894. );
  1895.  
  1896. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  1897.  
  1898. /***/ }),
  1899. /* 11 */
  1900. /***/ (function(module, exports, __webpack_require__) {
  1901.  
  1902. "use strict";
  1903.  
  1904.  
  1905. Object.defineProperty(exports, "__esModule", {
  1906. value: true
  1907. });
  1908.  
  1909. function getVideoUrl(tvid, vid) {
  1910. return new Promise(function (resolve, reject) {
  1911. GM_xmlhttpRequest({
  1912. url: `http://cache.video.qiyi.com/jp/vi/${tvid}/${vid}/?callback=callback`,
  1913. method: 'GET',
  1914. timeout: 8e3,
  1915. onload: function onload(details) {
  1916. try {
  1917. var json = JSON.parse(/callback\s*\(\s*(\{.*\})\s*\)/.exec(details.responseText)[1]);
  1918. resolve(json.vu);
  1919. } catch (err) {
  1920. reject(err);
  1921. }
  1922. },
  1923. onerror: reject,
  1924. onabort: reject,
  1925. ontimeout: reject
  1926. });
  1927. });
  1928. }
  1929.  
  1930. function findVid(text) {
  1931. var result = /vid=([\da-z]+)/i.exec(text);
  1932. return result ? result[1] : null;
  1933. }
  1934.  
  1935. function findTvid(text) {
  1936. var result = /tvid=(\d+)/i.exec(text);
  1937. return result ? result[1] : null;
  1938. }
  1939.  
  1940. exports.getVideoUrl = getVideoUrl;
  1941. exports.findVid = findVid;
  1942. exports.findTvid = findTvid;
  1943.  
  1944. /***/ }),
  1945. /* 12 */
  1946. /***/ (function(module, exports, __webpack_require__) {
  1947.  
  1948. "use strict";
  1949.  
  1950.  
  1951. Object.defineProperty(exports, "__esModule", {
  1952. value: true
  1953. });
  1954. exports.useWebSocketLoaderPatch = exports.mouseShortcutsPatch = exports.keyShortcutsPatch = exports.keepHookingPatch = exports.watermarksPatch = exports.controlsPatch = exports.adsPatch = exports.vipPatch = undefined;
  1955.  
  1956. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1957.  
  1958. var _logger = __webpack_require__(1);
  1959.  
  1960. var _logger2 = _interopRequireDefault(_logger);
  1961.  
  1962. var _hooker = __webpack_require__(0);
  1963.  
  1964. var _hooker2 = _interopRequireDefault(_hooker);
  1965.  
  1966. var _fullscreen = __webpack_require__(13);
  1967.  
  1968. var _webFullscreen = __webpack_require__(14);
  1969.  
  1970. var _parsedData = __webpack_require__(15);
  1971.  
  1972. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1973.  
  1974. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1975.  
  1976. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1977.  
  1978. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1979.  
  1980. var Patch = function () {
  1981. function Patch() {
  1982. _classCallCheck(this, Patch);
  1983.  
  1984. this._installed = false;
  1985. }
  1986.  
  1987. _createClass(Patch, [{
  1988. key: 'install',
  1989. value: function install() {
  1990. if (!this._installed) {
  1991. this._installed = true;
  1992. this._prepare();
  1993. this._apply();
  1994. }
  1995. }
  1996. }, {
  1997. key: '_prepare',
  1998. value: function _prepare() {}
  1999. }, {
  2000. key: '_apply',
  2001. value: function _apply() {}
  2002. }]);
  2003.  
  2004. return Patch;
  2005. }();
  2006.  
  2007. var VipPatch = function (_Patch) {
  2008. _inherits(VipPatch, _Patch);
  2009.  
  2010. function VipPatch() {
  2011. _classCallCheck(this, VipPatch);
  2012.  
  2013. return _possibleConstructorReturn(this, (VipPatch.__proto__ || Object.getPrototypeOf(VipPatch)).call(this));
  2014. }
  2015.  
  2016. _createClass(VipPatch, [{
  2017. key: '_apply',
  2018. value: function _apply() {
  2019. _hooker2.default.hookUser(function (exports) {
  2020. var proto = exports.__proto__;
  2021. proto.isVipSync = function () {
  2022. return true;
  2023. };
  2024. proto.isVip = function (cb) {
  2025. return setTimeout(cb, 0, true);
  2026. };
  2027. _logger2.default.info('The vip patch has been installed');
  2028. });
  2029. }
  2030. }]);
  2031.  
  2032. return VipPatch;
  2033. }(Patch);
  2034.  
  2035. var AdsPatch = function (_Patch2) {
  2036. _inherits(AdsPatch, _Patch2);
  2037.  
  2038. function AdsPatch() {
  2039. _classCallCheck(this, AdsPatch);
  2040.  
  2041. return _possibleConstructorReturn(this, (AdsPatch.__proto__ || Object.getPrototypeOf(AdsPatch)).call(this));
  2042. }
  2043.  
  2044. _createClass(AdsPatch, [{
  2045. key: '_fakeAdsData',
  2046. value: function _fakeAdsData() {
  2047. return {};
  2048. }
  2049. }, {
  2050. key: '_apply',
  2051. value: function _apply() {
  2052. var _this3 = this;
  2053.  
  2054. _hooker2.default.hookShowRequest(function (exports) {
  2055. var proto = exports.prototype;
  2056. proto.request = function (cb) {
  2057. return setTimeout(cb, 0, _this3._fakeAdsData());
  2058. };
  2059. _logger2.default.info('The ads patch has been installed');
  2060. });
  2061. }
  2062. }]);
  2063.  
  2064. return AdsPatch;
  2065. }(Patch);
  2066.  
  2067. var WatermarksPatch = function (_Patch3) {
  2068. _inherits(WatermarksPatch, _Patch3);
  2069.  
  2070. function WatermarksPatch() {
  2071. _classCallCheck(this, WatermarksPatch);
  2072.  
  2073. return _possibleConstructorReturn(this, (WatermarksPatch.__proto__ || Object.getPrototypeOf(WatermarksPatch)).call(this));
  2074. }
  2075.  
  2076. _createClass(WatermarksPatch, [{
  2077. key: '_apply',
  2078. value: function _apply() {
  2079. _hooker2.default.hookLogo(function (exports) {
  2080. exports.prototype.showLogo = function () {};
  2081. _logger2.default.info('The watermarks patch has been installed');
  2082. });
  2083. }
  2084. }]);
  2085.  
  2086. return WatermarksPatch;
  2087. }(Patch);
  2088.  
  2089. var ControlsPatch = function (_Patch4) {
  2090. _inherits(ControlsPatch, _Patch4);
  2091.  
  2092. // Prevent the player controls were disabled.
  2093. function ControlsPatch() {
  2094. _classCallCheck(this, ControlsPatch);
  2095.  
  2096. return _possibleConstructorReturn(this, (ControlsPatch.__proto__ || Object.getPrototypeOf(ControlsPatch)).call(this));
  2097. }
  2098.  
  2099. _createClass(ControlsPatch, [{
  2100. key: '_apply',
  2101. value: function _apply() {
  2102. _hooker2.default.hookSkinBase(function (exports) {
  2103. exports.prototype._checkPlugin = function () {}; // This function disables the player controls when playing ads and enables when done.
  2104. _logger2.default.info('The controls patch has been installed');
  2105. });
  2106. }
  2107. }]);
  2108.  
  2109. return ControlsPatch;
  2110. }(Patch);
  2111.  
  2112. var CorePatch = function (_Patch5) {
  2113. _inherits(CorePatch, _Patch5);
  2114.  
  2115. function CorePatch() {
  2116. _classCallCheck(this, CorePatch);
  2117.  
  2118. return _possibleConstructorReturn(this, (CorePatch.__proto__ || Object.getPrototypeOf(CorePatch)).call(this));
  2119. }
  2120.  
  2121. _createClass(CorePatch, [{
  2122. key: '_prepare',
  2123. value: function _prepare() {
  2124. this._initShowTip();
  2125. this._initPlaybackRate();
  2126. }
  2127. }, {
  2128. key: '_initShowTip',
  2129. value: function _initShowTip() {
  2130. _hooker2.default.hookPluginControlsInit(function (that) {
  2131. that.core.on('showtip', function (event) {
  2132. that.setcontroltip.apply(that, [{ str: event.data, x: that._process.offset().left, y: 3, cut: true, timeout: true }]);
  2133. if (that.$plugin.hasClass('process_hidden')) {
  2134. that._controltips.css('top', '-25px');
  2135. } else if (that.$plugin.hasClass('bottom-hide')) {
  2136. that._controltips.css('top', '-38px');
  2137. }
  2138. });
  2139. });
  2140. }
  2141. }, {
  2142. key: '_initPlaybackRate',
  2143. value: function _initPlaybackRate() {
  2144. _hooker2.default.hookPluginControls(function (exports) {
  2145. exports.prototype.initPlaybackRate = function () {
  2146. var core = this.core;
  2147.  
  2148. var rate = parseFloat(localStorage.getItem('QiyiPlayerPlaybackRate'));
  2149. rate = isNaN(rate) ? 1 : rate;
  2150.  
  2151. if (core.getCurrStatus() === 'playing') {
  2152. core.setPlaybackRate(rate);
  2153. } else {
  2154. var onstatuschanged = function onstatuschanged(evt) {
  2155. if (evt.data.state === 'playing') {
  2156. core.setPlaybackRate(rate);
  2157. core.un('statusChanged', onstatuschanged);
  2158. }
  2159. };
  2160. core.on('statusChanged', onstatuschanged);
  2161. }
  2162.  
  2163. var $ul = this.$playbackrateUl;
  2164. $ul.find(`[data-pbrate="${rate}"]`).addClass('selected');
  2165.  
  2166. var $items = $ul.find('li');
  2167. $items.on('click', function () {
  2168. var rate = parseFloat(this.getAttribute('data-pbrate'));
  2169. if (!this.classList.contains('selected')) {
  2170. $items.removeClass('selected');
  2171. this.classList.add('selected');
  2172. }
  2173. localStorage.setItem('QiyiPlayerPlaybackRate', rate);
  2174. core.setPlaybackRate(rate);
  2175. });
  2176.  
  2177. this.$playsettingicon.on('click', function () {
  2178. var rate = core.getPlaybackRate();
  2179. var $item = $ul.find(`[data-pbrate="${rate}"]`);
  2180. if ($item.length === 1) {
  2181. if (!$item.hasClass('selected')) {
  2182. $items.removeClass('selected');
  2183. $item.addClass('selected');
  2184. }
  2185. } else {
  2186. $items.removeClass('selected');
  2187. }
  2188. });
  2189. };
  2190. });
  2191. }
  2192. }, {
  2193. key: '_apply',
  2194. value: function _apply() {
  2195. _hooker2.default.hookCore(function (exports) {
  2196. var proto = exports.prototype;
  2197.  
  2198. proto._showTip = function (msg) {
  2199. this.fire({ type: 'showtip', data: msg });
  2200. };
  2201.  
  2202. proto.getFPS = function () {
  2203. if (_parsedData.flvInfo) {
  2204. return _parsedData.flvInfo.videoConfigTag.sps.frame_rate.fps;
  2205. } else {
  2206. return 25; // f4v极速以上,动画23.976、电影24、电视剧25。
  2207. }
  2208. };
  2209.  
  2210. proto.prevFrame = function () {
  2211. var video = this.video();
  2212. var seekTime = Math.max(0, Math.min(this.getDuration(), video.currentTime - 1 / this.getFPS()));
  2213. video.currentTime = seekTime;
  2214. this._showTip('上一帧');
  2215. };
  2216.  
  2217. proto.nextFrame = function () {
  2218. var video = this.video();
  2219. var seekTime = Math.max(0, Math.min(this.getDuration(), video.currentTime + 1 / this.getFPS()));
  2220. video.currentTime = seekTime;
  2221. this._showTip('下一帧');
  2222. };
  2223.  
  2224. proto.seek = function () {
  2225. var _engine;
  2226.  
  2227. var video = this.video();
  2228. var playbackRate = video.playbackRate;
  2229. (_engine = this._engine).seek.apply(_engine, arguments);
  2230. video.playbackRate = playbackRate;
  2231. };
  2232.  
  2233. proto.stepSeek = function (stepTime) {
  2234. var seekTime = Math.max(0, Math.min(this.getDuration(), this.getCurrenttime() + stepTime));
  2235. var msg = void 0;
  2236.  
  2237. if (Math.abs(stepTime) < 60) {
  2238. msg = stepTime > 0 ? `步进:${stepTime}秒` : `步退:${Math.abs(stepTime)}秒`;
  2239. } else {
  2240. msg = stepTime > 0 ? `步进:${stepTime / 60}分钟` : `步退:${Math.abs(stepTime) / 60}分钟`;
  2241. }
  2242. this._showTip(msg);
  2243.  
  2244. this.seek(seekTime, true);
  2245. };
  2246.  
  2247. proto.rangeSeek = function (range) {
  2248. var duration = this.getDuration();
  2249. var seekTime = Math.max(0, Math.min(duration, duration * range));
  2250. this.seek(seekTime, true);
  2251. this._showTip('定位:' + (range * 100).toFixed(0) + '%');
  2252. };
  2253.  
  2254. proto.toggleMute = function () {
  2255. if (this.getMuted()) {
  2256. this.setMuted(false);
  2257. this._showTip('取消静音');
  2258. } else {
  2259. this.setMuted(true);
  2260. this._showTip('静音');
  2261. }
  2262. };
  2263.  
  2264. proto.adjustVolume = function (value) {
  2265. var volume = this.getVolume() + value;
  2266. volume = Math.max(0, Math.min(1, volume.toFixed(2)));
  2267. this.setVolume(volume);
  2268. this.fire({ type: 'keyvolumechange' });
  2269. };
  2270.  
  2271. proto.getPlaybackRate = function () {
  2272. // iqiyi 的这个方法有bug,没把值返回!
  2273. return this._engine.getPlaybackRate();
  2274. };
  2275.  
  2276. proto.adjustPlaybackRate = function (value) {
  2277. var currRate = this.getPlaybackRate();
  2278. var rate = Math.max(0.2, Math.min(5, parseFloat((currRate + value).toFixed(1))));
  2279.  
  2280. localStorage.setItem('QiyiPlayerPlaybackRate', rate);
  2281. this.setPlaybackRate(rate);
  2282. this._showTip(`播放速率:${rate}`);
  2283. };
  2284.  
  2285. proto.turnPlaybackRate = function () {
  2286. var currRate = this.getPlaybackRate();
  2287. var rate = void 0;
  2288. if (currRate !== 1) {
  2289. this._backRate = currRate;
  2290. rate = 1;
  2291. } else {
  2292. rate = this._backRate || 1;
  2293. }
  2294.  
  2295. this.setPlaybackRate(rate);
  2296. this._showTip(`播放速率:${rate}`);
  2297. };
  2298.  
  2299. proto.hasPrevVideo = function () {
  2300. return this._getVideoIndexInList(this._movieinfo.tvid) > 0 || this._getVideoIndexInList(this._movieinfo.oldTvid) > 0;
  2301. };
  2302.  
  2303. proto.playNext = function () {
  2304. if (this.hasNextVideo()) {
  2305. this._showTip('播放下一集');
  2306. this.switchNextVideo();
  2307. } else {
  2308. this._showTip('没有下一集哦');
  2309. }
  2310. };
  2311.  
  2312. proto.playPrev = function () {
  2313. if (this.hasPrevVideo()) {
  2314. this._showTip('播放上一集');
  2315. this.switchPreVideo();
  2316. } else {
  2317. this._showTip('没有上一集哦');
  2318. }
  2319. };
  2320.  
  2321. _logger2.default.info('The core patch has been installed');
  2322. });
  2323. }
  2324. }]);
  2325.  
  2326. return CorePatch;
  2327. }(Patch);
  2328.  
  2329. var corePatch = new CorePatch();
  2330.  
  2331. var KeyShortcutsPatch = function (_Patch6) {
  2332. _inherits(KeyShortcutsPatch, _Patch6);
  2333.  
  2334. function KeyShortcutsPatch() {
  2335. _classCallCheck(this, KeyShortcutsPatch);
  2336.  
  2337. return _possibleConstructorReturn(this, (KeyShortcutsPatch.__proto__ || Object.getPrototypeOf(KeyShortcutsPatch)).call(this));
  2338. }
  2339.  
  2340. _createClass(KeyShortcutsPatch, [{
  2341. key: '_prepare',
  2342. value: function _prepare() {
  2343. corePatch.install();
  2344. }
  2345. }, {
  2346. key: '_apply',
  2347. value: function _apply() {
  2348. _hooker2.default.hookPluginHotKeys(function (exports) {
  2349. var proto = exports.prototype;
  2350.  
  2351. proto.init = function () {
  2352. document.addEventListener('keydown', this._keydown.bind(this));
  2353. };
  2354.  
  2355. proto._isValidTarget = function (target) {
  2356. return target.nodeName === 'BODY' || target.nodeName == 'VIDEO' || target.classList.contains('pw-video'); // 全局
  2357. // return target.nodeName === 'VIDEO' || target.classList.contains('pw-video'); // 非全局
  2358. };
  2359.  
  2360. proto._keydown = function (event) {
  2361. if (!this._isValidTarget(event.target)) return;
  2362.  
  2363. var keyCode = event.keyCode,
  2364. ctrlKey = event.ctrlKey,
  2365. shiftKey = event.shiftKey,
  2366. altKey = event.altKey;
  2367.  
  2368. var core = this.core;
  2369.  
  2370. switch (keyCode) {
  2371. case 32:
  2372. // Spacebar
  2373. if (!ctrlKey && !shiftKey && !altKey) {
  2374. if (core.isPaused()) {
  2375. core.play(true);
  2376. core._showTip('播放');
  2377. } else {
  2378. core.pause(true);
  2379. core._showTip('暂停');
  2380. }
  2381. } else {
  2382. return;
  2383. }
  2384. break;
  2385. case 39: // → Arrow Right
  2386. case 37:
  2387. {
  2388. // ← Arrow Left
  2389. var stepTime = void 0;
  2390. if (!ctrlKey && !shiftKey && !altKey) {
  2391. stepTime = 39 === keyCode ? 5 : -5;
  2392. } else if (ctrlKey && !shiftKey && !altKey) {
  2393. stepTime = 39 === keyCode ? 30 : -30;
  2394. } else if (!ctrlKey && shiftKey && !altKey) {
  2395. stepTime = 39 === keyCode ? 60 : -60;
  2396. } else if (ctrlKey && !shiftKey && altKey) {
  2397. stepTime = 39 === keyCode ? 3e2 : -3e2; // 5分钟
  2398. } else {
  2399. return;
  2400. }
  2401.  
  2402. core.stepSeek(stepTime);
  2403. break;
  2404. }
  2405. case 38: // ↑ Arrow Up
  2406. case 40:
  2407. // ↓ Arrow Down
  2408. if (!ctrlKey && !shiftKey && !altKey) {
  2409. core.adjustVolume(38 === keyCode ? 0.05 : -0.05);
  2410. } else {
  2411. return;
  2412. }
  2413. break;
  2414. case 77:
  2415. // M
  2416. if (!ctrlKey && !shiftKey && !altKey) {
  2417. core.toggleMute();
  2418. } else {
  2419. return;
  2420. }
  2421. break;
  2422. case 13:
  2423. // Enter
  2424. if (!ctrlKey && !shiftKey && !altKey) {
  2425. _fullscreen.fullscreen.toggle();
  2426. } else if (ctrlKey && !shiftKey && !altKey) {
  2427. _webFullscreen.webFullscreen.toggle();
  2428. } else {
  2429. return;
  2430. }
  2431. break;
  2432. case 67: // C
  2433. case 88:
  2434. // X
  2435. if (!ctrlKey && !shiftKey && !altKey) {
  2436. core.adjustPlaybackRate(67 === keyCode ? 0.1 : -0.1);
  2437. } else {
  2438. return;
  2439. }
  2440. break;
  2441. case 90:
  2442. // Z
  2443. if (!ctrlKey && !shiftKey && !altKey) {
  2444. core.turnPlaybackRate();
  2445. } else {
  2446. return;
  2447. }
  2448. break;
  2449. case 68: // D
  2450. case 70:
  2451. // F
  2452. if (!ctrlKey && !shiftKey && !altKey) {
  2453. core.pause(true);
  2454. if (keyCode === 68) {
  2455. core.prevFrame();
  2456. } else {
  2457. core.nextFrame();
  2458. }
  2459. } else {
  2460. return;
  2461. }
  2462. break;
  2463. case 80: // P
  2464. case 78:
  2465. // N
  2466. if (!ctrlKey && shiftKey && !altKey) {
  2467. if (keyCode === 78) {
  2468. core.playNext();
  2469. } else {
  2470. core.playPrev();
  2471. }
  2472. } else {
  2473. return;
  2474. }
  2475. break;
  2476. case 27:
  2477. // ESC
  2478. if (!event.ctrlKey && !event.shiftKey && !event.altKey) _webFullscreen.webFullscreen.isWebFullScreen() && _webFullscreen.webFullscreen.exit();
  2479. return;
  2480. default:
  2481. if (keyCode >= 48 && keyCode <= 57) {
  2482. // 0 ~ 9
  2483. if (!ctrlKey && !shiftKey && !altKey) {
  2484. core.rangeSeek((keyCode - 48) * 0.1);
  2485. } else {
  2486. return;
  2487. }
  2488. } else {
  2489. return;
  2490. }
  2491. }
  2492.  
  2493. event.preventDefault();
  2494. event.stopPropagation();
  2495. };
  2496.  
  2497. _logger2.default.info('The keyboard shortcuts patch has been installed');
  2498. });
  2499. }
  2500. }]);
  2501.  
  2502. return KeyShortcutsPatch;
  2503. }(Patch);
  2504.  
  2505. var MouseShortcutsPatch = function (_Patch7) {
  2506. _inherits(MouseShortcutsPatch, _Patch7);
  2507.  
  2508. function MouseShortcutsPatch() {
  2509. _classCallCheck(this, MouseShortcutsPatch);
  2510.  
  2511. return _possibleConstructorReturn(this, (MouseShortcutsPatch.__proto__ || Object.getPrototypeOf(MouseShortcutsPatch)).call(this));
  2512. }
  2513.  
  2514. _createClass(MouseShortcutsPatch, [{
  2515. key: '_prepare',
  2516. value: function _prepare() {
  2517. corePatch.install();
  2518. }
  2519. }, {
  2520. key: '_apply',
  2521. value: function _apply() {
  2522. _hooker2.default.hookDefaultSkin(function (exports) {
  2523. exports.prototype._initDBClicks = function () {
  2524. var timer = void 0,
  2525. core = this.core;
  2526. this.videoWrapper.find('video').on('click', function () {
  2527. if (timer) {
  2528. clearTimeout(timer);
  2529. timer = null;
  2530. return;
  2531. }
  2532. timer = setTimeout(function () {
  2533. if (core.isPaused()) {
  2534. core.play(true);
  2535. } else {
  2536. core.pause(true);
  2537. }
  2538. timer = null;
  2539. }, 200);
  2540. }).on('dblclick', function (event) {
  2541. event.preventDefault();
  2542. event.stopPropagation();
  2543. if (event.ctrlKey) {
  2544. _webFullscreen.webFullscreen.toggle();
  2545. } else {
  2546. _fullscreen.fullscreen.toggle();
  2547. }
  2548. }).on('wheel', function (event) {
  2549. if (_fullscreen.fullscreen.isFullScreen() || _webFullscreen.webFullscreen.isWebFullScreen()) {
  2550. var delta = event.wheelDelta || event.detail || event.deltaY && -event.deltaY;
  2551. core.adjustVolume(delta > 0 ? 0.05 : -0.05);
  2552. }
  2553. });
  2554. };
  2555.  
  2556. _logger2.default.info('The mouse shortcuts patch has been installed');
  2557. });
  2558. }
  2559. }]);
  2560.  
  2561. return MouseShortcutsPatch;
  2562. }(Patch);
  2563.  
  2564. var UseWebSocketLoaderPatch = function (_Patch8) {
  2565. _inherits(UseWebSocketLoaderPatch, _Patch8);
  2566.  
  2567. function UseWebSocketLoaderPatch() {
  2568. _classCallCheck(this, UseWebSocketLoaderPatch);
  2569.  
  2570. var _this9 = _possibleConstructorReturn(this, (UseWebSocketLoaderPatch.__proto__ || Object.getPrototypeOf(UseWebSocketLoaderPatch)).call(this));
  2571.  
  2572. _this9.tryWs = GM_getValue('tryWs', false);
  2573. return _this9;
  2574. }
  2575.  
  2576. _createClass(UseWebSocketLoaderPatch, [{
  2577. key: '_prepare',
  2578. value: function _prepare() {
  2579. this._addSetting();
  2580. }
  2581. }, {
  2582. key: '_apply',
  2583. value: function _apply() {
  2584. var _this10 = this;
  2585.  
  2586. var that = this;
  2587. _hooker2.default.hookFragment(function (exports) {
  2588. Reflect.defineProperty(exports.prototype, 'tryWS', {
  2589. get: function get() {
  2590. return _this10._tryWs || that.tryWs;
  2591. }, // Will use the WebSocket loader if the value of tryWs is true.
  2592. set: function set(value) {
  2593. return _this10._tryWs = value;
  2594. } // The value of tryWs will be true if the Fetch loader fails.
  2595. });
  2596. _logger2.default.info('The WebSocket loader patch has been installed');
  2597. });
  2598. }
  2599. }, {
  2600. key: '_addSetting',
  2601. value: function _addSetting() {
  2602. var that = this;
  2603. _hooker2.default.hookPluginControls(function (exports) {
  2604. var initSetting = exports.prototype.initSetting;
  2605. exports.prototype.initSetting = function () {
  2606. var _this11 = this;
  2607.  
  2608. var div = document.createElement('div');
  2609. div.innerHTML = `
  2610. <div class="setPop_item" data-player-hook="usewebsocketloaderbox">
  2611. <span class="setPop_switchTxt" data-player-hook="controls_usewebsocketloader">WebSocket</span>
  2612. <div class="setPop_switch setPop_switch_close" data-player-hook="usewebsocketloader"></div>
  2613. </div>`;
  2614. var item = div.querySelector('.setPop_item');
  2615. this.$playsettingbox.find('.video_setPop_top').append(item);
  2616. this.$usewebsocketBtn = this.$playsettingbox.find('[data-player-hook="usewebsocketloader"]');
  2617.  
  2618. if (that.tryWs) {
  2619. this.$usewebsocketBtn.removeClass('setPop_switch_close');
  2620. }
  2621. this.$usewebsocketBtn.on('click', function () {
  2622. _this11.$usewebsocketBtn.toggleClass('setPop_switch_close');
  2623. that.tryWs = !that.tryWs;
  2624. GM_setValue('tryWs', that.tryWs);
  2625. });
  2626.  
  2627. initSetting.apply(this);
  2628. };
  2629. });
  2630. }
  2631. }]);
  2632.  
  2633. return UseWebSocketLoaderPatch;
  2634. }(Patch);
  2635.  
  2636. var KeepHookingPatch = function (_Patch9) {
  2637. _inherits(KeepHookingPatch, _Patch9);
  2638.  
  2639. function KeepHookingPatch() {
  2640. _classCallCheck(this, KeepHookingPatch);
  2641.  
  2642. return _possibleConstructorReturn(this, (KeepHookingPatch.__proto__ || Object.getPrototypeOf(KeepHookingPatch)).call(this));
  2643. }
  2644.  
  2645. _createClass(KeepHookingPatch, [{
  2646. key: '_apply',
  2647. value: function _apply() {
  2648. _hooker2.default.keepalive = true;
  2649. _logger2.default.info('The keep hooking patch has been installed');
  2650. }
  2651. }]);
  2652.  
  2653. return KeepHookingPatch;
  2654. }(Patch);
  2655.  
  2656. var vipPatch = exports.vipPatch = new VipPatch();
  2657. var adsPatch = exports.adsPatch = new AdsPatch();
  2658. var controlsPatch = exports.controlsPatch = new ControlsPatch();
  2659. var watermarksPatch = exports.watermarksPatch = new WatermarksPatch();
  2660. var keepHookingPatch = exports.keepHookingPatch = new KeepHookingPatch();
  2661. var keyShortcutsPatch = exports.keyShortcutsPatch = new KeyShortcutsPatch();
  2662. var mouseShortcutsPatch = exports.mouseShortcutsPatch = new MouseShortcutsPatch();
  2663. var useWebSocketLoaderPatch = exports.useWebSocketLoaderPatch = new UseWebSocketLoaderPatch();
  2664.  
  2665. /***/ }),
  2666. /* 13 */
  2667. /***/ (function(module, exports, __webpack_require__) {
  2668.  
  2669. "use strict";
  2670.  
  2671.  
  2672. Object.defineProperty(exports, "__esModule", {
  2673. value: true
  2674. });
  2675. exports.fullscreen = undefined;
  2676.  
  2677. var _hooker = __webpack_require__(0);
  2678.  
  2679. var _hooker2 = _interopRequireDefault(_hooker);
  2680.  
  2681. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2682.  
  2683. var fullscreen = void 0;
  2684. _hooker2.default.hookFullScreen(function (_exports) {
  2685. return exports.fullscreen = fullscreen = _exports;
  2686. });
  2687.  
  2688. exports.fullscreen = fullscreen;
  2689.  
  2690. /***/ }),
  2691. /* 14 */
  2692. /***/ (function(module, exports, __webpack_require__) {
  2693.  
  2694. "use strict";
  2695.  
  2696.  
  2697. Object.defineProperty(exports, "__esModule", {
  2698. value: true
  2699. });
  2700. exports.webFullscreen = undefined;
  2701.  
  2702. var _hooker = __webpack_require__(0);
  2703.  
  2704. var _hooker2 = _interopRequireDefault(_hooker);
  2705.  
  2706. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2707.  
  2708. var webFullscreen = void 0;
  2709. _hooker2.default.hookWebFullScreen(function (_exports) {
  2710. return exports.webFullscreen = webFullscreen = _exports;
  2711. });
  2712.  
  2713. exports.webFullscreen = webFullscreen;
  2714.  
  2715. /***/ }),
  2716. /* 15 */
  2717. /***/ (function(module, exports, __webpack_require__) {
  2718.  
  2719. "use strict";
  2720.  
  2721.  
  2722. Object.defineProperty(exports, "__esModule", {
  2723. value: true
  2724. });
  2725. exports.flvInfo = undefined;
  2726.  
  2727. var _hooker = __webpack_require__(0);
  2728.  
  2729. var _hooker2 = _interopRequireDefault(_hooker);
  2730.  
  2731. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2732.  
  2733. var flvInfo = void 0;
  2734. _hooker2.default.hookParseData(function (that) {
  2735. return exports.flvInfo = flvInfo = that.flvInfo;
  2736. });
  2737.  
  2738. exports.flvInfo = flvInfo;
  2739.  
  2740. /***/ })
  2741. /******/ ]);