锁定b站直播间发送弹幕为滚动模式

锁定b站(bilibili)直播间发送弹幕为滚动模式

  1. // ==UserScript==
  2. // @name 锁定b站直播间发送弹幕为滚动模式
  3. // @namespace https://github.com/KazooTTT/bilibili-danmaku-scroll-mode-locker
  4. // @version 0.0.3
  5. // @author KazooTTT
  6. // @description 锁定b站(bilibili)直播间发送弹幕为滚动模式
  7. // @license MIT
  8. // @icon https://github.com/kazoottt.png
  9. // @match https://live.bilibili.com/*
  10. // @grant GM_getValue
  11. // @grant GM_registerMenuCommand
  12. // @grant GM_setValue
  13. // @grant unsafeWindow
  14. // ==/UserScript==
  15.  
  16. (async function () {
  17. "use strict";
  18.  
  19. var _GM_getValue = /* @__PURE__ */ (() =>
  20. typeof GM_getValue != "undefined" ? GM_getValue : void 0)();
  21. var _GM_registerMenuCommand = /* @__PURE__ */ (() =>
  22. typeof GM_registerMenuCommand != "undefined"
  23. ? GM_registerMenuCommand
  24. : void 0)();
  25. var _GM_setValue = /* @__PURE__ */ (() =>
  26. typeof GM_setValue != "undefined" ? GM_setValue : void 0)();
  27. var _unsafeWindow = /* @__PURE__ */ (() =>
  28. typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)();
  29. function bind(fn, thisArg) {
  30. return function wrap() {
  31. return fn.apply(thisArg, arguments);
  32. };
  33. }
  34. const { toString } = Object.prototype;
  35. const { getPrototypeOf } = Object;
  36. const kindOf = /* @__PURE__ */ ((cache) => (thing) => {
  37. const str = toString.call(thing);
  38. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  39. })(/* @__PURE__ */ Object.create(null));
  40. const kindOfTest = (type) => {
  41. type = type.toLowerCase();
  42. return (thing) => kindOf(thing) === type;
  43. };
  44. const typeOfTest = (type) => (thing) => typeof thing === type;
  45. const { isArray } = Array;
  46. const isUndefined = typeOfTest("undefined");
  47. function isBuffer(val) {
  48. return (
  49. val !== null &&
  50. !isUndefined(val) &&
  51. val.constructor !== null &&
  52. !isUndefined(val.constructor) &&
  53. isFunction(val.constructor.isBuffer) &&
  54. val.constructor.isBuffer(val)
  55. );
  56. }
  57. const isArrayBuffer = kindOfTest("ArrayBuffer");
  58. function isArrayBufferView(val) {
  59. let result;
  60. if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
  61. result = ArrayBuffer.isView(val);
  62. } else {
  63. result = val && val.buffer && isArrayBuffer(val.buffer);
  64. }
  65. return result;
  66. }
  67. const isString = typeOfTest("string");
  68. const isFunction = typeOfTest("function");
  69. const isNumber = typeOfTest("number");
  70. const isObject = (thing) => thing !== null && typeof thing === "object";
  71. const isBoolean = (thing) => thing === true || thing === false;
  72. const isPlainObject = (val) => {
  73. if (kindOf(val) !== "object") {
  74. return false;
  75. }
  76. const prototype2 = getPrototypeOf(val);
  77. return (
  78. (prototype2 === null ||
  79. prototype2 === Object.prototype ||
  80. Object.getPrototypeOf(prototype2) === null) &&
  81. !(Symbol.toStringTag in val) &&
  82. !(Symbol.iterator in val)
  83. );
  84. };
  85. const isDate = kindOfTest("Date");
  86. const isFile = kindOfTest("File");
  87. const isBlob = kindOfTest("Blob");
  88. const isFileList = kindOfTest("FileList");
  89. const isStream = (val) => isObject(val) && isFunction(val.pipe);
  90. const isFormData = (thing) => {
  91. let kind;
  92. return (
  93. thing &&
  94. ((typeof FormData === "function" && thing instanceof FormData) ||
  95. (isFunction(thing.append) &&
  96. ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
  97. (kind === "object" &&
  98. isFunction(thing.toString) &&
  99. thing.toString() === "[object FormData]"))))
  100. );
  101. };
  102. const isURLSearchParams = kindOfTest("URLSearchParams");
  103. const [isReadableStream, isRequest, isResponse, isHeaders] = [
  104. "ReadableStream",
  105. "Request",
  106. "Response",
  107. "Headers",
  108. ].map(kindOfTest);
  109. const trim = (str) =>
  110. str.trim
  111. ? str.trim()
  112. : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
  113. function forEach(obj, fn, { allOwnKeys = false } = {}) {
  114. if (obj === null || typeof obj === "undefined") {
  115. return;
  116. }
  117. let i;
  118. let l;
  119. if (typeof obj !== "object") {
  120. obj = [obj];
  121. }
  122. if (isArray(obj)) {
  123. for (i = 0, l = obj.length; i < l; i++) {
  124. fn.call(null, obj[i], i, obj);
  125. }
  126. } else {
  127. const keys = allOwnKeys
  128. ? Object.getOwnPropertyNames(obj)
  129. : Object.keys(obj);
  130. const len = keys.length;
  131. let key;
  132. for (i = 0; i < len; i++) {
  133. key = keys[i];
  134. fn.call(null, obj[key], key, obj);
  135. }
  136. }
  137. }
  138. function findKey(obj, key) {
  139. key = key.toLowerCase();
  140. const keys = Object.keys(obj);
  141. let i = keys.length;
  142. let _key;
  143. while (i-- > 0) {
  144. _key = keys[i];
  145. if (key === _key.toLowerCase()) {
  146. return _key;
  147. }
  148. }
  149. return null;
  150. }
  151. const _global = (() => {
  152. if (typeof globalThis !== "undefined") return globalThis;
  153. return typeof self !== "undefined"
  154. ? self
  155. : typeof window !== "undefined"
  156. ? window
  157. : global;
  158. })();
  159. const isContextDefined = (context) =>
  160. !isUndefined(context) && context !== _global;
  161. function merge() {
  162. const { caseless } = (isContextDefined(this) && this) || {};
  163. const result = {};
  164. const assignValue = (val, key) => {
  165. const targetKey = (caseless && findKey(result, key)) || key;
  166. if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
  167. result[targetKey] = merge(result[targetKey], val);
  168. } else if (isPlainObject(val)) {
  169. result[targetKey] = merge({}, val);
  170. } else if (isArray(val)) {
  171. result[targetKey] = val.slice();
  172. } else {
  173. result[targetKey] = val;
  174. }
  175. };
  176. for (let i = 0, l = arguments.length; i < l; i++) {
  177. arguments[i] && forEach(arguments[i], assignValue);
  178. }
  179. return result;
  180. }
  181. const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
  182. forEach(
  183. b,
  184. (val, key) => {
  185. if (thisArg && isFunction(val)) {
  186. a[key] = bind(val, thisArg);
  187. } else {
  188. a[key] = val;
  189. }
  190. },
  191. { allOwnKeys }
  192. );
  193. return a;
  194. };
  195. const stripBOM = (content) => {
  196. if (content.charCodeAt(0) === 65279) {
  197. content = content.slice(1);
  198. }
  199. return content;
  200. };
  201. const inherits = (constructor, superConstructor, props, descriptors2) => {
  202. constructor.prototype = Object.create(
  203. superConstructor.prototype,
  204. descriptors2
  205. );
  206. constructor.prototype.constructor = constructor;
  207. Object.defineProperty(constructor, "super", {
  208. value: superConstructor.prototype,
  209. });
  210. props && Object.assign(constructor.prototype, props);
  211. };
  212. const toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
  213. let props;
  214. let i;
  215. let prop;
  216. const merged = {};
  217. destObj = destObj || {};
  218. if (sourceObj == null) return destObj;
  219. do {
  220. props = Object.getOwnPropertyNames(sourceObj);
  221. i = props.length;
  222. while (i-- > 0) {
  223. prop = props[i];
  224. if (
  225. (!propFilter || propFilter(prop, sourceObj, destObj)) &&
  226. !merged[prop]
  227. ) {
  228. destObj[prop] = sourceObj[prop];
  229. merged[prop] = true;
  230. }
  231. }
  232. sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
  233. } while (
  234. sourceObj &&
  235. (!filter2 || filter2(sourceObj, destObj)) &&
  236. sourceObj !== Object.prototype
  237. );
  238. return destObj;
  239. };
  240. const endsWith = (str, searchString, position) => {
  241. str = String(str);
  242. if (position === void 0 || position > str.length) {
  243. position = str.length;
  244. }
  245. position -= searchString.length;
  246. const lastIndex = str.indexOf(searchString, position);
  247. return lastIndex !== -1 && lastIndex === position;
  248. };
  249. const toArray = (thing) => {
  250. if (!thing) return null;
  251. if (isArray(thing)) return thing;
  252. let i = thing.length;
  253. if (!isNumber(i)) return null;
  254. const arr = new Array(i);
  255. while (i-- > 0) {
  256. arr[i] = thing[i];
  257. }
  258. return arr;
  259. };
  260. const isTypedArray = /* @__PURE__ */ ((TypedArray) => {
  261. return (thing) => {
  262. return TypedArray && thing instanceof TypedArray;
  263. };
  264. })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
  265. const forEachEntry = (obj, fn) => {
  266. const generator = obj && obj[Symbol.iterator];
  267. const iterator = generator.call(obj);
  268. let result;
  269. while ((result = iterator.next()) && !result.done) {
  270. const pair = result.value;
  271. fn.call(obj, pair[0], pair[1]);
  272. }
  273. };
  274. const matchAll = (regExp, str) => {
  275. let matches;
  276. const arr = [];
  277. while ((matches = regExp.exec(str)) !== null) {
  278. arr.push(matches);
  279. }
  280. return arr;
  281. };
  282. const isHTMLForm = kindOfTest("HTMLFormElement");
  283. const toCamelCase = (str) => {
  284. return str
  285. .toLowerCase()
  286. .replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
  287. return p1.toUpperCase() + p2;
  288. });
  289. };
  290. const hasOwnProperty = (
  291. ({ hasOwnProperty: hasOwnProperty2 }) =>
  292. (obj, prop) =>
  293. hasOwnProperty2.call(obj, prop)
  294. )(Object.prototype);
  295. const isRegExp = kindOfTest("RegExp");
  296. const reduceDescriptors = (obj, reducer) => {
  297. const descriptors2 = Object.getOwnPropertyDescriptors(obj);
  298. const reducedDescriptors = {};
  299. forEach(descriptors2, (descriptor, name) => {
  300. let ret;
  301. if ((ret = reducer(descriptor, name, obj)) !== false) {
  302. reducedDescriptors[name] = ret || descriptor;
  303. }
  304. });
  305. Object.defineProperties(obj, reducedDescriptors);
  306. };
  307. const freezeMethods = (obj) => {
  308. reduceDescriptors(obj, (descriptor, name) => {
  309. if (
  310. isFunction(obj) &&
  311. ["arguments", "caller", "callee"].indexOf(name) !== -1
  312. ) {
  313. return false;
  314. }
  315. const value = obj[name];
  316. if (!isFunction(value)) return;
  317. descriptor.enumerable = false;
  318. if ("writable" in descriptor) {
  319. descriptor.writable = false;
  320. return;
  321. }
  322. if (!descriptor.set) {
  323. descriptor.set = () => {
  324. throw Error("Can not rewrite read-only method '" + name + "'");
  325. };
  326. }
  327. });
  328. };
  329. const toObjectSet = (arrayOrString, delimiter) => {
  330. const obj = {};
  331. const define = (arr) => {
  332. arr.forEach((value) => {
  333. obj[value] = true;
  334. });
  335. };
  336. isArray(arrayOrString)
  337. ? define(arrayOrString)
  338. : define(String(arrayOrString).split(delimiter));
  339. return obj;
  340. };
  341. const noop = () => {};
  342. const toFiniteNumber = (value, defaultValue) => {
  343. return value != null && Number.isFinite((value = +value))
  344. ? value
  345. : defaultValue;
  346. };
  347. const ALPHA = "abcdefghijklmnopqrstuvwxyz";
  348. const DIGIT = "0123456789";
  349. const ALPHABET = {
  350. DIGIT,
  351. ALPHA,
  352. ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT,
  353. };
  354. const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
  355. let str = "";
  356. const { length } = alphabet;
  357. while (size--) {
  358. str += alphabet[(Math.random() * length) | 0];
  359. }
  360. return str;
  361. };
  362. function isSpecCompliantForm(thing) {
  363. return !!(
  364. thing &&
  365. isFunction(thing.append) &&
  366. thing[Symbol.toStringTag] === "FormData" &&
  367. thing[Symbol.iterator]
  368. );
  369. }
  370. const toJSONObject = (obj) => {
  371. const stack = new Array(10);
  372. const visit = (source, i) => {
  373. if (isObject(source)) {
  374. if (stack.indexOf(source) >= 0) {
  375. return;
  376. }
  377. if (!("toJSON" in source)) {
  378. stack[i] = source;
  379. const target = isArray(source) ? [] : {};
  380. forEach(source, (value, key) => {
  381. const reducedValue = visit(value, i + 1);
  382. !isUndefined(reducedValue) && (target[key] = reducedValue);
  383. });
  384. stack[i] = void 0;
  385. return target;
  386. }
  387. }
  388. return source;
  389. };
  390. return visit(obj, 0);
  391. };
  392. const isAsyncFn = kindOfTest("AsyncFunction");
  393. const isThenable = (thing) =>
  394. thing &&
  395. (isObject(thing) || isFunction(thing)) &&
  396. isFunction(thing.then) &&
  397. isFunction(thing.catch);
  398. const utils$1 = {
  399. isArray,
  400. isArrayBuffer,
  401. isBuffer,
  402. isFormData,
  403. isArrayBufferView,
  404. isString,
  405. isNumber,
  406. isBoolean,
  407. isObject,
  408. isPlainObject,
  409. isReadableStream,
  410. isRequest,
  411. isResponse,
  412. isHeaders,
  413. isUndefined,
  414. isDate,
  415. isFile,
  416. isBlob,
  417. isRegExp,
  418. isFunction,
  419. isStream,
  420. isURLSearchParams,
  421. isTypedArray,
  422. isFileList,
  423. forEach,
  424. merge,
  425. extend,
  426. trim,
  427. stripBOM,
  428. inherits,
  429. toFlatObject,
  430. kindOf,
  431. kindOfTest,
  432. endsWith,
  433. toArray,
  434. forEachEntry,
  435. matchAll,
  436. isHTMLForm,
  437. hasOwnProperty,
  438. hasOwnProp: hasOwnProperty,
  439. // an alias to avoid ESLint no-prototype-builtins detection
  440. reduceDescriptors,
  441. freezeMethods,
  442. toObjectSet,
  443. toCamelCase,
  444. noop,
  445. toFiniteNumber,
  446. findKey,
  447. global: _global,
  448. isContextDefined,
  449. ALPHABET,
  450. generateString,
  451. isSpecCompliantForm,
  452. toJSONObject,
  453. isAsyncFn,
  454. isThenable,
  455. };
  456. function AxiosError(message, code, config, request, response) {
  457. Error.call(this);
  458. if (Error.captureStackTrace) {
  459. Error.captureStackTrace(this, this.constructor);
  460. } else {
  461. this.stack = new Error().stack;
  462. }
  463. this.message = message;
  464. this.name = "AxiosError";
  465. code && (this.code = code);
  466. config && (this.config = config);
  467. request && (this.request = request);
  468. response && (this.response = response);
  469. }
  470. utils$1.inherits(AxiosError, Error, {
  471. toJSON: function toJSON() {
  472. return {
  473. // Standard
  474. message: this.message,
  475. name: this.name,
  476. // Microsoft
  477. description: this.description,
  478. number: this.number,
  479. // Mozilla
  480. fileName: this.fileName,
  481. lineNumber: this.lineNumber,
  482. columnNumber: this.columnNumber,
  483. stack: this.stack,
  484. // Axios
  485. config: utils$1.toJSONObject(this.config),
  486. code: this.code,
  487. status:
  488. this.response && this.response.status ? this.response.status : null,
  489. };
  490. },
  491. });
  492. const prototype$1 = AxiosError.prototype;
  493. const descriptors = {};
  494. [
  495. "ERR_BAD_OPTION_VALUE",
  496. "ERR_BAD_OPTION",
  497. "ECONNABORTED",
  498. "ETIMEDOUT",
  499. "ERR_NETWORK",
  500. "ERR_FR_TOO_MANY_REDIRECTS",
  501. "ERR_DEPRECATED",
  502. "ERR_BAD_RESPONSE",
  503. "ERR_BAD_REQUEST",
  504. "ERR_CANCELED",
  505. "ERR_NOT_SUPPORT",
  506. "ERR_INVALID_URL",
  507. // eslint-disable-next-line func-names
  508. ].forEach((code) => {
  509. descriptors[code] = { value: code };
  510. });
  511. Object.defineProperties(AxiosError, descriptors);
  512. Object.defineProperty(prototype$1, "isAxiosError", { value: true });
  513. AxiosError.from = (error, code, config, request, response, customProps) => {
  514. const axiosError = Object.create(prototype$1);
  515. utils$1.toFlatObject(
  516. error,
  517. axiosError,
  518. function filter2(obj) {
  519. return obj !== Error.prototype;
  520. },
  521. (prop) => {
  522. return prop !== "isAxiosError";
  523. }
  524. );
  525. AxiosError.call(axiosError, error.message, code, config, request, response);
  526. axiosError.cause = error;
  527. axiosError.name = error.name;
  528. customProps && Object.assign(axiosError, customProps);
  529. return axiosError;
  530. };
  531. const httpAdapter = null;
  532. function isVisitable(thing) {
  533. return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
  534. }
  535. function removeBrackets(key) {
  536. return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
  537. }
  538. function renderKey(path, key, dots) {
  539. if (!path) return key;
  540. return path
  541. .concat(key)
  542. .map(function each(token, i) {
  543. token = removeBrackets(token);
  544. return !dots && i ? "[" + token + "]" : token;
  545. })
  546. .join(dots ? "." : "");
  547. }
  548. function isFlatArray(arr) {
  549. return utils$1.isArray(arr) && !arr.some(isVisitable);
  550. }
  551. const predicates = utils$1.toFlatObject(
  552. utils$1,
  553. {},
  554. null,
  555. function filter(prop) {
  556. return /^is[A-Z]/.test(prop);
  557. }
  558. );
  559. function toFormData(obj, formData, options) {
  560. if (!utils$1.isObject(obj)) {
  561. throw new TypeError("target must be an object");
  562. }
  563. formData = formData || new FormData();
  564. options = utils$1.toFlatObject(
  565. options,
  566. {
  567. metaTokens: true,
  568. dots: false,
  569. indexes: false,
  570. },
  571. false,
  572. function defined(option, source) {
  573. return !utils$1.isUndefined(source[option]);
  574. }
  575. );
  576. const metaTokens = options.metaTokens;
  577. const visitor = options.visitor || defaultVisitor;
  578. const dots = options.dots;
  579. const indexes = options.indexes;
  580. const _Blob = options.Blob || (typeof Blob !== "undefined" && Blob);
  581. const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
  582. if (!utils$1.isFunction(visitor)) {
  583. throw new TypeError("visitor must be a function");
  584. }
  585. function convertValue(value) {
  586. if (value === null) return "";
  587. if (utils$1.isDate(value)) {
  588. return value.toISOString();
  589. }
  590. if (!useBlob && utils$1.isBlob(value)) {
  591. throw new AxiosError("Blob is not supported. Use a Buffer instead.");
  592. }
  593. if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
  594. return useBlob && typeof Blob === "function"
  595. ? new Blob([value])
  596. : Buffer.from(value);
  597. }
  598. return value;
  599. }
  600. function defaultVisitor(value, key, path) {
  601. let arr = value;
  602. if (value && !path && typeof value === "object") {
  603. if (utils$1.endsWith(key, "{}")) {
  604. key = metaTokens ? key : key.slice(0, -2);
  605. value = JSON.stringify(value);
  606. } else if (
  607. (utils$1.isArray(value) && isFlatArray(value)) ||
  608. ((utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) &&
  609. (arr = utils$1.toArray(value)))
  610. ) {
  611. key = removeBrackets(key);
  612. arr.forEach(function each(el, index) {
  613. !(utils$1.isUndefined(el) || el === null) &&
  614. formData.append(
  615. // eslint-disable-next-line no-nested-ternary
  616. indexes === true
  617. ? renderKey([key], index, dots)
  618. : indexes === null
  619. ? key
  620. : key + "[]",
  621. convertValue(el)
  622. );
  623. });
  624. return false;
  625. }
  626. }
  627. if (isVisitable(value)) {
  628. return true;
  629. }
  630. formData.append(renderKey(path, key, dots), convertValue(value));
  631. return false;
  632. }
  633. const stack = [];
  634. const exposedHelpers = Object.assign(predicates, {
  635. defaultVisitor,
  636. convertValue,
  637. isVisitable,
  638. });
  639. function build(value, path) {
  640. if (utils$1.isUndefined(value)) return;
  641. if (stack.indexOf(value) !== -1) {
  642. throw Error("Circular reference detected in " + path.join("."));
  643. }
  644. stack.push(value);
  645. utils$1.forEach(value, function each(el, key) {
  646. const result =
  647. !(utils$1.isUndefined(el) || el === null) &&
  648. visitor.call(
  649. formData,
  650. el,
  651. utils$1.isString(key) ? key.trim() : key,
  652. path,
  653. exposedHelpers
  654. );
  655. if (result === true) {
  656. build(el, path ? path.concat(key) : [key]);
  657. }
  658. });
  659. stack.pop();
  660. }
  661. if (!utils$1.isObject(obj)) {
  662. throw new TypeError("data must be an object");
  663. }
  664. build(obj);
  665. return formData;
  666. }
  667. function encode$1(str) {
  668. const charMap = {
  669. "!": "%21",
  670. "'": "%27",
  671. "(": "%28",
  672. ")": "%29",
  673. "~": "%7E",
  674. "%20": "+",
  675. "%00": "\0",
  676. };
  677. return encodeURIComponent(str).replace(
  678. /[!'()~]|%20|%00/g,
  679. function replacer(match) {
  680. return charMap[match];
  681. }
  682. );
  683. }
  684. function AxiosURLSearchParams(params, options) {
  685. this._pairs = [];
  686. params && toFormData(params, this, options);
  687. }
  688. const prototype = AxiosURLSearchParams.prototype;
  689. prototype.append = function append(name, value) {
  690. this._pairs.push([name, value]);
  691. };
  692. prototype.toString = function toString2(encoder) {
  693. const _encode = encoder
  694. ? function (value) {
  695. return encoder.call(this, value, encode$1);
  696. }
  697. : encode$1;
  698. return this._pairs
  699. .map(function each(pair) {
  700. return _encode(pair[0]) + "=" + _encode(pair[1]);
  701. }, "")
  702. .join("&");
  703. };
  704. function encode(val) {
  705. return encodeURIComponent(val)
  706. .replace(/%3A/gi, ":")
  707. .replace(/%24/g, "$")
  708. .replace(/%2C/gi, ",")
  709. .replace(/%20/g, "+")
  710. .replace(/%5B/gi, "[")
  711. .replace(/%5D/gi, "]");
  712. }
  713. function buildURL(url, params, options) {
  714. if (!params) {
  715. return url;
  716. }
  717. const _encode = (options && options.encode) || encode;
  718. const serializeFn = options && options.serialize;
  719. let serializedParams;
  720. if (serializeFn) {
  721. serializedParams = serializeFn(params, options);
  722. } else {
  723. serializedParams = utils$1.isURLSearchParams(params)
  724. ? params.toString()
  725. : new AxiosURLSearchParams(params, options).toString(_encode);
  726. }
  727. if (serializedParams) {
  728. const hashmarkIndex = url.indexOf("#");
  729. if (hashmarkIndex !== -1) {
  730. url = url.slice(0, hashmarkIndex);
  731. }
  732. url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
  733. }
  734. return url;
  735. }
  736. class InterceptorManager {
  737. constructor() {
  738. this.handlers = [];
  739. }
  740. /**
  741. * Add a new interceptor to the stack
  742. *
  743. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  744. * @param {Function} rejected The function to handle `reject` for a `Promise`
  745. *
  746. * @return {Number} An ID used to remove interceptor later
  747. */
  748. use(fulfilled, rejected, options) {
  749. this.handlers.push({
  750. fulfilled,
  751. rejected,
  752. synchronous: options ? options.synchronous : false,
  753. runWhen: options ? options.runWhen : null,
  754. });
  755. return this.handlers.length - 1;
  756. }
  757. /**
  758. * Remove an interceptor from the stack
  759. *
  760. * @param {Number} id The ID that was returned by `use`
  761. *
  762. * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
  763. */
  764. eject(id) {
  765. if (this.handlers[id]) {
  766. this.handlers[id] = null;
  767. }
  768. }
  769. /**
  770. * Clear all interceptors from the stack
  771. *
  772. * @returns {void}
  773. */
  774. clear() {
  775. if (this.handlers) {
  776. this.handlers = [];
  777. }
  778. }
  779. /**
  780. * Iterate over all the registered interceptors
  781. *
  782. * This method is particularly useful for skipping over any
  783. * interceptors that may have become `null` calling `eject`.
  784. *
  785. * @param {Function} fn The function to call for each interceptor
  786. *
  787. * @returns {void}
  788. */
  789. forEach(fn) {
  790. utils$1.forEach(this.handlers, function forEachHandler(h) {
  791. if (h !== null) {
  792. fn(h);
  793. }
  794. });
  795. }
  796. }
  797. const transitionalDefaults = {
  798. silentJSONParsing: true,
  799. forcedJSONParsing: true,
  800. clarifyTimeoutError: false,
  801. };
  802. const URLSearchParams$1 =
  803. typeof URLSearchParams !== "undefined"
  804. ? URLSearchParams
  805. : AxiosURLSearchParams;
  806. const FormData$1 = typeof FormData !== "undefined" ? FormData : null;
  807. const Blob$1 = typeof Blob !== "undefined" ? Blob : null;
  808. const platform$1 = {
  809. isBrowser: true,
  810. classes: {
  811. URLSearchParams: URLSearchParams$1,
  812. FormData: FormData$1,
  813. Blob: Blob$1,
  814. },
  815. protocols: ["http", "https", "file", "blob", "url", "data"],
  816. };
  817. const hasBrowserEnv =
  818. typeof window !== "undefined" && typeof document !== "undefined";
  819. const hasStandardBrowserEnv = ((product) => {
  820. return (
  821. hasBrowserEnv &&
  822. ["ReactNative", "NativeScript", "NS"].indexOf(product) < 0
  823. );
  824. })(typeof navigator !== "undefined" && navigator.product);
  825. const hasStandardBrowserWebWorkerEnv = (() => {
  826. return (
  827. typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
  828. self instanceof WorkerGlobalScope &&
  829. typeof self.importScripts === "function"
  830. );
  831. })();
  832. const origin = (hasBrowserEnv && window.location.href) || "http://localhost";
  833. const utils = /* @__PURE__ */ Object.freeze(
  834. /* @__PURE__ */ Object.defineProperty(
  835. {
  836. __proto__: null,
  837. hasBrowserEnv,
  838. hasStandardBrowserEnv,
  839. hasStandardBrowserWebWorkerEnv,
  840. origin,
  841. },
  842. Symbol.toStringTag,
  843. { value: "Module" }
  844. )
  845. );
  846. const platform = {
  847. ...utils,
  848. ...platform$1,
  849. };
  850. function toURLEncodedForm(data, options) {
  851. return toFormData(
  852. data,
  853. new platform.classes.URLSearchParams(),
  854. Object.assign(
  855. {
  856. visitor: function (value, key, path, helpers) {
  857. if (platform.isNode && utils$1.isBuffer(value)) {
  858. this.append(key, value.toString("base64"));
  859. return false;
  860. }
  861. return helpers.defaultVisitor.apply(this, arguments);
  862. },
  863. },
  864. options
  865. )
  866. );
  867. }
  868. function parsePropPath(name) {
  869. return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
  870. return match[0] === "[]" ? "" : match[1] || match[0];
  871. });
  872. }
  873. function arrayToObject(arr) {
  874. const obj = {};
  875. const keys = Object.keys(arr);
  876. let i;
  877. const len = keys.length;
  878. let key;
  879. for (i = 0; i < len; i++) {
  880. key = keys[i];
  881. obj[key] = arr[key];
  882. }
  883. return obj;
  884. }
  885. function formDataToJSON(formData) {
  886. function buildPath(path, value, target, index) {
  887. let name = path[index++];
  888. if (name === "__proto__") return true;
  889. const isNumericKey = Number.isFinite(+name);
  890. const isLast = index >= path.length;
  891. name = !name && utils$1.isArray(target) ? target.length : name;
  892. if (isLast) {
  893. if (utils$1.hasOwnProp(target, name)) {
  894. target[name] = [target[name], value];
  895. } else {
  896. target[name] = value;
  897. }
  898. return !isNumericKey;
  899. }
  900. if (!target[name] || !utils$1.isObject(target[name])) {
  901. target[name] = [];
  902. }
  903. const result = buildPath(path, value, target[name], index);
  904. if (result && utils$1.isArray(target[name])) {
  905. target[name] = arrayToObject(target[name]);
  906. }
  907. return !isNumericKey;
  908. }
  909. if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
  910. const obj = {};
  911. utils$1.forEachEntry(formData, (name, value) => {
  912. buildPath(parsePropPath(name), value, obj, 0);
  913. });
  914. return obj;
  915. }
  916. return null;
  917. }
  918. function stringifySafely(rawValue, parser, encoder) {
  919. if (utils$1.isString(rawValue)) {
  920. try {
  921. (parser || JSON.parse)(rawValue);
  922. return utils$1.trim(rawValue);
  923. } catch (e) {
  924. if (e.name !== "SyntaxError") {
  925. throw e;
  926. }
  927. }
  928. }
  929. return (0, JSON.stringify)(rawValue);
  930. }
  931. const defaults = {
  932. transitional: transitionalDefaults,
  933. adapter: ["xhr", "http", "fetch"],
  934. transformRequest: [
  935. function transformRequest(data, headers) {
  936. const contentType = headers.getContentType() || "";
  937. const hasJSONContentType = contentType.indexOf("application/json") > -1;
  938. const isObjectPayload = utils$1.isObject(data);
  939. if (isObjectPayload && utils$1.isHTMLForm(data)) {
  940. data = new FormData(data);
  941. }
  942. const isFormData2 = utils$1.isFormData(data);
  943. if (isFormData2) {
  944. return hasJSONContentType
  945. ? JSON.stringify(formDataToJSON(data))
  946. : data;
  947. }
  948. if (
  949. utils$1.isArrayBuffer(data) ||
  950. utils$1.isBuffer(data) ||
  951. utils$1.isStream(data) ||
  952. utils$1.isFile(data) ||
  953. utils$1.isBlob(data) ||
  954. utils$1.isReadableStream(data)
  955. ) {
  956. return data;
  957. }
  958. if (utils$1.isArrayBufferView(data)) {
  959. return data.buffer;
  960. }
  961. if (utils$1.isURLSearchParams(data)) {
  962. headers.setContentType(
  963. "application/x-www-form-urlencoded;charset=utf-8",
  964. false
  965. );
  966. return data.toString();
  967. }
  968. let isFileList2;
  969. if (isObjectPayload) {
  970. if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
  971. return toURLEncodedForm(data, this.formSerializer).toString();
  972. }
  973. if (
  974. (isFileList2 = utils$1.isFileList(data)) ||
  975. contentType.indexOf("multipart/form-data") > -1
  976. ) {
  977. const _FormData = this.env && this.env.FormData;
  978. return toFormData(
  979. isFileList2 ? { "files[]": data } : data,
  980. _FormData && new _FormData(),
  981. this.formSerializer
  982. );
  983. }
  984. }
  985. if (isObjectPayload || hasJSONContentType) {
  986. headers.setContentType("application/json", false);
  987. return stringifySafely(data);
  988. }
  989. return data;
  990. },
  991. ],
  992. transformResponse: [
  993. function transformResponse(data) {
  994. const transitional2 = this.transitional || defaults.transitional;
  995. const forcedJSONParsing =
  996. transitional2 && transitional2.forcedJSONParsing;
  997. const JSONRequested = this.responseType === "json";
  998. if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
  999. return data;
  1000. }
  1001. if (
  1002. data &&
  1003. utils$1.isString(data) &&
  1004. ((forcedJSONParsing && !this.responseType) || JSONRequested)
  1005. ) {
  1006. const silentJSONParsing =
  1007. transitional2 && transitional2.silentJSONParsing;
  1008. const strictJSONParsing = !silentJSONParsing && JSONRequested;
  1009. try {
  1010. return JSON.parse(data);
  1011. } catch (e) {
  1012. if (strictJSONParsing) {
  1013. if (e.name === "SyntaxError") {
  1014. throw AxiosError.from(
  1015. e,
  1016. AxiosError.ERR_BAD_RESPONSE,
  1017. this,
  1018. null,
  1019. this.response
  1020. );
  1021. }
  1022. throw e;
  1023. }
  1024. }
  1025. }
  1026. return data;
  1027. },
  1028. ],
  1029. /**
  1030. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1031. * timeout is not created.
  1032. */
  1033. timeout: 0,
  1034. xsrfCookieName: "XSRF-TOKEN",
  1035. xsrfHeaderName: "X-XSRF-TOKEN",
  1036. maxContentLength: -1,
  1037. maxBodyLength: -1,
  1038. env: {
  1039. FormData: platform.classes.FormData,
  1040. Blob: platform.classes.Blob,
  1041. },
  1042. validateStatus: function validateStatus(status) {
  1043. return status >= 200 && status < 300;
  1044. },
  1045. headers: {
  1046. common: {
  1047. Accept: "application/json, text/plain, */*",
  1048. "Content-Type": void 0,
  1049. },
  1050. },
  1051. };
  1052. utils$1.forEach(
  1053. ["delete", "get", "head", "post", "put", "patch"],
  1054. (method) => {
  1055. defaults.headers[method] = {};
  1056. }
  1057. );
  1058. const ignoreDuplicateOf = utils$1.toObjectSet([
  1059. "age",
  1060. "authorization",
  1061. "content-length",
  1062. "content-type",
  1063. "etag",
  1064. "expires",
  1065. "from",
  1066. "host",
  1067. "if-modified-since",
  1068. "if-unmodified-since",
  1069. "last-modified",
  1070. "location",
  1071. "max-forwards",
  1072. "proxy-authorization",
  1073. "referer",
  1074. "retry-after",
  1075. "user-agent",
  1076. ]);
  1077. const parseHeaders = (rawHeaders) => {
  1078. const parsed = {};
  1079. let key;
  1080. let val;
  1081. let i;
  1082. rawHeaders &&
  1083. rawHeaders.split("\n").forEach(function parser(line) {
  1084. i = line.indexOf(":");
  1085. key = line.substring(0, i).trim().toLowerCase();
  1086. val = line.substring(i + 1).trim();
  1087. if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
  1088. return;
  1089. }
  1090. if (key === "set-cookie") {
  1091. if (parsed[key]) {
  1092. parsed[key].push(val);
  1093. } else {
  1094. parsed[key] = [val];
  1095. }
  1096. } else {
  1097. parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
  1098. }
  1099. });
  1100. return parsed;
  1101. };
  1102. const $internals = Symbol("internals");
  1103. function normalizeHeader(header) {
  1104. return header && String(header).trim().toLowerCase();
  1105. }
  1106. function normalizeValue(value) {
  1107. if (value === false || value == null) {
  1108. return value;
  1109. }
  1110. return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
  1111. }
  1112. function parseTokens(str) {
  1113. const tokens = /* @__PURE__ */ Object.create(null);
  1114. const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  1115. let match;
  1116. while ((match = tokensRE.exec(str))) {
  1117. tokens[match[1]] = match[2];
  1118. }
  1119. return tokens;
  1120. }
  1121. const isValidHeaderName = (str) =>
  1122. /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
  1123. function matchHeaderValue(
  1124. context,
  1125. value,
  1126. header,
  1127. filter2,
  1128. isHeaderNameFilter
  1129. ) {
  1130. if (utils$1.isFunction(filter2)) {
  1131. return filter2.call(this, value, header);
  1132. }
  1133. if (isHeaderNameFilter) {
  1134. value = header;
  1135. }
  1136. if (!utils$1.isString(value)) return;
  1137. if (utils$1.isString(filter2)) {
  1138. return value.indexOf(filter2) !== -1;
  1139. }
  1140. if (utils$1.isRegExp(filter2)) {
  1141. return filter2.test(value);
  1142. }
  1143. }
  1144. function formatHeader(header) {
  1145. return header
  1146. .trim()
  1147. .toLowerCase()
  1148. .replace(/([a-z\d])(\w*)/g, (w, char, str) => {
  1149. return char.toUpperCase() + str;
  1150. });
  1151. }
  1152. function buildAccessors(obj, header) {
  1153. const accessorName = utils$1.toCamelCase(" " + header);
  1154. ["get", "set", "has"].forEach((methodName) => {
  1155. Object.defineProperty(obj, methodName + accessorName, {
  1156. value: function (arg1, arg2, arg3) {
  1157. return this[methodName].call(this, header, arg1, arg2, arg3);
  1158. },
  1159. configurable: true,
  1160. });
  1161. });
  1162. }
  1163. class AxiosHeaders {
  1164. constructor(headers) {
  1165. headers && this.set(headers);
  1166. }
  1167. set(header, valueOrRewrite, rewrite) {
  1168. const self2 = this;
  1169. function setHeader(_value, _header, _rewrite) {
  1170. const lHeader = normalizeHeader(_header);
  1171. if (!lHeader) {
  1172. throw new Error("header name must be a non-empty string");
  1173. }
  1174. const key = utils$1.findKey(self2, lHeader);
  1175. if (
  1176. !key ||
  1177. self2[key] === void 0 ||
  1178. _rewrite === true ||
  1179. (_rewrite === void 0 && self2[key] !== false)
  1180. ) {
  1181. self2[key || _header] = normalizeValue(_value);
  1182. }
  1183. }
  1184. const setHeaders = (headers, _rewrite) =>
  1185. utils$1.forEach(headers, (_value, _header) =>
  1186. setHeader(_value, _header, _rewrite)
  1187. );
  1188. if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
  1189. setHeaders(header, valueOrRewrite);
  1190. } else if (
  1191. utils$1.isString(header) &&
  1192. (header = header.trim()) &&
  1193. !isValidHeaderName(header)
  1194. ) {
  1195. setHeaders(parseHeaders(header), valueOrRewrite);
  1196. } else if (utils$1.isHeaders(header)) {
  1197. for (const [key, value] of header.entries()) {
  1198. setHeader(value, key, rewrite);
  1199. }
  1200. } else {
  1201. header != null && setHeader(valueOrRewrite, header, rewrite);
  1202. }
  1203. return this;
  1204. }
  1205. get(header, parser) {
  1206. header = normalizeHeader(header);
  1207. if (header) {
  1208. const key = utils$1.findKey(this, header);
  1209. if (key) {
  1210. const value = this[key];
  1211. if (!parser) {
  1212. return value;
  1213. }
  1214. if (parser === true) {
  1215. return parseTokens(value);
  1216. }
  1217. if (utils$1.isFunction(parser)) {
  1218. return parser.call(this, value, key);
  1219. }
  1220. if (utils$1.isRegExp(parser)) {
  1221. return parser.exec(value);
  1222. }
  1223. throw new TypeError("parser must be boolean|regexp|function");
  1224. }
  1225. }
  1226. }
  1227. has(header, matcher) {
  1228. header = normalizeHeader(header);
  1229. if (header) {
  1230. const key = utils$1.findKey(this, header);
  1231. return !!(
  1232. key &&
  1233. this[key] !== void 0 &&
  1234. (!matcher || matchHeaderValue(this, this[key], key, matcher))
  1235. );
  1236. }
  1237. return false;
  1238. }
  1239. delete(header, matcher) {
  1240. const self2 = this;
  1241. let deleted = false;
  1242. function deleteHeader(_header) {
  1243. _header = normalizeHeader(_header);
  1244. if (_header) {
  1245. const key = utils$1.findKey(self2, _header);
  1246. if (
  1247. key &&
  1248. (!matcher || matchHeaderValue(self2, self2[key], key, matcher))
  1249. ) {
  1250. delete self2[key];
  1251. deleted = true;
  1252. }
  1253. }
  1254. }
  1255. if (utils$1.isArray(header)) {
  1256. header.forEach(deleteHeader);
  1257. } else {
  1258. deleteHeader(header);
  1259. }
  1260. return deleted;
  1261. }
  1262. clear(matcher) {
  1263. const keys = Object.keys(this);
  1264. let i = keys.length;
  1265. let deleted = false;
  1266. while (i--) {
  1267. const key = keys[i];
  1268. if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
  1269. delete this[key];
  1270. deleted = true;
  1271. }
  1272. }
  1273. return deleted;
  1274. }
  1275. normalize(format) {
  1276. const self2 = this;
  1277. const headers = {};
  1278. utils$1.forEach(this, (value, header) => {
  1279. const key = utils$1.findKey(headers, header);
  1280. if (key) {
  1281. self2[key] = normalizeValue(value);
  1282. delete self2[header];
  1283. return;
  1284. }
  1285. const normalized = format
  1286. ? formatHeader(header)
  1287. : String(header).trim();
  1288. if (normalized !== header) {
  1289. delete self2[header];
  1290. }
  1291. self2[normalized] = normalizeValue(value);
  1292. headers[normalized] = true;
  1293. });
  1294. return this;
  1295. }
  1296. concat(...targets) {
  1297. return this.constructor.concat(this, ...targets);
  1298. }
  1299. toJSON(asStrings) {
  1300. const obj = /* @__PURE__ */ Object.create(null);
  1301. utils$1.forEach(this, (value, header) => {
  1302. value != null &&
  1303. value !== false &&
  1304. (obj[header] =
  1305. asStrings && utils$1.isArray(value) ? value.join(", ") : value);
  1306. });
  1307. return obj;
  1308. }
  1309. [Symbol.iterator]() {
  1310. return Object.entries(this.toJSON())[Symbol.iterator]();
  1311. }
  1312. toString() {
  1313. return Object.entries(this.toJSON())
  1314. .map(([header, value]) => header + ": " + value)
  1315. .join("\n");
  1316. }
  1317. get [Symbol.toStringTag]() {
  1318. return "AxiosHeaders";
  1319. }
  1320. static from(thing) {
  1321. return thing instanceof this ? thing : new this(thing);
  1322. }
  1323. static concat(first, ...targets) {
  1324. const computed = new this(first);
  1325. targets.forEach((target) => computed.set(target));
  1326. return computed;
  1327. }
  1328. static accessor(header) {
  1329. const internals =
  1330. (this[$internals] =
  1331. this[$internals] =
  1332. {
  1333. accessors: {},
  1334. });
  1335. const accessors = internals.accessors;
  1336. const prototype2 = this.prototype;
  1337. function defineAccessor(_header) {
  1338. const lHeader = normalizeHeader(_header);
  1339. if (!accessors[lHeader]) {
  1340. buildAccessors(prototype2, _header);
  1341. accessors[lHeader] = true;
  1342. }
  1343. }
  1344. utils$1.isArray(header)
  1345. ? header.forEach(defineAccessor)
  1346. : defineAccessor(header);
  1347. return this;
  1348. }
  1349. }
  1350. AxiosHeaders.accessor([
  1351. "Content-Type",
  1352. "Content-Length",
  1353. "Accept",
  1354. "Accept-Encoding",
  1355. "User-Agent",
  1356. "Authorization",
  1357. ]);
  1358. utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
  1359. let mapped = key[0].toUpperCase() + key.slice(1);
  1360. return {
  1361. get: () => value,
  1362. set(headerValue) {
  1363. this[mapped] = headerValue;
  1364. },
  1365. };
  1366. });
  1367. utils$1.freezeMethods(AxiosHeaders);
  1368. function transformData(fns, response) {
  1369. const config = this || defaults;
  1370. const context = response || config;
  1371. const headers = AxiosHeaders.from(context.headers);
  1372. let data = context.data;
  1373. utils$1.forEach(fns, function transform(fn) {
  1374. data = fn.call(
  1375. config,
  1376. data,
  1377. headers.normalize(),
  1378. response ? response.status : void 0
  1379. );
  1380. });
  1381. headers.normalize();
  1382. return data;
  1383. }
  1384. function isCancel(value) {
  1385. return !!(value && value.__CANCEL__);
  1386. }
  1387. function CanceledError(message, config, request) {
  1388. AxiosError.call(
  1389. this,
  1390. message == null ? "canceled" : message,
  1391. AxiosError.ERR_CANCELED,
  1392. config,
  1393. request
  1394. );
  1395. this.name = "CanceledError";
  1396. }
  1397. utils$1.inherits(CanceledError, AxiosError, {
  1398. __CANCEL__: true,
  1399. });
  1400. function settle(resolve, reject, response) {
  1401. const validateStatus2 = response.config.validateStatus;
  1402. if (
  1403. !response.status ||
  1404. !validateStatus2 ||
  1405. validateStatus2(response.status)
  1406. ) {
  1407. resolve(response);
  1408. } else {
  1409. reject(
  1410. new AxiosError(
  1411. "Request failed with status code " + response.status,
  1412. [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][
  1413. Math.floor(response.status / 100) - 4
  1414. ],
  1415. response.config,
  1416. response.request,
  1417. response
  1418. )
  1419. );
  1420. }
  1421. }
  1422. function parseProtocol(url) {
  1423. const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  1424. return (match && match[1]) || "";
  1425. }
  1426. function speedometer(samplesCount, min) {
  1427. samplesCount = samplesCount || 10;
  1428. const bytes = new Array(samplesCount);
  1429. const timestamps = new Array(samplesCount);
  1430. let head = 0;
  1431. let tail = 0;
  1432. let firstSampleTS;
  1433. min = min !== void 0 ? min : 1e3;
  1434. return function push(chunkLength) {
  1435. const now = Date.now();
  1436. const startedAt = timestamps[tail];
  1437. if (!firstSampleTS) {
  1438. firstSampleTS = now;
  1439. }
  1440. bytes[head] = chunkLength;
  1441. timestamps[head] = now;
  1442. let i = tail;
  1443. let bytesCount = 0;
  1444. while (i !== head) {
  1445. bytesCount += bytes[i++];
  1446. i = i % samplesCount;
  1447. }
  1448. head = (head + 1) % samplesCount;
  1449. if (head === tail) {
  1450. tail = (tail + 1) % samplesCount;
  1451. }
  1452. if (now - firstSampleTS < min) {
  1453. return;
  1454. }
  1455. const passed = startedAt && now - startedAt;
  1456. return passed ? Math.round((bytesCount * 1e3) / passed) : void 0;
  1457. };
  1458. }
  1459. function throttle(fn, freq) {
  1460. let timestamp = 0;
  1461. const threshold = 1e3 / freq;
  1462. let timer = null;
  1463. return function throttled() {
  1464. const force = this === true;
  1465. const now = Date.now();
  1466. if (force || now - timestamp > threshold) {
  1467. if (timer) {
  1468. clearTimeout(timer);
  1469. timer = null;
  1470. }
  1471. timestamp = now;
  1472. return fn.apply(null, arguments);
  1473. }
  1474. if (!timer) {
  1475. timer = setTimeout(() => {
  1476. timer = null;
  1477. timestamp = Date.now();
  1478. return fn.apply(null, arguments);
  1479. }, threshold - (now - timestamp));
  1480. }
  1481. };
  1482. }
  1483. const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
  1484. let bytesNotified = 0;
  1485. const _speedometer = speedometer(50, 250);
  1486. return throttle((e) => {
  1487. const loaded = e.loaded;
  1488. const total = e.lengthComputable ? e.total : void 0;
  1489. const progressBytes = loaded - bytesNotified;
  1490. const rate = _speedometer(progressBytes);
  1491. const inRange = loaded <= total;
  1492. bytesNotified = loaded;
  1493. const data = {
  1494. loaded,
  1495. total,
  1496. progress: total ? loaded / total : void 0,
  1497. bytes: progressBytes,
  1498. rate: rate ? rate : void 0,
  1499. estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
  1500. event: e,
  1501. lengthComputable: total != null,
  1502. };
  1503. data[isDownloadStream ? "download" : "upload"] = true;
  1504. listener(data);
  1505. }, freq);
  1506. };
  1507. const isURLSameOrigin = platform.hasStandardBrowserEnv
  1508. ? // Standard browser envs have full support of the APIs needed to test
  1509. // whether the request URL is of the same origin as current location.
  1510. (function standardBrowserEnv() {
  1511. const msie = /(msie|trident)/i.test(navigator.userAgent);
  1512. const urlParsingNode = document.createElement("a");
  1513. let originURL;
  1514. function resolveURL(url) {
  1515. let href = url;
  1516. if (msie) {
  1517. urlParsingNode.setAttribute("href", href);
  1518. href = urlParsingNode.href;
  1519. }
  1520. urlParsingNode.setAttribute("href", href);
  1521. return {
  1522. href: urlParsingNode.href,
  1523. protocol: urlParsingNode.protocol
  1524. ? urlParsingNode.protocol.replace(/:$/, "")
  1525. : "",
  1526. host: urlParsingNode.host,
  1527. search: urlParsingNode.search
  1528. ? urlParsingNode.search.replace(/^\?/, "")
  1529. : "",
  1530. hash: urlParsingNode.hash
  1531. ? urlParsingNode.hash.replace(/^#/, "")
  1532. : "",
  1533. hostname: urlParsingNode.hostname,
  1534. port: urlParsingNode.port,
  1535. pathname:
  1536. urlParsingNode.pathname.charAt(0) === "/"
  1537. ? urlParsingNode.pathname
  1538. : "/" + urlParsingNode.pathname,
  1539. };
  1540. }
  1541. originURL = resolveURL(window.location.href);
  1542. return function isURLSameOrigin2(requestURL) {
  1543. const parsed = utils$1.isString(requestURL)
  1544. ? resolveURL(requestURL)
  1545. : requestURL;
  1546. return (
  1547. parsed.protocol === originURL.protocol &&
  1548. parsed.host === originURL.host
  1549. );
  1550. };
  1551. })()
  1552. : // Non standard browser envs (web workers, react-native) lack needed support.
  1553. /* @__PURE__ */ (function nonStandardBrowserEnv() {
  1554. return function isURLSameOrigin2() {
  1555. return true;
  1556. };
  1557. })();
  1558. const cookies = platform.hasStandardBrowserEnv
  1559. ? // Standard browser envs support document.cookie
  1560. {
  1561. write(name, value, expires, path, domain, secure) {
  1562. const cookie = [name + "=" + encodeURIComponent(value)];
  1563. utils$1.isNumber(expires) &&
  1564. cookie.push("expires=" + new Date(expires).toGMTString());
  1565. utils$1.isString(path) && cookie.push("path=" + path);
  1566. utils$1.isString(domain) && cookie.push("domain=" + domain);
  1567. secure === true && cookie.push("secure");
  1568. document.cookie = cookie.join("; ");
  1569. },
  1570. read(name) {
  1571. const match = document.cookie.match(
  1572. new RegExp("(^|;\\s*)(" + name + ")=([^;]*)")
  1573. );
  1574. return match ? decodeURIComponent(match[3]) : null;
  1575. },
  1576. remove(name) {
  1577. this.write(name, "", Date.now() - 864e5);
  1578. },
  1579. }
  1580. : // Non-standard browser env (web workers, react-native) lack needed support.
  1581. {
  1582. write() {},
  1583. read() {
  1584. return null;
  1585. },
  1586. remove() {},
  1587. };
  1588. function isAbsoluteURL(url) {
  1589. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  1590. }
  1591. function combineURLs(baseURL, relativeURL) {
  1592. return relativeURL
  1593. ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "")
  1594. : baseURL;
  1595. }
  1596. function buildFullPath(baseURL, requestedURL) {
  1597. if (baseURL && !isAbsoluteURL(requestedURL)) {
  1598. return combineURLs(baseURL, requestedURL);
  1599. }
  1600. return requestedURL;
  1601. }
  1602. const headersToObject = (thing) =>
  1603. thing instanceof AxiosHeaders ? { ...thing } : thing;
  1604. function mergeConfig(config1, config2) {
  1605. config2 = config2 || {};
  1606. const config = {};
  1607. function getMergedValue(target, source, caseless) {
  1608. if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
  1609. return utils$1.merge.call({ caseless }, target, source);
  1610. } else if (utils$1.isPlainObject(source)) {
  1611. return utils$1.merge({}, source);
  1612. } else if (utils$1.isArray(source)) {
  1613. return source.slice();
  1614. }
  1615. return source;
  1616. }
  1617. function mergeDeepProperties(a, b, caseless) {
  1618. if (!utils$1.isUndefined(b)) {
  1619. return getMergedValue(a, b, caseless);
  1620. } else if (!utils$1.isUndefined(a)) {
  1621. return getMergedValue(void 0, a, caseless);
  1622. }
  1623. }
  1624. function valueFromConfig2(a, b) {
  1625. if (!utils$1.isUndefined(b)) {
  1626. return getMergedValue(void 0, b);
  1627. }
  1628. }
  1629. function defaultToConfig2(a, b) {
  1630. if (!utils$1.isUndefined(b)) {
  1631. return getMergedValue(void 0, b);
  1632. } else if (!utils$1.isUndefined(a)) {
  1633. return getMergedValue(void 0, a);
  1634. }
  1635. }
  1636. function mergeDirectKeys(a, b, prop) {
  1637. if (prop in config2) {
  1638. return getMergedValue(a, b);
  1639. } else if (prop in config1) {
  1640. return getMergedValue(void 0, a);
  1641. }
  1642. }
  1643. const mergeMap = {
  1644. url: valueFromConfig2,
  1645. method: valueFromConfig2,
  1646. data: valueFromConfig2,
  1647. baseURL: defaultToConfig2,
  1648. transformRequest: defaultToConfig2,
  1649. transformResponse: defaultToConfig2,
  1650. paramsSerializer: defaultToConfig2,
  1651. timeout: defaultToConfig2,
  1652. timeoutMessage: defaultToConfig2,
  1653. withCredentials: defaultToConfig2,
  1654. withXSRFToken: defaultToConfig2,
  1655. adapter: defaultToConfig2,
  1656. responseType: defaultToConfig2,
  1657. xsrfCookieName: defaultToConfig2,
  1658. xsrfHeaderName: defaultToConfig2,
  1659. onUploadProgress: defaultToConfig2,
  1660. onDownloadProgress: defaultToConfig2,
  1661. decompress: defaultToConfig2,
  1662. maxContentLength: defaultToConfig2,
  1663. maxBodyLength: defaultToConfig2,
  1664. beforeRedirect: defaultToConfig2,
  1665. transport: defaultToConfig2,
  1666. httpAgent: defaultToConfig2,
  1667. httpsAgent: defaultToConfig2,
  1668. cancelToken: defaultToConfig2,
  1669. socketPath: defaultToConfig2,
  1670. responseEncoding: defaultToConfig2,
  1671. validateStatus: mergeDirectKeys,
  1672. headers: (a, b) =>
  1673. mergeDeepProperties(headersToObject(a), headersToObject(b), true),
  1674. };
  1675. utils$1.forEach(
  1676. Object.keys(Object.assign({}, config1, config2)),
  1677. function computeConfigValue(prop) {
  1678. const merge2 = mergeMap[prop] || mergeDeepProperties;
  1679. const configValue = merge2(config1[prop], config2[prop], prop);
  1680. (utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys) ||
  1681. (config[prop] = configValue);
  1682. }
  1683. );
  1684. return config;
  1685. }
  1686. const resolveConfig = (config) => {
  1687. const newConfig = mergeConfig({}, config);
  1688. let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } =
  1689. newConfig;
  1690. newConfig.headers = headers = AxiosHeaders.from(headers);
  1691. newConfig.url = buildURL(
  1692. buildFullPath(newConfig.baseURL, newConfig.url),
  1693. config.params,
  1694. config.paramsSerializer
  1695. );
  1696. if (auth) {
  1697. headers.set(
  1698. "Authorization",
  1699. "Basic " +
  1700. btoa(
  1701. (auth.username || "") +
  1702. ":" +
  1703. (auth.password ? unescape(encodeURIComponent(auth.password)) : "")
  1704. )
  1705. );
  1706. }
  1707. let contentType;
  1708. if (utils$1.isFormData(data)) {
  1709. if (
  1710. platform.hasStandardBrowserEnv ||
  1711. platform.hasStandardBrowserWebWorkerEnv
  1712. ) {
  1713. headers.setContentType(void 0);
  1714. } else if ((contentType = headers.getContentType()) !== false) {
  1715. const [type, ...tokens] = contentType
  1716. ? contentType
  1717. .split(";")
  1718. .map((token) => token.trim())
  1719. .filter(Boolean)
  1720. : [];
  1721. headers.setContentType(
  1722. [type || "multipart/form-data", ...tokens].join("; ")
  1723. );
  1724. }
  1725. }
  1726. if (platform.hasStandardBrowserEnv) {
  1727. withXSRFToken &&
  1728. utils$1.isFunction(withXSRFToken) &&
  1729. (withXSRFToken = withXSRFToken(newConfig));
  1730. if (
  1731. withXSRFToken ||
  1732. (withXSRFToken !== false && isURLSameOrigin(newConfig.url))
  1733. ) {
  1734. const xsrfValue =
  1735. xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
  1736. if (xsrfValue) {
  1737. headers.set(xsrfHeaderName, xsrfValue);
  1738. }
  1739. }
  1740. }
  1741. return newConfig;
  1742. };
  1743. const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
  1744. const xhrAdapter =
  1745. isXHRAdapterSupported &&
  1746. function (config) {
  1747. return new Promise(function dispatchXhrRequest(resolve, reject) {
  1748. const _config = resolveConfig(config);
  1749. let requestData = _config.data;
  1750. const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
  1751. let { responseType } = _config;
  1752. let onCanceled;
  1753. function done() {
  1754. if (_config.cancelToken) {
  1755. _config.cancelToken.unsubscribe(onCanceled);
  1756. }
  1757. if (_config.signal) {
  1758. _config.signal.removeEventListener("abort", onCanceled);
  1759. }
  1760. }
  1761. let request = new XMLHttpRequest();
  1762. request.open(_config.method.toUpperCase(), _config.url, true);
  1763. request.timeout = _config.timeout;
  1764. function onloadend() {
  1765. if (!request) {
  1766. return;
  1767. }
  1768. const responseHeaders = AxiosHeaders.from(
  1769. "getAllResponseHeaders" in request &&
  1770. request.getAllResponseHeaders()
  1771. );
  1772. const responseData =
  1773. !responseType || responseType === "text" || responseType === "json"
  1774. ? request.responseText
  1775. : request.response;
  1776. const response = {
  1777. data: responseData,
  1778. status: request.status,
  1779. statusText: request.statusText,
  1780. headers: responseHeaders,
  1781. config,
  1782. request,
  1783. };
  1784. settle(
  1785. function _resolve(value) {
  1786. resolve(value);
  1787. done();
  1788. },
  1789. function _reject(err) {
  1790. reject(err);
  1791. done();
  1792. },
  1793. response
  1794. );
  1795. request = null;
  1796. }
  1797. if ("onloadend" in request) {
  1798. request.onloadend = onloadend;
  1799. } else {
  1800. request.onreadystatechange = function handleLoad() {
  1801. if (!request || request.readyState !== 4) {
  1802. return;
  1803. }
  1804. if (
  1805. request.status === 0 &&
  1806. !(
  1807. request.responseURL &&
  1808. request.responseURL.indexOf("file:") === 0
  1809. )
  1810. ) {
  1811. return;
  1812. }
  1813. setTimeout(onloadend);
  1814. };
  1815. }
  1816. request.onabort = function handleAbort() {
  1817. if (!request) {
  1818. return;
  1819. }
  1820. reject(
  1821. new AxiosError(
  1822. "Request aborted",
  1823. AxiosError.ECONNABORTED,
  1824. _config,
  1825. request
  1826. )
  1827. );
  1828. request = null;
  1829. };
  1830. request.onerror = function handleError() {
  1831. reject(
  1832. new AxiosError(
  1833. "Network Error",
  1834. AxiosError.ERR_NETWORK,
  1835. _config,
  1836. request
  1837. )
  1838. );
  1839. request = null;
  1840. };
  1841. request.ontimeout = function handleTimeout() {
  1842. let timeoutErrorMessage = _config.timeout
  1843. ? "timeout of " + _config.timeout + "ms exceeded"
  1844. : "timeout exceeded";
  1845. const transitional2 = _config.transitional || transitionalDefaults;
  1846. if (_config.timeoutErrorMessage) {
  1847. timeoutErrorMessage = _config.timeoutErrorMessage;
  1848. }
  1849. reject(
  1850. new AxiosError(
  1851. timeoutErrorMessage,
  1852. transitional2.clarifyTimeoutError
  1853. ? AxiosError.ETIMEDOUT
  1854. : AxiosError.ECONNABORTED,
  1855. _config,
  1856. request
  1857. )
  1858. );
  1859. request = null;
  1860. };
  1861. requestData === void 0 && requestHeaders.setContentType(null);
  1862. if ("setRequestHeader" in request) {
  1863. utils$1.forEach(
  1864. requestHeaders.toJSON(),
  1865. function setRequestHeader(val, key) {
  1866. request.setRequestHeader(key, val);
  1867. }
  1868. );
  1869. }
  1870. if (!utils$1.isUndefined(_config.withCredentials)) {
  1871. request.withCredentials = !!_config.withCredentials;
  1872. }
  1873. if (responseType && responseType !== "json") {
  1874. request.responseType = _config.responseType;
  1875. }
  1876. if (typeof _config.onDownloadProgress === "function") {
  1877. request.addEventListener(
  1878. "progress",
  1879. progressEventReducer(_config.onDownloadProgress, true)
  1880. );
  1881. }
  1882. if (typeof _config.onUploadProgress === "function" && request.upload) {
  1883. request.upload.addEventListener(
  1884. "progress",
  1885. progressEventReducer(_config.onUploadProgress)
  1886. );
  1887. }
  1888. if (_config.cancelToken || _config.signal) {
  1889. onCanceled = (cancel) => {
  1890. if (!request) {
  1891. return;
  1892. }
  1893. reject(
  1894. !cancel || cancel.type
  1895. ? new CanceledError(null, config, request)
  1896. : cancel
  1897. );
  1898. request.abort();
  1899. request = null;
  1900. };
  1901. _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
  1902. if (_config.signal) {
  1903. _config.signal.aborted
  1904. ? onCanceled()
  1905. : _config.signal.addEventListener("abort", onCanceled);
  1906. }
  1907. }
  1908. const protocol = parseProtocol(_config.url);
  1909. if (protocol && platform.protocols.indexOf(protocol) === -1) {
  1910. reject(
  1911. new AxiosError(
  1912. "Unsupported protocol " + protocol + ":",
  1913. AxiosError.ERR_BAD_REQUEST,
  1914. config
  1915. )
  1916. );
  1917. return;
  1918. }
  1919. request.send(requestData || null);
  1920. });
  1921. };
  1922. const composeSignals = (signals, timeout) => {
  1923. let controller = new AbortController();
  1924. let aborted;
  1925. const onabort = function (cancel) {
  1926. if (!aborted) {
  1927. aborted = true;
  1928. unsubscribe();
  1929. const err = cancel instanceof Error ? cancel : this.reason;
  1930. controller.abort(
  1931. err instanceof AxiosError
  1932. ? err
  1933. : new CanceledError(err instanceof Error ? err.message : err)
  1934. );
  1935. }
  1936. };
  1937. let timer =
  1938. timeout &&
  1939. setTimeout(() => {
  1940. onabort(
  1941. new AxiosError(
  1942. `timeout ${timeout} of ms exceeded`,
  1943. AxiosError.ETIMEDOUT
  1944. )
  1945. );
  1946. }, timeout);
  1947. const unsubscribe = () => {
  1948. if (signals) {
  1949. timer && clearTimeout(timer);
  1950. timer = null;
  1951. signals.forEach((signal2) => {
  1952. signal2 &&
  1953. (signal2.removeEventListener
  1954. ? signal2.removeEventListener("abort", onabort)
  1955. : signal2.unsubscribe(onabort));
  1956. });
  1957. signals = null;
  1958. }
  1959. };
  1960. signals.forEach(
  1961. (signal2) =>
  1962. signal2 &&
  1963. signal2.addEventListener &&
  1964. signal2.addEventListener("abort", onabort)
  1965. );
  1966. const { signal } = controller;
  1967. signal.unsubscribe = unsubscribe;
  1968. return [
  1969. signal,
  1970. () => {
  1971. timer && clearTimeout(timer);
  1972. timer = null;
  1973. },
  1974. ];
  1975. };
  1976. const streamChunk = function* (chunk, chunkSize) {
  1977. let len = chunk.byteLength;
  1978. if (len < chunkSize) {
  1979. yield chunk;
  1980. return;
  1981. }
  1982. let pos = 0;
  1983. let end;
  1984. while (pos < len) {
  1985. end = pos + chunkSize;
  1986. yield chunk.slice(pos, end);
  1987. pos = end;
  1988. }
  1989. };
  1990. const readBytes = async function* (iterable, chunkSize, encode2) {
  1991. for await (const chunk of iterable) {
  1992. yield* streamChunk(
  1993. ArrayBuffer.isView(chunk) ? chunk : await encode2(String(chunk)),
  1994. chunkSize
  1995. );
  1996. }
  1997. };
  1998. const trackStream = (stream, chunkSize, onProgress, onFinish, encode2) => {
  1999. const iterator = readBytes(stream, chunkSize, encode2);
  2000. let bytes = 0;
  2001. return new ReadableStream(
  2002. {
  2003. type: "bytes",
  2004. async pull(controller) {
  2005. const { done, value } = await iterator.next();
  2006. if (done) {
  2007. controller.close();
  2008. onFinish();
  2009. return;
  2010. }
  2011. let len = value.byteLength;
  2012. onProgress && onProgress((bytes += len));
  2013. controller.enqueue(new Uint8Array(value));
  2014. },
  2015. cancel(reason) {
  2016. onFinish(reason);
  2017. return iterator.return();
  2018. },
  2019. },
  2020. {
  2021. highWaterMark: 2,
  2022. }
  2023. );
  2024. };
  2025. const fetchProgressDecorator = (total, fn) => {
  2026. const lengthComputable = total != null;
  2027. return (loaded) =>
  2028. setTimeout(() =>
  2029. fn({
  2030. lengthComputable,
  2031. total,
  2032. loaded,
  2033. })
  2034. );
  2035. };
  2036. const isFetchSupported =
  2037. typeof fetch === "function" &&
  2038. typeof Request === "function" &&
  2039. typeof Response === "function";
  2040. const isReadableStreamSupported =
  2041. isFetchSupported && typeof ReadableStream === "function";
  2042. const encodeText =
  2043. isFetchSupported &&
  2044. (typeof TextEncoder === "function"
  2045. ? /* @__PURE__ */ (
  2046. (encoder) => (str) =>
  2047. encoder.encode(str)
  2048. )(new TextEncoder())
  2049. : async (str) => new Uint8Array(await new Response(str).arrayBuffer()));
  2050. const supportsRequestStream =
  2051. isReadableStreamSupported &&
  2052. (() => {
  2053. let duplexAccessed = false;
  2054. const hasContentType = new Request(platform.origin, {
  2055. body: new ReadableStream(),
  2056. method: "POST",
  2057. get duplex() {
  2058. duplexAccessed = true;
  2059. return "half";
  2060. },
  2061. }).headers.has("Content-Type");
  2062. return duplexAccessed && !hasContentType;
  2063. })();
  2064. const DEFAULT_CHUNK_SIZE = 64 * 1024;
  2065. const supportsResponseStream =
  2066. isReadableStreamSupported &&
  2067. !!(() => {
  2068. try {
  2069. return utils$1.isReadableStream(new Response("").body);
  2070. } catch (err) {}
  2071. })();
  2072. const resolvers = {
  2073. stream: supportsResponseStream && ((res) => res.body),
  2074. };
  2075. isFetchSupported &&
  2076. ((res) => {
  2077. ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
  2078. !resolvers[type] &&
  2079. (resolvers[type] = utils$1.isFunction(res[type])
  2080. ? (res2) => res2[type]()
  2081. : (_, config) => {
  2082. throw new AxiosError(
  2083. `Response type '${type}' is not supported`,
  2084. AxiosError.ERR_NOT_SUPPORT,
  2085. config
  2086. );
  2087. });
  2088. });
  2089. })(new Response());
  2090. const getBodyLength = async (body) => {
  2091. if (body == null) {
  2092. return 0;
  2093. }
  2094. if (utils$1.isBlob(body)) {
  2095. return body.size;
  2096. }
  2097. if (utils$1.isSpecCompliantForm(body)) {
  2098. return (await new Request(body).arrayBuffer()).byteLength;
  2099. }
  2100. if (utils$1.isArrayBufferView(body)) {
  2101. return body.byteLength;
  2102. }
  2103. if (utils$1.isURLSearchParams(body)) {
  2104. body = body + "";
  2105. }
  2106. if (utils$1.isString(body)) {
  2107. return (await encodeText(body)).byteLength;
  2108. }
  2109. };
  2110. const resolveBodyLength = async (headers, body) => {
  2111. const length = utils$1.toFiniteNumber(headers.getContentLength());
  2112. return length == null ? getBodyLength(body) : length;
  2113. };
  2114. const fetchAdapter =
  2115. isFetchSupported &&
  2116. (async (config) => {
  2117. let {
  2118. url,
  2119. method,
  2120. data,
  2121. signal,
  2122. cancelToken,
  2123. timeout,
  2124. onDownloadProgress,
  2125. onUploadProgress,
  2126. responseType,
  2127. headers,
  2128. withCredentials = "same-origin",
  2129. fetchOptions,
  2130. } = resolveConfig(config);
  2131. responseType = responseType ? (responseType + "").toLowerCase() : "text";
  2132. let [composedSignal, stopTimeout] =
  2133. signal || cancelToken || timeout
  2134. ? composeSignals([signal, cancelToken], timeout)
  2135. : [];
  2136. let finished, request;
  2137. const onFinish = () => {
  2138. !finished &&
  2139. setTimeout(() => {
  2140. composedSignal && composedSignal.unsubscribe();
  2141. });
  2142. finished = true;
  2143. };
  2144. let requestContentLength;
  2145. try {
  2146. if (
  2147. onUploadProgress &&
  2148. supportsRequestStream &&
  2149. method !== "get" &&
  2150. method !== "head" &&
  2151. (requestContentLength = await resolveBodyLength(headers, data)) !== 0
  2152. ) {
  2153. let _request = new Request(url, {
  2154. method: "POST",
  2155. body: data,
  2156. duplex: "half",
  2157. });
  2158. let contentTypeHeader;
  2159. if (
  2160. utils$1.isFormData(data) &&
  2161. (contentTypeHeader = _request.headers.get("content-type"))
  2162. ) {
  2163. headers.setContentType(contentTypeHeader);
  2164. }
  2165. if (_request.body) {
  2166. data = trackStream(
  2167. _request.body,
  2168. DEFAULT_CHUNK_SIZE,
  2169. fetchProgressDecorator(
  2170. requestContentLength,
  2171. progressEventReducer(onUploadProgress)
  2172. ),
  2173. null,
  2174. encodeText
  2175. );
  2176. }
  2177. }
  2178. if (!utils$1.isString(withCredentials)) {
  2179. withCredentials = withCredentials ? "cors" : "omit";
  2180. }
  2181. request = new Request(url, {
  2182. ...fetchOptions,
  2183. signal: composedSignal,
  2184. method: method.toUpperCase(),
  2185. headers: headers.normalize().toJSON(),
  2186. body: data,
  2187. duplex: "half",
  2188. withCredentials,
  2189. });
  2190. let response = await fetch(request);
  2191. const isStreamResponse =
  2192. supportsResponseStream &&
  2193. (responseType === "stream" || responseType === "response");
  2194. if (
  2195. supportsResponseStream &&
  2196. (onDownloadProgress || isStreamResponse)
  2197. ) {
  2198. const options = {};
  2199. ["status", "statusText", "headers"].forEach((prop) => {
  2200. options[prop] = response[prop];
  2201. });
  2202. const responseContentLength = utils$1.toFiniteNumber(
  2203. response.headers.get("content-length")
  2204. );
  2205. response = new Response(
  2206. trackStream(
  2207. response.body,
  2208. DEFAULT_CHUNK_SIZE,
  2209. onDownloadProgress &&
  2210. fetchProgressDecorator(
  2211. responseContentLength,
  2212. progressEventReducer(onDownloadProgress, true)
  2213. ),
  2214. isStreamResponse && onFinish,
  2215. encodeText
  2216. ),
  2217. options
  2218. );
  2219. }
  2220. responseType = responseType || "text";
  2221. let responseData = await resolvers[
  2222. utils$1.findKey(resolvers, responseType) || "text"
  2223. ](response, config);
  2224. !isStreamResponse && onFinish();
  2225. stopTimeout && stopTimeout();
  2226. return await new Promise((resolve, reject) => {
  2227. settle(resolve, reject, {
  2228. data: responseData,
  2229. headers: AxiosHeaders.from(response.headers),
  2230. status: response.status,
  2231. statusText: response.statusText,
  2232. config,
  2233. request,
  2234. });
  2235. });
  2236. } catch (err) {
  2237. onFinish();
  2238. if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
  2239. throw Object.assign(
  2240. new AxiosError(
  2241. "Network Error",
  2242. AxiosError.ERR_NETWORK,
  2243. config,
  2244. request
  2245. ),
  2246. {
  2247. cause: err.cause || err,
  2248. }
  2249. );
  2250. }
  2251. throw AxiosError.from(err, err && err.code, config, request);
  2252. }
  2253. });
  2254. const knownAdapters = {
  2255. http: httpAdapter,
  2256. xhr: xhrAdapter,
  2257. fetch: fetchAdapter,
  2258. };
  2259. utils$1.forEach(knownAdapters, (fn, value) => {
  2260. if (fn) {
  2261. try {
  2262. Object.defineProperty(fn, "name", { value });
  2263. } catch (e) {}
  2264. Object.defineProperty(fn, "adapterName", { value });
  2265. }
  2266. });
  2267. const renderReason = (reason) => `- ${reason}`;
  2268. const isResolvedHandle = (adapter) =>
  2269. utils$1.isFunction(adapter) || adapter === null || adapter === false;
  2270. const adapters = {
  2271. getAdapter: (adapters2) => {
  2272. adapters2 = utils$1.isArray(adapters2) ? adapters2 : [adapters2];
  2273. const { length } = adapters2;
  2274. let nameOrAdapter;
  2275. let adapter;
  2276. const rejectedReasons = {};
  2277. for (let i = 0; i < length; i++) {
  2278. nameOrAdapter = adapters2[i];
  2279. let id;
  2280. adapter = nameOrAdapter;
  2281. if (!isResolvedHandle(nameOrAdapter)) {
  2282. adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
  2283. if (adapter === void 0) {
  2284. throw new AxiosError(`Unknown adapter '${id}'`);
  2285. }
  2286. }
  2287. if (adapter) {
  2288. break;
  2289. }
  2290. rejectedReasons[id || "#" + i] = adapter;
  2291. }
  2292. if (!adapter) {
  2293. const reasons = Object.entries(rejectedReasons).map(
  2294. ([id, state]) =>
  2295. `adapter ${id} ` +
  2296. (state === false
  2297. ? "is not supported by the environment"
  2298. : "is not available in the build")
  2299. );
  2300. let s = length
  2301. ? reasons.length > 1
  2302. ? "since :\n" + reasons.map(renderReason).join("\n")
  2303. : " " + renderReason(reasons[0])
  2304. : "as no adapter specified";
  2305. throw new AxiosError(
  2306. `There is no suitable adapter to dispatch the request ` + s,
  2307. "ERR_NOT_SUPPORT"
  2308. );
  2309. }
  2310. return adapter;
  2311. },
  2312. adapters: knownAdapters,
  2313. };
  2314. function throwIfCancellationRequested(config) {
  2315. if (config.cancelToken) {
  2316. config.cancelToken.throwIfRequested();
  2317. }
  2318. if (config.signal && config.signal.aborted) {
  2319. throw new CanceledError(null, config);
  2320. }
  2321. }
  2322. function dispatchRequest(config) {
  2323. throwIfCancellationRequested(config);
  2324. config.headers = AxiosHeaders.from(config.headers);
  2325. config.data = transformData.call(config, config.transformRequest);
  2326. if (["post", "put", "patch"].indexOf(config.method) !== -1) {
  2327. config.headers.setContentType("application/x-www-form-urlencoded", false);
  2328. }
  2329. const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
  2330. return adapter(config).then(
  2331. function onAdapterResolution(response) {
  2332. throwIfCancellationRequested(config);
  2333. response.data = transformData.call(
  2334. config,
  2335. config.transformResponse,
  2336. response
  2337. );
  2338. response.headers = AxiosHeaders.from(response.headers);
  2339. return response;
  2340. },
  2341. function onAdapterRejection(reason) {
  2342. if (!isCancel(reason)) {
  2343. throwIfCancellationRequested(config);
  2344. if (reason && reason.response) {
  2345. reason.response.data = transformData.call(
  2346. config,
  2347. config.transformResponse,
  2348. reason.response
  2349. );
  2350. reason.response.headers = AxiosHeaders.from(
  2351. reason.response.headers
  2352. );
  2353. }
  2354. }
  2355. return Promise.reject(reason);
  2356. }
  2357. );
  2358. }
  2359. const VERSION = "1.7.2";
  2360. const validators$1 = {};
  2361. ["object", "boolean", "number", "function", "string", "symbol"].forEach(
  2362. (type, i) => {
  2363. validators$1[type] = function validator2(thing) {
  2364. return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
  2365. };
  2366. }
  2367. );
  2368. const deprecatedWarnings = {};
  2369. validators$1.transitional = function transitional(
  2370. validator2,
  2371. version,
  2372. message
  2373. ) {
  2374. function formatMessage(opt, desc) {
  2375. return (
  2376. "[Axios v" +
  2377. VERSION +
  2378. "] Transitional option '" +
  2379. opt +
  2380. "'" +
  2381. desc +
  2382. (message ? ". " + message : "")
  2383. );
  2384. }
  2385. return (value, opt, opts) => {
  2386. if (validator2 === false) {
  2387. throw new AxiosError(
  2388. formatMessage(
  2389. opt,
  2390. " has been removed" + (version ? " in " + version : "")
  2391. ),
  2392. AxiosError.ERR_DEPRECATED
  2393. );
  2394. }
  2395. if (version && !deprecatedWarnings[opt]) {
  2396. deprecatedWarnings[opt] = true;
  2397. console.warn(
  2398. formatMessage(
  2399. opt,
  2400. " has been deprecated since v" +
  2401. version +
  2402. " and will be removed in the near future"
  2403. )
  2404. );
  2405. }
  2406. return validator2 ? validator2(value, opt, opts) : true;
  2407. };
  2408. };
  2409. function assertOptions(options, schema, allowUnknown) {
  2410. if (typeof options !== "object") {
  2411. throw new AxiosError(
  2412. "options must be an object",
  2413. AxiosError.ERR_BAD_OPTION_VALUE
  2414. );
  2415. }
  2416. const keys = Object.keys(options);
  2417. let i = keys.length;
  2418. while (i-- > 0) {
  2419. const opt = keys[i];
  2420. const validator2 = schema[opt];
  2421. if (validator2) {
  2422. const value = options[opt];
  2423. const result = value === void 0 || validator2(value, opt, options);
  2424. if (result !== true) {
  2425. throw new AxiosError(
  2426. "option " + opt + " must be " + result,
  2427. AxiosError.ERR_BAD_OPTION_VALUE
  2428. );
  2429. }
  2430. continue;
  2431. }
  2432. if (allowUnknown !== true) {
  2433. throw new AxiosError(
  2434. "Unknown option " + opt,
  2435. AxiosError.ERR_BAD_OPTION
  2436. );
  2437. }
  2438. }
  2439. }
  2440. const validator = {
  2441. assertOptions,
  2442. validators: validators$1,
  2443. };
  2444. const validators = validator.validators;
  2445. class Axios {
  2446. constructor(instanceConfig) {
  2447. this.defaults = instanceConfig;
  2448. this.interceptors = {
  2449. request: new InterceptorManager(),
  2450. response: new InterceptorManager(),
  2451. };
  2452. }
  2453. /**
  2454. * Dispatch a request
  2455. *
  2456. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  2457. * @param {?Object} config
  2458. *
  2459. * @returns {Promise} The Promise to be fulfilled
  2460. */
  2461. async request(configOrUrl, config) {
  2462. try {
  2463. return await this._request(configOrUrl, config);
  2464. } catch (err) {
  2465. if (err instanceof Error) {
  2466. let dummy;
  2467. Error.captureStackTrace
  2468. ? Error.captureStackTrace((dummy = {}))
  2469. : (dummy = new Error());
  2470. const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
  2471. try {
  2472. if (!err.stack) {
  2473. err.stack = stack;
  2474. } else if (
  2475. stack &&
  2476. !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))
  2477. ) {
  2478. err.stack += "\n" + stack;
  2479. }
  2480. } catch (e) {}
  2481. }
  2482. throw err;
  2483. }
  2484. }
  2485. _request(configOrUrl, config) {
  2486. if (typeof configOrUrl === "string") {
  2487. config = config || {};
  2488. config.url = configOrUrl;
  2489. } else {
  2490. config = configOrUrl || {};
  2491. }
  2492. config = mergeConfig(this.defaults, config);
  2493. const { transitional: transitional2, paramsSerializer, headers } = config;
  2494. if (transitional2 !== void 0) {
  2495. validator.assertOptions(
  2496. transitional2,
  2497. {
  2498. silentJSONParsing: validators.transitional(validators.boolean),
  2499. forcedJSONParsing: validators.transitional(validators.boolean),
  2500. clarifyTimeoutError: validators.transitional(validators.boolean),
  2501. },
  2502. false
  2503. );
  2504. }
  2505. if (paramsSerializer != null) {
  2506. if (utils$1.isFunction(paramsSerializer)) {
  2507. config.paramsSerializer = {
  2508. serialize: paramsSerializer,
  2509. };
  2510. } else {
  2511. validator.assertOptions(
  2512. paramsSerializer,
  2513. {
  2514. encode: validators.function,
  2515. serialize: validators.function,
  2516. },
  2517. true
  2518. );
  2519. }
  2520. }
  2521. config.method = (
  2522. config.method ||
  2523. this.defaults.method ||
  2524. "get"
  2525. ).toLowerCase();
  2526. let contextHeaders =
  2527. headers && utils$1.merge(headers.common, headers[config.method]);
  2528. headers &&
  2529. utils$1.forEach(
  2530. ["delete", "get", "head", "post", "put", "patch", "common"],
  2531. (method) => {
  2532. delete headers[method];
  2533. }
  2534. );
  2535. config.headers = AxiosHeaders.concat(contextHeaders, headers);
  2536. const requestInterceptorChain = [];
  2537. let synchronousRequestInterceptors = true;
  2538. this.interceptors.request.forEach(function unshiftRequestInterceptors(
  2539. interceptor
  2540. ) {
  2541. if (
  2542. typeof interceptor.runWhen === "function" &&
  2543. interceptor.runWhen(config) === false
  2544. ) {
  2545. return;
  2546. }
  2547. synchronousRequestInterceptors =
  2548. synchronousRequestInterceptors && interceptor.synchronous;
  2549. requestInterceptorChain.unshift(
  2550. interceptor.fulfilled,
  2551. interceptor.rejected
  2552. );
  2553. });
  2554. const responseInterceptorChain = [];
  2555. this.interceptors.response.forEach(function pushResponseInterceptors(
  2556. interceptor
  2557. ) {
  2558. responseInterceptorChain.push(
  2559. interceptor.fulfilled,
  2560. interceptor.rejected
  2561. );
  2562. });
  2563. let promise;
  2564. let i = 0;
  2565. let len;
  2566. if (!synchronousRequestInterceptors) {
  2567. const chain = [dispatchRequest.bind(this), void 0];
  2568. chain.unshift.apply(chain, requestInterceptorChain);
  2569. chain.push.apply(chain, responseInterceptorChain);
  2570. len = chain.length;
  2571. promise = Promise.resolve(config);
  2572. while (i < len) {
  2573. promise = promise.then(chain[i++], chain[i++]);
  2574. }
  2575. return promise;
  2576. }
  2577. len = requestInterceptorChain.length;
  2578. let newConfig = config;
  2579. i = 0;
  2580. while (i < len) {
  2581. const onFulfilled = requestInterceptorChain[i++];
  2582. const onRejected = requestInterceptorChain[i++];
  2583. try {
  2584. newConfig = onFulfilled(newConfig);
  2585. } catch (error) {
  2586. onRejected.call(this, error);
  2587. break;
  2588. }
  2589. }
  2590. try {
  2591. promise = dispatchRequest.call(this, newConfig);
  2592. } catch (error) {
  2593. return Promise.reject(error);
  2594. }
  2595. i = 0;
  2596. len = responseInterceptorChain.length;
  2597. while (i < len) {
  2598. promise = promise.then(
  2599. responseInterceptorChain[i++],
  2600. responseInterceptorChain[i++]
  2601. );
  2602. }
  2603. return promise;
  2604. }
  2605. getUri(config) {
  2606. config = mergeConfig(this.defaults, config);
  2607. const fullPath = buildFullPath(config.baseURL, config.url);
  2608. return buildURL(fullPath, config.params, config.paramsSerializer);
  2609. }
  2610. }
  2611. utils$1.forEach(
  2612. ["delete", "get", "head", "options"],
  2613. function forEachMethodNoData(method) {
  2614. Axios.prototype[method] = function (url, config) {
  2615. return this.request(
  2616. mergeConfig(config || {}, {
  2617. method,
  2618. url,
  2619. data: (config || {}).data,
  2620. })
  2621. );
  2622. };
  2623. }
  2624. );
  2625. utils$1.forEach(
  2626. ["post", "put", "patch"],
  2627. function forEachMethodWithData(method) {
  2628. function generateHTTPMethod(isForm) {
  2629. return function httpMethod(url, data, config) {
  2630. return this.request(
  2631. mergeConfig(config || {}, {
  2632. method,
  2633. headers: isForm
  2634. ? {
  2635. "Content-Type": "multipart/form-data",
  2636. }
  2637. : {},
  2638. url,
  2639. data,
  2640. })
  2641. );
  2642. };
  2643. }
  2644. Axios.prototype[method] = generateHTTPMethod();
  2645. Axios.prototype[method + "Form"] = generateHTTPMethod(true);
  2646. }
  2647. );
  2648. class CancelToken {
  2649. constructor(executor) {
  2650. if (typeof executor !== "function") {
  2651. throw new TypeError("executor must be a function.");
  2652. }
  2653. let resolvePromise;
  2654. this.promise = new Promise(function promiseExecutor(resolve) {
  2655. resolvePromise = resolve;
  2656. });
  2657. const token = this;
  2658. this.promise.then((cancel) => {
  2659. if (!token._listeners) return;
  2660. let i = token._listeners.length;
  2661. while (i-- > 0) {
  2662. token._listeners[i](cancel);
  2663. }
  2664. token._listeners = null;
  2665. });
  2666. this.promise.then = (onfulfilled) => {
  2667. let _resolve;
  2668. const promise = new Promise((resolve) => {
  2669. token.subscribe(resolve);
  2670. _resolve = resolve;
  2671. }).then(onfulfilled);
  2672. promise.cancel = function reject() {
  2673. token.unsubscribe(_resolve);
  2674. };
  2675. return promise;
  2676. };
  2677. executor(function cancel(message, config, request) {
  2678. if (token.reason) {
  2679. return;
  2680. }
  2681. token.reason = new CanceledError(message, config, request);
  2682. resolvePromise(token.reason);
  2683. });
  2684. }
  2685. /**
  2686. * Throws a `CanceledError` if cancellation has been requested.
  2687. */
  2688. throwIfRequested() {
  2689. if (this.reason) {
  2690. throw this.reason;
  2691. }
  2692. }
  2693. /**
  2694. * Subscribe to the cancel signal
  2695. */
  2696. subscribe(listener) {
  2697. if (this.reason) {
  2698. listener(this.reason);
  2699. return;
  2700. }
  2701. if (this._listeners) {
  2702. this._listeners.push(listener);
  2703. } else {
  2704. this._listeners = [listener];
  2705. }
  2706. }
  2707. /**
  2708. * Unsubscribe from the cancel signal
  2709. */
  2710. unsubscribe(listener) {
  2711. if (!this._listeners) {
  2712. return;
  2713. }
  2714. const index = this._listeners.indexOf(listener);
  2715. if (index !== -1) {
  2716. this._listeners.splice(index, 1);
  2717. }
  2718. }
  2719. /**
  2720. * Returns an object that contains a new `CancelToken` and a function that, when called,
  2721. * cancels the `CancelToken`.
  2722. */
  2723. static source() {
  2724. let cancel;
  2725. const token = new CancelToken(function executor(c) {
  2726. cancel = c;
  2727. });
  2728. return {
  2729. token,
  2730. cancel,
  2731. };
  2732. }
  2733. }
  2734. function spread(callback) {
  2735. return function wrap(arr) {
  2736. return callback.apply(null, arr);
  2737. };
  2738. }
  2739. function isAxiosError(payload) {
  2740. return utils$1.isObject(payload) && payload.isAxiosError === true;
  2741. }
  2742. const HttpStatusCode = {
  2743. Continue: 100,
  2744. SwitchingProtocols: 101,
  2745. Processing: 102,
  2746. EarlyHints: 103,
  2747. Ok: 200,
  2748. Created: 201,
  2749. Accepted: 202,
  2750. NonAuthoritativeInformation: 203,
  2751. NoContent: 204,
  2752. ResetContent: 205,
  2753. PartialContent: 206,
  2754. MultiStatus: 207,
  2755. AlreadyReported: 208,
  2756. ImUsed: 226,
  2757. MultipleChoices: 300,
  2758. MovedPermanently: 301,
  2759. Found: 302,
  2760. SeeOther: 303,
  2761. NotModified: 304,
  2762. UseProxy: 305,
  2763. Unused: 306,
  2764. TemporaryRedirect: 307,
  2765. PermanentRedirect: 308,
  2766. BadRequest: 400,
  2767. Unauthorized: 401,
  2768. PaymentRequired: 402,
  2769. Forbidden: 403,
  2770. NotFound: 404,
  2771. MethodNotAllowed: 405,
  2772. NotAcceptable: 406,
  2773. ProxyAuthenticationRequired: 407,
  2774. RequestTimeout: 408,
  2775. Conflict: 409,
  2776. Gone: 410,
  2777. LengthRequired: 411,
  2778. PreconditionFailed: 412,
  2779. PayloadTooLarge: 413,
  2780. UriTooLong: 414,
  2781. UnsupportedMediaType: 415,
  2782. RangeNotSatisfiable: 416,
  2783. ExpectationFailed: 417,
  2784. ImATeapot: 418,
  2785. MisdirectedRequest: 421,
  2786. UnprocessableEntity: 422,
  2787. Locked: 423,
  2788. FailedDependency: 424,
  2789. TooEarly: 425,
  2790. UpgradeRequired: 426,
  2791. PreconditionRequired: 428,
  2792. TooManyRequests: 429,
  2793. RequestHeaderFieldsTooLarge: 431,
  2794. UnavailableForLegalReasons: 451,
  2795. InternalServerError: 500,
  2796. NotImplemented: 501,
  2797. BadGateway: 502,
  2798. ServiceUnavailable: 503,
  2799. GatewayTimeout: 504,
  2800. HttpVersionNotSupported: 505,
  2801. VariantAlsoNegotiates: 506,
  2802. InsufficientStorage: 507,
  2803. LoopDetected: 508,
  2804. NotExtended: 510,
  2805. NetworkAuthenticationRequired: 511,
  2806. };
  2807. Object.entries(HttpStatusCode).forEach(([key, value]) => {
  2808. HttpStatusCode[value] = key;
  2809. });
  2810. function createInstance(defaultConfig) {
  2811. const context = new Axios(defaultConfig);
  2812. const instance = bind(Axios.prototype.request, context);
  2813. utils$1.extend(instance, Axios.prototype, context, { allOwnKeys: true });
  2814. utils$1.extend(instance, context, null, { allOwnKeys: true });
  2815. instance.create = function create(instanceConfig) {
  2816. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  2817. };
  2818. return instance;
  2819. }
  2820. const axios = createInstance(defaults);
  2821. axios.Axios = Axios;
  2822. axios.CanceledError = CanceledError;
  2823. axios.CancelToken = CancelToken;
  2824. axios.isCancel = isCancel;
  2825. axios.VERSION = VERSION;
  2826. axios.toFormData = toFormData;
  2827. axios.AxiosError = AxiosError;
  2828. axios.Cancel = axios.CanceledError;
  2829. axios.all = function all(promises) {
  2830. return Promise.all(promises);
  2831. };
  2832. axios.spread = spread;
  2833. axios.isAxiosError = isAxiosError;
  2834. axios.mergeConfig = mergeConfig;
  2835. axios.AxiosHeaders = AxiosHeaders;
  2836. axios.formToJSON = (thing) =>
  2837. formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
  2838. axios.getAdapter = adapters.getAdapter;
  2839. axios.HttpStatusCode = HttpStatusCode;
  2840. axios.default = axios;
  2841. const useOption = (key, title, defaultValue) => {
  2842. if (typeof _GM_getValue === "undefined") {
  2843. return {
  2844. value: defaultValue,
  2845. };
  2846. }
  2847. let value = _GM_getValue(key, defaultValue);
  2848. const ref = {
  2849. get value() {
  2850. return value;
  2851. },
  2852. set value(v) {
  2853. value = v;
  2854. _GM_setValue(key, v);
  2855. location.reload();
  2856. },
  2857. };
  2858. _GM_registerMenuCommand(`${title}: ${value ? "✅" : "❌"}`, () => {
  2859. ref.value = !value;
  2860. });
  2861. return ref;
  2862. };
  2863. const getCsrfToken = () => {
  2864. const match = _unsafeWindow.document.cookie.match(
  2865. /\bbili_jct=(.+?)(?:;|$)/
  2866. );
  2867. return match ? match[1] : "";
  2868. };
  2869. const hideHomeTabs = useOption(
  2870. "isDanmakuScrollModeLocked",
  2871. "是否锁定弹幕为滚动模式",
  2872. true
  2873. );
  2874. const setDanmakuLocationConfig = async (csrf, mode) => {
  2875. let data = new FormData();
  2876. data.append("mode", mode);
  2877. data.append("csrf_token", csrf);
  2878. data.append("csrf", csrf);
  2879. data.append(
  2880. "room_id",
  2881. _unsafeWindow.__NEPTUNE_IS_MY_WAIFU__.roomInfoRes.data.room_info.room_id
  2882. );
  2883. data.append("visit_id", "");
  2884. const response = await axios.post(
  2885. "https://api.live.bilibili.com/xlive/web-room/v1/dM/AjaxSetConfig",
  2886. data,
  2887. { withCredentials: true }
  2888. );
  2889. if (response.data.code === 0) {
  2890. console.log("设置弹幕位置成功");
  2891. } else {
  2892. console.log("%c Line:68 🍣 response", "color:#3f7cff", response);
  2893. alert("设置弹幕位置失败,请手动设置为滚动模式");
  2894. }
  2895. };
  2896. if (hideHomeTabs.value) {
  2897. const csrf = getCsrfToken();
  2898. await setDanmakuLocationConfig(
  2899. csrf,
  2900. "1"
  2901. /* scroll */
  2902. );
  2903. }
  2904. })();

QingJ © 2025

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