掘金扩展助手

提供一个扩展平台,聚合掘金社区的各类第三方扩展,可插拔使用。扩展旨在为掘金社区提供辅助支持。

  1. // ==UserScript==
  2. // @name Juejin Extension Enhancer
  3. // @namespace juejin-enhancer
  4. // @version 1.0.3
  5. // @description Enhances Juejin
  6. // @include *
  7. // @name:zh-CN 掘金扩展助手
  8. // @description:zh-CN 提供一个扩展平台,聚合掘金社区的各类第三方扩展,可插拔使用。扩展旨在为掘金社区提供辅助支持。
  9. // @match *
  10. // @run-at document-end
  11. // @require https://code.jquery.com/jquery-3.6.0.min.js
  12. // @grant GM_addStyle
  13. // @grant GM_addElement
  14. // @grant GM_log
  15. // @grant GM_setValue
  16. // @grant GM_getValue
  17. // @grant GM_deleteValue
  18. // @grant GM_listValues
  19. // @grant GM_addValueChangeListener
  20. // @grant GM_removeValueChangeListener
  21. // @grant GM_getResourceText
  22. // @grant GM_getResourceURL
  23. // @grant GM_registerMenuCommand
  24. // @grant GM_unregisterMenuCommand
  25. // @grant GM_openInTab
  26. // @grant GM_xmlhttpRequest
  27. // @grant GM_download
  28. // @grant GM_getTab
  29. // @grant GM_saveTab
  30. // @grant GM_getTabs
  31. // @grant GM_notification
  32. // @grant GM_setClipboard
  33. // @connect juejin.cn
  34. // @connect github.com
  35. // @connect gitee.com
  36. // @connect juejin-enhancer-extensions.vercel.app
  37. // ==/UserScript==
  38. (function () {
  39. 'use strict';
  40.  
  41. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  42.  
  43. var check = function (it) {
  44. return it && it.Math == Math && it;
  45. };
  46.  
  47. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  48. var global$e =
  49. // eslint-disable-next-line es/no-global-this -- safe
  50. check(typeof globalThis == 'object' && globalThis) ||
  51. check(typeof window == 'object' && window) ||
  52. // eslint-disable-next-line no-restricted-globals -- safe
  53. check(typeof self == 'object' && self) ||
  54. check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
  55. // eslint-disable-next-line no-new-func -- fallback
  56. (function () { return this; })() || Function('return this')();
  57.  
  58. var objectGetOwnPropertyDescriptor = {};
  59.  
  60. var fails$a = function (exec) {
  61. try {
  62. return !!exec();
  63. } catch (error) {
  64. return true;
  65. }
  66. };
  67.  
  68. var fails$9 = fails$a;
  69.  
  70. // Detect IE8's incomplete defineProperty implementation
  71. var descriptors = !fails$9(function () {
  72. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  73. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  74. });
  75.  
  76. var objectPropertyIsEnumerable = {};
  77.  
  78. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  79. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  80. var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  81.  
  82. // Nashorn ~ JDK8 bug
  83. var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  84.  
  85. // `Object.prototype.propertyIsEnumerable` method implementation
  86. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  87. objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  88. var descriptor = getOwnPropertyDescriptor$1(this, V);
  89. return !!descriptor && descriptor.enumerable;
  90. } : $propertyIsEnumerable;
  91.  
  92. var createPropertyDescriptor$2 = function (bitmap, value) {
  93. return {
  94. enumerable: !(bitmap & 1),
  95. configurable: !(bitmap & 2),
  96. writable: !(bitmap & 4),
  97. value: value
  98. };
  99. };
  100.  
  101. var toString$4 = {}.toString;
  102.  
  103. var classofRaw$1 = function (it) {
  104. return toString$4.call(it).slice(8, -1);
  105. };
  106.  
  107. var fails$8 = fails$a;
  108. var classof$3 = classofRaw$1;
  109.  
  110. var split = ''.split;
  111.  
  112. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  113. var indexedObject = fails$8(function () {
  114. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  115. // eslint-disable-next-line no-prototype-builtins -- safe
  116. return !Object('z').propertyIsEnumerable(0);
  117. }) ? function (it) {
  118. return classof$3(it) == 'String' ? split.call(it, '') : Object(it);
  119. } : Object;
  120.  
  121. // `RequireObjectCoercible` abstract operation
  122. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  123. var requireObjectCoercible$4 = function (it) {
  124. if (it == undefined) throw TypeError("Can't call method on " + it);
  125. return it;
  126. };
  127.  
  128. // toObject with fallback for non-array-like ES3 strings
  129. var IndexedObject = indexedObject;
  130. var requireObjectCoercible$3 = requireObjectCoercible$4;
  131.  
  132. var toIndexedObject$3 = function (it) {
  133. return IndexedObject(requireObjectCoercible$3(it));
  134. };
  135.  
  136. // `IsCallable` abstract operation
  137. // https://tc39.es/ecma262/#sec-iscallable
  138. var isCallable$c = function (argument) {
  139. return typeof argument === 'function';
  140. };
  141.  
  142. var isCallable$b = isCallable$c;
  143.  
  144. var isObject$5 = function (it) {
  145. return typeof it === 'object' ? it !== null : isCallable$b(it);
  146. };
  147.  
  148. var global$d = global$e;
  149. var isCallable$a = isCallable$c;
  150.  
  151. var aFunction = function (argument) {
  152. return isCallable$a(argument) ? argument : undefined;
  153. };
  154.  
  155. var getBuiltIn$4 = function (namespace, method) {
  156. return arguments.length < 2 ? aFunction(global$d[namespace]) : global$d[namespace] && global$d[namespace][method];
  157. };
  158.  
  159. var getBuiltIn$3 = getBuiltIn$4;
  160.  
  161. var engineUserAgent = getBuiltIn$3('navigator', 'userAgent') || '';
  162.  
  163. var global$c = global$e;
  164. var userAgent = engineUserAgent;
  165.  
  166. var process = global$c.process;
  167. var Deno = global$c.Deno;
  168. var versions = process && process.versions || Deno && Deno.version;
  169. var v8 = versions && versions.v8;
  170. var match, version;
  171.  
  172. if (v8) {
  173. match = v8.split('.');
  174. version = match[0] < 4 ? 1 : match[0] + match[1];
  175. } else if (userAgent) {
  176. match = userAgent.match(/Edge\/(\d+)/);
  177. if (!match || match[1] >= 74) {
  178. match = userAgent.match(/Chrome\/(\d+)/);
  179. if (match) version = match[1];
  180. }
  181. }
  182.  
  183. var engineV8Version = version && +version;
  184.  
  185. /* eslint-disable es/no-symbol -- required for testing */
  186.  
  187. var V8_VERSION = engineV8Version;
  188. var fails$7 = fails$a;
  189.  
  190. // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
  191. var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$7(function () {
  192. var symbol = Symbol();
  193. // Chrome 38 Symbol has incorrect toString conversion
  194. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  195. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  196. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  197. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  198. });
  199.  
  200. /* eslint-disable es/no-symbol -- required for testing */
  201.  
  202. var NATIVE_SYMBOL$1 = nativeSymbol;
  203.  
  204. var useSymbolAsUid = NATIVE_SYMBOL$1
  205. && !Symbol.sham
  206. && typeof Symbol.iterator == 'symbol';
  207.  
  208. var isCallable$9 = isCallable$c;
  209. var getBuiltIn$2 = getBuiltIn$4;
  210. var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
  211.  
  212. var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
  213. return typeof it == 'symbol';
  214. } : function (it) {
  215. var $Symbol = getBuiltIn$2('Symbol');
  216. return isCallable$9($Symbol) && Object(it) instanceof $Symbol;
  217. };
  218.  
  219. var tryToString$1 = function (argument) {
  220. try {
  221. return String(argument);
  222. } catch (error) {
  223. return 'Object';
  224. }
  225. };
  226.  
  227. var isCallable$8 = isCallable$c;
  228. var tryToString = tryToString$1;
  229.  
  230. // `Assert: IsCallable(argument) is true`
  231. var aCallable$1 = function (argument) {
  232. if (isCallable$8(argument)) return argument;
  233. throw TypeError(tryToString(argument) + ' is not a function');
  234. };
  235.  
  236. var aCallable = aCallable$1;
  237.  
  238. // `GetMethod` abstract operation
  239. // https://tc39.es/ecma262/#sec-getmethod
  240. var getMethod$2 = function (V, P) {
  241. var func = V[P];
  242. return func == null ? undefined : aCallable(func);
  243. };
  244.  
  245. var isCallable$7 = isCallable$c;
  246. var isObject$4 = isObject$5;
  247.  
  248. // `OrdinaryToPrimitive` abstract operation
  249. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  250. var ordinaryToPrimitive$1 = function (input, pref) {
  251. var fn, val;
  252. if (pref === 'string' && isCallable$7(fn = input.toString) && !isObject$4(val = fn.call(input))) return val;
  253. if (isCallable$7(fn = input.valueOf) && !isObject$4(val = fn.call(input))) return val;
  254. if (pref !== 'string' && isCallable$7(fn = input.toString) && !isObject$4(val = fn.call(input))) return val;
  255. throw TypeError("Can't convert object to primitive value");
  256. };
  257.  
  258. var shared$4 = {exports: {}};
  259.  
  260. var global$b = global$e;
  261.  
  262. var setGlobal$3 = function (key, value) {
  263. try {
  264. // eslint-disable-next-line es/no-object-defineproperty -- safe
  265. Object.defineProperty(global$b, key, { value: value, configurable: true, writable: true });
  266. } catch (error) {
  267. global$b[key] = value;
  268. } return value;
  269. };
  270.  
  271. var global$a = global$e;
  272. var setGlobal$2 = setGlobal$3;
  273.  
  274. var SHARED = '__core-js_shared__';
  275. var store$3 = global$a[SHARED] || setGlobal$2(SHARED, {});
  276.  
  277. var sharedStore = store$3;
  278.  
  279. var store$2 = sharedStore;
  280.  
  281. (shared$4.exports = function (key, value) {
  282. return store$2[key] || (store$2[key] = value !== undefined ? value : {});
  283. })('versions', []).push({
  284. version: '3.18.3',
  285. mode: 'global',
  286. copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
  287. });
  288.  
  289. var requireObjectCoercible$2 = requireObjectCoercible$4;
  290.  
  291. // `ToObject` abstract operation
  292. // https://tc39.es/ecma262/#sec-toobject
  293. var toObject$2 = function (argument) {
  294. return Object(requireObjectCoercible$2(argument));
  295. };
  296.  
  297. var toObject$1 = toObject$2;
  298.  
  299. var hasOwnProperty = {}.hasOwnProperty;
  300.  
  301. // `HasOwnProperty` abstract operation
  302. // https://tc39.es/ecma262/#sec-hasownproperty
  303. var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
  304. return hasOwnProperty.call(toObject$1(it), key);
  305. };
  306.  
  307. var id = 0;
  308. var postfix = Math.random();
  309.  
  310. var uid$2 = function (key) {
  311. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  312. };
  313.  
  314. var global$9 = global$e;
  315. var shared$3 = shared$4.exports;
  316. var hasOwn$6 = hasOwnProperty_1;
  317. var uid$1 = uid$2;
  318. var NATIVE_SYMBOL = nativeSymbol;
  319. var USE_SYMBOL_AS_UID = useSymbolAsUid;
  320.  
  321. var WellKnownSymbolsStore = shared$3('wks');
  322. var Symbol$1 = global$9.Symbol;
  323. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
  324.  
  325. var wellKnownSymbol$5 = function (name) {
  326. if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
  327. if (NATIVE_SYMBOL && hasOwn$6(Symbol$1, name)) {
  328. WellKnownSymbolsStore[name] = Symbol$1[name];
  329. } else {
  330. WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  331. }
  332. } return WellKnownSymbolsStore[name];
  333. };
  334.  
  335. var isObject$3 = isObject$5;
  336. var isSymbol$1 = isSymbol$2;
  337. var getMethod$1 = getMethod$2;
  338. var ordinaryToPrimitive = ordinaryToPrimitive$1;
  339. var wellKnownSymbol$4 = wellKnownSymbol$5;
  340.  
  341. var TO_PRIMITIVE = wellKnownSymbol$4('toPrimitive');
  342.  
  343. // `ToPrimitive` abstract operation
  344. // https://tc39.es/ecma262/#sec-toprimitive
  345. var toPrimitive$1 = function (input, pref) {
  346. if (!isObject$3(input) || isSymbol$1(input)) return input;
  347. var exoticToPrim = getMethod$1(input, TO_PRIMITIVE);
  348. var result;
  349. if (exoticToPrim) {
  350. if (pref === undefined) pref = 'default';
  351. result = exoticToPrim.call(input, pref);
  352. if (!isObject$3(result) || isSymbol$1(result)) return result;
  353. throw TypeError("Can't convert object to primitive value");
  354. }
  355. if (pref === undefined) pref = 'number';
  356. return ordinaryToPrimitive(input, pref);
  357. };
  358.  
  359. var toPrimitive = toPrimitive$1;
  360. var isSymbol = isSymbol$2;
  361.  
  362. // `ToPropertyKey` abstract operation
  363. // https://tc39.es/ecma262/#sec-topropertykey
  364. var toPropertyKey$2 = function (argument) {
  365. var key = toPrimitive(argument, 'string');
  366. return isSymbol(key) ? key : String(key);
  367. };
  368.  
  369. var global$8 = global$e;
  370. var isObject$2 = isObject$5;
  371.  
  372. var document$1 = global$8.document;
  373. // typeof document.createElement is 'object' in old IE
  374. var EXISTS$1 = isObject$2(document$1) && isObject$2(document$1.createElement);
  375.  
  376. var documentCreateElement$1 = function (it) {
  377. return EXISTS$1 ? document$1.createElement(it) : {};
  378. };
  379.  
  380. var DESCRIPTORS$5 = descriptors;
  381. var fails$6 = fails$a;
  382. var createElement = documentCreateElement$1;
  383.  
  384. // Thank's IE8 for his funny defineProperty
  385. var ie8DomDefine = !DESCRIPTORS$5 && !fails$6(function () {
  386. // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
  387. return Object.defineProperty(createElement('div'), 'a', {
  388. get: function () { return 7; }
  389. }).a != 7;
  390. });
  391.  
  392. var DESCRIPTORS$4 = descriptors;
  393. var propertyIsEnumerableModule = objectPropertyIsEnumerable;
  394. var createPropertyDescriptor$1 = createPropertyDescriptor$2;
  395. var toIndexedObject$2 = toIndexedObject$3;
  396. var toPropertyKey$1 = toPropertyKey$2;
  397. var hasOwn$5 = hasOwnProperty_1;
  398. var IE8_DOM_DEFINE$1 = ie8DomDefine;
  399.  
  400. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  401. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  402.  
  403. // `Object.getOwnPropertyDescriptor` method
  404. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  405. objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  406. O = toIndexedObject$2(O);
  407. P = toPropertyKey$1(P);
  408. if (IE8_DOM_DEFINE$1) try {
  409. return $getOwnPropertyDescriptor(O, P);
  410. } catch (error) { /* empty */ }
  411. if (hasOwn$5(O, P)) return createPropertyDescriptor$1(!propertyIsEnumerableModule.f.call(O, P), O[P]);
  412. };
  413.  
  414. var objectDefineProperty = {};
  415.  
  416. var isObject$1 = isObject$5;
  417.  
  418. // `Assert: Type(argument) is Object`
  419. var anObject$7 = function (argument) {
  420. if (isObject$1(argument)) return argument;
  421. throw TypeError(String(argument) + ' is not an object');
  422. };
  423.  
  424. var DESCRIPTORS$3 = descriptors;
  425. var IE8_DOM_DEFINE = ie8DomDefine;
  426. var anObject$6 = anObject$7;
  427. var toPropertyKey = toPropertyKey$2;
  428.  
  429. // eslint-disable-next-line es/no-object-defineproperty -- safe
  430. var $defineProperty = Object.defineProperty;
  431.  
  432. // `Object.defineProperty` method
  433. // https://tc39.es/ecma262/#sec-object.defineproperty
  434. objectDefineProperty.f = DESCRIPTORS$3 ? $defineProperty : function defineProperty(O, P, Attributes) {
  435. anObject$6(O);
  436. P = toPropertyKey(P);
  437. anObject$6(Attributes);
  438. if (IE8_DOM_DEFINE) try {
  439. return $defineProperty(O, P, Attributes);
  440. } catch (error) { /* empty */ }
  441. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  442. if ('value' in Attributes) O[P] = Attributes.value;
  443. return O;
  444. };
  445.  
  446. var DESCRIPTORS$2 = descriptors;
  447. var definePropertyModule$2 = objectDefineProperty;
  448. var createPropertyDescriptor = createPropertyDescriptor$2;
  449.  
  450. var createNonEnumerableProperty$4 = DESCRIPTORS$2 ? function (object, key, value) {
  451. return definePropertyModule$2.f(object, key, createPropertyDescriptor(1, value));
  452. } : function (object, key, value) {
  453. object[key] = value;
  454. return object;
  455. };
  456.  
  457. var redefine$2 = {exports: {}};
  458.  
  459. var isCallable$6 = isCallable$c;
  460. var store$1 = sharedStore;
  461.  
  462. var functionToString = Function.toString;
  463.  
  464. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  465. if (!isCallable$6(store$1.inspectSource)) {
  466. store$1.inspectSource = function (it) {
  467. return functionToString.call(it);
  468. };
  469. }
  470.  
  471. var inspectSource$2 = store$1.inspectSource;
  472.  
  473. var global$7 = global$e;
  474. var isCallable$5 = isCallable$c;
  475. var inspectSource$1 = inspectSource$2;
  476.  
  477. var WeakMap$1 = global$7.WeakMap;
  478.  
  479. var nativeWeakMap = isCallable$5(WeakMap$1) && /native code/.test(inspectSource$1(WeakMap$1));
  480.  
  481. var shared$2 = shared$4.exports;
  482. var uid = uid$2;
  483.  
  484. var keys = shared$2('keys');
  485.  
  486. var sharedKey$2 = function (key) {
  487. return keys[key] || (keys[key] = uid(key));
  488. };
  489.  
  490. var hiddenKeys$4 = {};
  491.  
  492. var NATIVE_WEAK_MAP = nativeWeakMap;
  493. var global$6 = global$e;
  494. var isObject = isObject$5;
  495. var createNonEnumerableProperty$3 = createNonEnumerableProperty$4;
  496. var hasOwn$4 = hasOwnProperty_1;
  497. var shared$1 = sharedStore;
  498. var sharedKey$1 = sharedKey$2;
  499. var hiddenKeys$3 = hiddenKeys$4;
  500.  
  501. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  502. var WeakMap = global$6.WeakMap;
  503. var set, get, has;
  504.  
  505. var enforce = function (it) {
  506. return has(it) ? get(it) : set(it, {});
  507. };
  508.  
  509. var getterFor = function (TYPE) {
  510. return function (it) {
  511. var state;
  512. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  513. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  514. } return state;
  515. };
  516. };
  517.  
  518. if (NATIVE_WEAK_MAP || shared$1.state) {
  519. var store = shared$1.state || (shared$1.state = new WeakMap());
  520. var wmget = store.get;
  521. var wmhas = store.has;
  522. var wmset = store.set;
  523. set = function (it, metadata) {
  524. if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  525. metadata.facade = it;
  526. wmset.call(store, it, metadata);
  527. return metadata;
  528. };
  529. get = function (it) {
  530. return wmget.call(store, it) || {};
  531. };
  532. has = function (it) {
  533. return wmhas.call(store, it);
  534. };
  535. } else {
  536. var STATE = sharedKey$1('state');
  537. hiddenKeys$3[STATE] = true;
  538. set = function (it, metadata) {
  539. if (hasOwn$4(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  540. metadata.facade = it;
  541. createNonEnumerableProperty$3(it, STATE, metadata);
  542. return metadata;
  543. };
  544. get = function (it) {
  545. return hasOwn$4(it, STATE) ? it[STATE] : {};
  546. };
  547. has = function (it) {
  548. return hasOwn$4(it, STATE);
  549. };
  550. }
  551.  
  552. var internalState = {
  553. set: set,
  554. get: get,
  555. has: has,
  556. enforce: enforce,
  557. getterFor: getterFor
  558. };
  559.  
  560. var DESCRIPTORS$1 = descriptors;
  561. var hasOwn$3 = hasOwnProperty_1;
  562.  
  563. var FunctionPrototype = Function.prototype;
  564. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  565. var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
  566.  
  567. var EXISTS = hasOwn$3(FunctionPrototype, 'name');
  568. // additional protection from minified / mangled / dropped function names
  569. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  570. var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || (DESCRIPTORS$1 && getDescriptor(FunctionPrototype, 'name').configurable));
  571.  
  572. var functionName = {
  573. EXISTS: EXISTS,
  574. PROPER: PROPER,
  575. CONFIGURABLE: CONFIGURABLE
  576. };
  577.  
  578. var global$5 = global$e;
  579. var isCallable$4 = isCallable$c;
  580. var hasOwn$2 = hasOwnProperty_1;
  581. var createNonEnumerableProperty$2 = createNonEnumerableProperty$4;
  582. var setGlobal$1 = setGlobal$3;
  583. var inspectSource = inspectSource$2;
  584. var InternalStateModule = internalState;
  585. var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
  586.  
  587. var getInternalState$1 = InternalStateModule.get;
  588. var enforceInternalState = InternalStateModule.enforce;
  589. var TEMPLATE = String(String).split('String');
  590.  
  591. (redefine$2.exports = function (O, key, value, options) {
  592. var unsafe = options ? !!options.unsafe : false;
  593. var simple = options ? !!options.enumerable : false;
  594. var noTargetGet = options ? !!options.noTargetGet : false;
  595. var name = options && options.name !== undefined ? options.name : key;
  596. var state;
  597. if (isCallable$4(value)) {
  598. if (String(name).slice(0, 7) === 'Symbol(') {
  599. name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
  600. }
  601. if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
  602. createNonEnumerableProperty$2(value, 'name', name);
  603. }
  604. state = enforceInternalState(value);
  605. if (!state.source) {
  606. state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
  607. }
  608. }
  609. if (O === global$5) {
  610. if (simple) O[key] = value;
  611. else setGlobal$1(key, value);
  612. return;
  613. } else if (!unsafe) {
  614. delete O[key];
  615. } else if (!noTargetGet && O[key]) {
  616. simple = true;
  617. }
  618. if (simple) O[key] = value;
  619. else createNonEnumerableProperty$2(O, key, value);
  620. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  621. })(Function.prototype, 'toString', function toString() {
  622. return isCallable$4(this) && getInternalState$1(this).source || inspectSource(this);
  623. });
  624.  
  625. var objectGetOwnPropertyNames = {};
  626.  
  627. var ceil = Math.ceil;
  628. var floor$1 = Math.floor;
  629.  
  630. // `ToIntegerOrInfinity` abstract operation
  631. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  632. var toIntegerOrInfinity$4 = function (argument) {
  633. var number = +argument;
  634. // eslint-disable-next-line no-self-compare -- safe
  635. return number !== number || number === 0 ? 0 : (number > 0 ? floor$1 : ceil)(number);
  636. };
  637.  
  638. var toIntegerOrInfinity$3 = toIntegerOrInfinity$4;
  639.  
  640. var max$1 = Math.max;
  641. var min$2 = Math.min;
  642.  
  643. // Helper for a popular repeating case of the spec:
  644. // Let integer be ? ToInteger(index).
  645. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  646. var toAbsoluteIndex$1 = function (index, length) {
  647. var integer = toIntegerOrInfinity$3(index);
  648. return integer < 0 ? max$1(integer + length, 0) : min$2(integer, length);
  649. };
  650.  
  651. var toIntegerOrInfinity$2 = toIntegerOrInfinity$4;
  652.  
  653. var min$1 = Math.min;
  654.  
  655. // `ToLength` abstract operation
  656. // https://tc39.es/ecma262/#sec-tolength
  657. var toLength$2 = function (argument) {
  658. return argument > 0 ? min$1(toIntegerOrInfinity$2(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  659. };
  660.  
  661. var toLength$1 = toLength$2;
  662.  
  663. // `LengthOfArrayLike` abstract operation
  664. // https://tc39.es/ecma262/#sec-lengthofarraylike
  665. var lengthOfArrayLike$1 = function (obj) {
  666. return toLength$1(obj.length);
  667. };
  668.  
  669. var toIndexedObject$1 = toIndexedObject$3;
  670. var toAbsoluteIndex = toAbsoluteIndex$1;
  671. var lengthOfArrayLike = lengthOfArrayLike$1;
  672.  
  673. // `Array.prototype.{ indexOf, includes }` methods implementation
  674. var createMethod$1 = function (IS_INCLUDES) {
  675. return function ($this, el, fromIndex) {
  676. var O = toIndexedObject$1($this);
  677. var length = lengthOfArrayLike(O);
  678. var index = toAbsoluteIndex(fromIndex, length);
  679. var value;
  680. // Array#includes uses SameValueZero equality algorithm
  681. // eslint-disable-next-line no-self-compare -- NaN check
  682. if (IS_INCLUDES && el != el) while (length > index) {
  683. value = O[index++];
  684. // eslint-disable-next-line no-self-compare -- NaN check
  685. if (value != value) return true;
  686. // Array#indexOf ignores holes, Array#includes - not
  687. } else for (;length > index; index++) {
  688. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  689. } return !IS_INCLUDES && -1;
  690. };
  691. };
  692.  
  693. var arrayIncludes = {
  694. // `Array.prototype.includes` method
  695. // https://tc39.es/ecma262/#sec-array.prototype.includes
  696. includes: createMethod$1(true),
  697. // `Array.prototype.indexOf` method
  698. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  699. indexOf: createMethod$1(false)
  700. };
  701.  
  702. var hasOwn$1 = hasOwnProperty_1;
  703. var toIndexedObject = toIndexedObject$3;
  704. var indexOf = arrayIncludes.indexOf;
  705. var hiddenKeys$2 = hiddenKeys$4;
  706.  
  707. var objectKeysInternal = function (object, names) {
  708. var O = toIndexedObject(object);
  709. var i = 0;
  710. var result = [];
  711. var key;
  712. for (key in O) !hasOwn$1(hiddenKeys$2, key) && hasOwn$1(O, key) && result.push(key);
  713. // Don't enum bug & hidden keys
  714. while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
  715. ~indexOf(result, key) || result.push(key);
  716. }
  717. return result;
  718. };
  719.  
  720. // IE8- don't enum bug keys
  721. var enumBugKeys$3 = [
  722. 'constructor',
  723. 'hasOwnProperty',
  724. 'isPrototypeOf',
  725. 'propertyIsEnumerable',
  726. 'toLocaleString',
  727. 'toString',
  728. 'valueOf'
  729. ];
  730.  
  731. var internalObjectKeys$1 = objectKeysInternal;
  732. var enumBugKeys$2 = enumBugKeys$3;
  733.  
  734. var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
  735.  
  736. // `Object.getOwnPropertyNames` method
  737. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  738. // eslint-disable-next-line es/no-object-getownpropertynames -- safe
  739. objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  740. return internalObjectKeys$1(O, hiddenKeys$1);
  741. };
  742.  
  743. var objectGetOwnPropertySymbols = {};
  744.  
  745. // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
  746. objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
  747.  
  748. var getBuiltIn$1 = getBuiltIn$4;
  749. var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
  750. var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
  751. var anObject$5 = anObject$7;
  752.  
  753. // all object keys, includes non-enumerable and symbols
  754. var ownKeys$1 = getBuiltIn$1('Reflect', 'ownKeys') || function ownKeys(it) {
  755. var keys = getOwnPropertyNamesModule.f(anObject$5(it));
  756. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  757. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  758. };
  759.  
  760. var hasOwn = hasOwnProperty_1;
  761. var ownKeys = ownKeys$1;
  762. var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
  763. var definePropertyModule$1 = objectDefineProperty;
  764.  
  765. var copyConstructorProperties$1 = function (target, source) {
  766. var keys = ownKeys(source);
  767. var defineProperty = definePropertyModule$1.f;
  768. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  769. for (var i = 0; i < keys.length; i++) {
  770. var key = keys[i];
  771. if (!hasOwn(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  772. }
  773. };
  774.  
  775. var fails$5 = fails$a;
  776. var isCallable$3 = isCallable$c;
  777.  
  778. var replacement = /#|\.prototype\./;
  779.  
  780. var isForced$1 = function (feature, detection) {
  781. var value = data[normalize(feature)];
  782. return value == POLYFILL ? true
  783. : value == NATIVE ? false
  784. : isCallable$3(detection) ? fails$5(detection)
  785. : !!detection;
  786. };
  787.  
  788. var normalize = isForced$1.normalize = function (string) {
  789. return String(string).replace(replacement, '.').toLowerCase();
  790. };
  791.  
  792. var data = isForced$1.data = {};
  793. var NATIVE = isForced$1.NATIVE = 'N';
  794. var POLYFILL = isForced$1.POLYFILL = 'P';
  795.  
  796. var isForced_1 = isForced$1;
  797.  
  798. var global$4 = global$e;
  799. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  800. var createNonEnumerableProperty$1 = createNonEnumerableProperty$4;
  801. var redefine$1 = redefine$2.exports;
  802. var setGlobal = setGlobal$3;
  803. var copyConstructorProperties = copyConstructorProperties$1;
  804. var isForced = isForced_1;
  805.  
  806. /*
  807. options.target - name of the target object
  808. options.global - target is the global object
  809. options.stat - export as static methods of target
  810. options.proto - export as prototype methods of target
  811. options.real - real prototype method for the `pure` version
  812. options.forced - export even if the native feature is available
  813. options.bind - bind methods to the target, required for the `pure` version
  814. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  815. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  816. options.sham - add a flag to not completely full polyfills
  817. options.enumerable - export as enumerable property
  818. options.noTargetGet - prevent calling a getter on target
  819. options.name - the .name of the function if it does not match the key
  820. */
  821. var _export = function (options, source) {
  822. var TARGET = options.target;
  823. var GLOBAL = options.global;
  824. var STATIC = options.stat;
  825. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  826. if (GLOBAL) {
  827. target = global$4;
  828. } else if (STATIC) {
  829. target = global$4[TARGET] || setGlobal(TARGET, {});
  830. } else {
  831. target = (global$4[TARGET] || {}).prototype;
  832. }
  833. if (target) for (key in source) {
  834. sourceProperty = source[key];
  835. if (options.noTargetGet) {
  836. descriptor = getOwnPropertyDescriptor(target, key);
  837. targetProperty = descriptor && descriptor.value;
  838. } else targetProperty = target[key];
  839. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  840. // contained in target
  841. if (!FORCED && targetProperty !== undefined) {
  842. if (typeof sourceProperty === typeof targetProperty) continue;
  843. copyConstructorProperties(sourceProperty, targetProperty);
  844. }
  845. // add a flag to not completely full polyfills
  846. if (options.sham || (targetProperty && targetProperty.sham)) {
  847. createNonEnumerableProperty$1(sourceProperty, 'sham', true);
  848. }
  849. // extend global
  850. redefine$1(target, key, sourceProperty, options);
  851. }
  852. };
  853.  
  854. var wellKnownSymbol$3 = wellKnownSymbol$5;
  855.  
  856. var TO_STRING_TAG$1 = wellKnownSymbol$3('toStringTag');
  857. var test = {};
  858.  
  859. test[TO_STRING_TAG$1] = 'z';
  860.  
  861. var toStringTagSupport = String(test) === '[object z]';
  862.  
  863. var TO_STRING_TAG_SUPPORT = toStringTagSupport;
  864. var isCallable$2 = isCallable$c;
  865. var classofRaw = classofRaw$1;
  866. var wellKnownSymbol$2 = wellKnownSymbol$5;
  867.  
  868. var TO_STRING_TAG = wellKnownSymbol$2('toStringTag');
  869. // ES3 wrong here
  870. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  871.  
  872. // fallback for IE11 Script Access Denied error
  873. var tryGet = function (it, key) {
  874. try {
  875. return it[key];
  876. } catch (error) { /* empty */ }
  877. };
  878.  
  879. // getting tag from ES6+ `Object.prototype.toString`
  880. var classof$2 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  881. var O, tag, result;
  882. return it === undefined ? 'Undefined' : it === null ? 'Null'
  883. // @@toStringTag case
  884. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
  885. // builtinTag case
  886. : CORRECT_ARGUMENTS ? classofRaw(O)
  887. // ES3 arguments fallback
  888. : (result = classofRaw(O)) == 'Object' && isCallable$2(O.callee) ? 'Arguments' : result;
  889. };
  890.  
  891. var classof$1 = classof$2;
  892.  
  893. var toString$3 = function (argument) {
  894. if (classof$1(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  895. return String(argument);
  896. };
  897.  
  898. var anObject$4 = anObject$7;
  899.  
  900. // `RegExp.prototype.flags` getter implementation
  901. // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
  902. var regexpFlags$1 = function () {
  903. var that = anObject$4(this);
  904. var result = '';
  905. if (that.global) result += 'g';
  906. if (that.ignoreCase) result += 'i';
  907. if (that.multiline) result += 'm';
  908. if (that.dotAll) result += 's';
  909. if (that.unicode) result += 'u';
  910. if (that.sticky) result += 'y';
  911. return result;
  912. };
  913.  
  914. var regexpStickyHelpers = {};
  915.  
  916. var fails$4 = fails$a;
  917. var global$3 = global$e;
  918.  
  919. // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
  920. var $RegExp$2 = global$3.RegExp;
  921.  
  922. regexpStickyHelpers.UNSUPPORTED_Y = fails$4(function () {
  923. var re = $RegExp$2('a', 'y');
  924. re.lastIndex = 2;
  925. return re.exec('abcd') != null;
  926. });
  927.  
  928. regexpStickyHelpers.BROKEN_CARET = fails$4(function () {
  929. // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
  930. var re = $RegExp$2('^r', 'gy');
  931. re.lastIndex = 2;
  932. return re.exec('str') != null;
  933. });
  934.  
  935. var internalObjectKeys = objectKeysInternal;
  936. var enumBugKeys$1 = enumBugKeys$3;
  937.  
  938. // `Object.keys` method
  939. // https://tc39.es/ecma262/#sec-object.keys
  940. // eslint-disable-next-line es/no-object-keys -- safe
  941. var objectKeys$1 = Object.keys || function keys(O) {
  942. return internalObjectKeys(O, enumBugKeys$1);
  943. };
  944.  
  945. var DESCRIPTORS = descriptors;
  946. var definePropertyModule = objectDefineProperty;
  947. var anObject$3 = anObject$7;
  948. var objectKeys = objectKeys$1;
  949.  
  950. // `Object.defineProperties` method
  951. // https://tc39.es/ecma262/#sec-object.defineproperties
  952. // eslint-disable-next-line es/no-object-defineproperties -- safe
  953. var objectDefineProperties = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  954. anObject$3(O);
  955. var keys = objectKeys(Properties);
  956. var length = keys.length;
  957. var index = 0;
  958. var key;
  959. while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);
  960. return O;
  961. };
  962.  
  963. var getBuiltIn = getBuiltIn$4;
  964.  
  965. var html$1 = getBuiltIn('document', 'documentElement');
  966.  
  967. /* global ActiveXObject -- old IE, WSH */
  968.  
  969. var anObject$2 = anObject$7;
  970. var defineProperties = objectDefineProperties;
  971. var enumBugKeys = enumBugKeys$3;
  972. var hiddenKeys = hiddenKeys$4;
  973. var html = html$1;
  974. var documentCreateElement = documentCreateElement$1;
  975. var sharedKey = sharedKey$2;
  976.  
  977. var GT = '>';
  978. var LT = '<';
  979. var PROTOTYPE = 'prototype';
  980. var SCRIPT = 'script';
  981. var IE_PROTO = sharedKey('IE_PROTO');
  982.  
  983. var EmptyConstructor = function () { /* empty */ };
  984.  
  985. var scriptTag = function (content) {
  986. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  987. };
  988.  
  989. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  990. var NullProtoObjectViaActiveX = function (activeXDocument) {
  991. activeXDocument.write(scriptTag(''));
  992. activeXDocument.close();
  993. var temp = activeXDocument.parentWindow.Object;
  994. activeXDocument = null; // avoid memory leak
  995. return temp;
  996. };
  997.  
  998. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  999. var NullProtoObjectViaIFrame = function () {
  1000. // Thrash, waste and sodomy: IE GC bug
  1001. var iframe = documentCreateElement('iframe');
  1002. var JS = 'java' + SCRIPT + ':';
  1003. var iframeDocument;
  1004. iframe.style.display = 'none';
  1005. html.appendChild(iframe);
  1006. // https://github.com/zloirock/core-js/issues/475
  1007. iframe.src = String(JS);
  1008. iframeDocument = iframe.contentWindow.document;
  1009. iframeDocument.open();
  1010. iframeDocument.write(scriptTag('document.F=Object'));
  1011. iframeDocument.close();
  1012. return iframeDocument.F;
  1013. };
  1014.  
  1015. // Check for document.domain and active x support
  1016. // No need to use active x approach when document.domain is not set
  1017. // see https://github.com/es-shims/es5-shim/issues/150
  1018. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  1019. // avoid IE GC bug
  1020. var activeXDocument;
  1021. var NullProtoObject = function () {
  1022. try {
  1023. activeXDocument = new ActiveXObject('htmlfile');
  1024. } catch (error) { /* ignore */ }
  1025. NullProtoObject = typeof document != 'undefined'
  1026. ? document.domain && activeXDocument
  1027. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  1028. : NullProtoObjectViaIFrame()
  1029. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  1030. var length = enumBugKeys.length;
  1031. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  1032. return NullProtoObject();
  1033. };
  1034.  
  1035. hiddenKeys[IE_PROTO] = true;
  1036.  
  1037. // `Object.create` method
  1038. // https://tc39.es/ecma262/#sec-object.create
  1039. var objectCreate = Object.create || function create(O, Properties) {
  1040. var result;
  1041. if (O !== null) {
  1042. EmptyConstructor[PROTOTYPE] = anObject$2(O);
  1043. result = new EmptyConstructor();
  1044. EmptyConstructor[PROTOTYPE] = null;
  1045. // add "__proto__" for Object.getPrototypeOf polyfill
  1046. result[IE_PROTO] = O;
  1047. } else result = NullProtoObject();
  1048. return Properties === undefined ? result : defineProperties(result, Properties);
  1049. };
  1050.  
  1051. var fails$3 = fails$a;
  1052. var global$2 = global$e;
  1053.  
  1054. // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
  1055. var $RegExp$1 = global$2.RegExp;
  1056.  
  1057. var regexpUnsupportedDotAll = fails$3(function () {
  1058. var re = $RegExp$1('.', 's');
  1059. return !(re.dotAll && re.exec('\n') && re.flags === 's');
  1060. });
  1061.  
  1062. var fails$2 = fails$a;
  1063. var global$1 = global$e;
  1064.  
  1065. // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
  1066. var $RegExp = global$1.RegExp;
  1067.  
  1068. var regexpUnsupportedNcg = fails$2(function () {
  1069. var re = $RegExp('(?<a>b)', 'g');
  1070. return re.exec('b').groups.a !== 'b' ||
  1071. 'b'.replace(re, '$<a>c') !== 'bc';
  1072. });
  1073.  
  1074. /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
  1075. /* eslint-disable regexp/no-useless-quantifier -- testing */
  1076. var toString$2 = toString$3;
  1077. var regexpFlags = regexpFlags$1;
  1078. var stickyHelpers = regexpStickyHelpers;
  1079. var shared = shared$4.exports;
  1080. var create = objectCreate;
  1081. var getInternalState = internalState.get;
  1082. var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll;
  1083. var UNSUPPORTED_NCG = regexpUnsupportedNcg;
  1084.  
  1085. var nativeExec = RegExp.prototype.exec;
  1086. var nativeReplace = shared('native-string-replace', String.prototype.replace);
  1087.  
  1088. var patchedExec = nativeExec;
  1089.  
  1090. var UPDATES_LAST_INDEX_WRONG = (function () {
  1091. var re1 = /a/;
  1092. var re2 = /b*/g;
  1093. nativeExec.call(re1, 'a');
  1094. nativeExec.call(re2, 'a');
  1095. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  1096. })();
  1097.  
  1098. var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;
  1099.  
  1100. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  1101. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  1102.  
  1103. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
  1104.  
  1105. if (PATCH) {
  1106. // eslint-disable-next-line max-statements -- TODO
  1107. patchedExec = function exec(string) {
  1108. var re = this;
  1109. var state = getInternalState(re);
  1110. var str = toString$2(string);
  1111. var raw = state.raw;
  1112. var result, reCopy, lastIndex, match, i, object, group;
  1113.  
  1114. if (raw) {
  1115. raw.lastIndex = re.lastIndex;
  1116. result = patchedExec.call(raw, str);
  1117. re.lastIndex = raw.lastIndex;
  1118. return result;
  1119. }
  1120.  
  1121. var groups = state.groups;
  1122. var sticky = UNSUPPORTED_Y && re.sticky;
  1123. var flags = regexpFlags.call(re);
  1124. var source = re.source;
  1125. var charsAdded = 0;
  1126. var strCopy = str;
  1127.  
  1128. if (sticky) {
  1129. flags = flags.replace('y', '');
  1130. if (flags.indexOf('g') === -1) {
  1131. flags += 'g';
  1132. }
  1133.  
  1134. strCopy = str.slice(re.lastIndex);
  1135. // Support anchored sticky behavior.
  1136. if (re.lastIndex > 0 && (!re.multiline || re.multiline && str.charAt(re.lastIndex - 1) !== '\n')) {
  1137. source = '(?: ' + source + ')';
  1138. strCopy = ' ' + strCopy;
  1139. charsAdded++;
  1140. }
  1141. // ^(? + rx + ) is needed, in combination with some str slicing, to
  1142. // simulate the 'y' flag.
  1143. reCopy = new RegExp('^(?:' + source + ')', flags);
  1144. }
  1145.  
  1146. if (NPCG_INCLUDED) {
  1147. reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
  1148. }
  1149. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  1150.  
  1151. match = nativeExec.call(sticky ? reCopy : re, strCopy);
  1152.  
  1153. if (sticky) {
  1154. if (match) {
  1155. match.input = match.input.slice(charsAdded);
  1156. match[0] = match[0].slice(charsAdded);
  1157. match.index = re.lastIndex;
  1158. re.lastIndex += match[0].length;
  1159. } else re.lastIndex = 0;
  1160. } else if (UPDATES_LAST_INDEX_WRONG && match) {
  1161. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  1162. }
  1163. if (NPCG_INCLUDED && match && match.length > 1) {
  1164. // Fix browsers whose `exec` methods don't consistently return `undefined`
  1165. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  1166. nativeReplace.call(match[0], reCopy, function () {
  1167. for (i = 1; i < arguments.length - 2; i++) {
  1168. if (arguments[i] === undefined) match[i] = undefined;
  1169. }
  1170. });
  1171. }
  1172.  
  1173. if (match && groups) {
  1174. match.groups = object = create(null);
  1175. for (i = 0; i < groups.length; i++) {
  1176. group = groups[i];
  1177. object[group[0]] = match[group[1]];
  1178. }
  1179. }
  1180.  
  1181. return match;
  1182. };
  1183. }
  1184.  
  1185. var regexpExec$2 = patchedExec;
  1186.  
  1187. var $$1 = _export;
  1188. var exec = regexpExec$2;
  1189.  
  1190. // `RegExp.prototype.exec` method
  1191. // https://tc39.es/ecma262/#sec-regexp.prototype.exec
  1192. $$1({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {
  1193. exec: exec
  1194. });
  1195.  
  1196. // TODO: Remove from `core-js@4` since it's moved to entry points
  1197.  
  1198. var redefine = redefine$2.exports;
  1199. var regexpExec$1 = regexpExec$2;
  1200. var fails$1 = fails$a;
  1201. var wellKnownSymbol$1 = wellKnownSymbol$5;
  1202. var createNonEnumerableProperty = createNonEnumerableProperty$4;
  1203.  
  1204. var SPECIES = wellKnownSymbol$1('species');
  1205. var RegExpPrototype = RegExp.prototype;
  1206.  
  1207. var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
  1208. var SYMBOL = wellKnownSymbol$1(KEY);
  1209.  
  1210. var DELEGATES_TO_SYMBOL = !fails$1(function () {
  1211. // String methods call symbol-named RegEp methods
  1212. var O = {};
  1213. O[SYMBOL] = function () { return 7; };
  1214. return ''[KEY](O) != 7;
  1215. });
  1216.  
  1217. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$1(function () {
  1218. // Symbol-named RegExp methods call .exec
  1219. var execCalled = false;
  1220. var re = /a/;
  1221.  
  1222. if (KEY === 'split') {
  1223. // We can't use real regex here since it causes deoptimization
  1224. // and serious performance degradation in V8
  1225. // https://github.com/zloirock/core-js/issues/306
  1226. re = {};
  1227. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  1228. // a new one. We need to return the patched regex when creating the new one.
  1229. re.constructor = {};
  1230. re.constructor[SPECIES] = function () { return re; };
  1231. re.flags = '';
  1232. re[SYMBOL] = /./[SYMBOL];
  1233. }
  1234.  
  1235. re.exec = function () { execCalled = true; return null; };
  1236.  
  1237. re[SYMBOL]('');
  1238. return !execCalled;
  1239. });
  1240.  
  1241. if (
  1242. !DELEGATES_TO_SYMBOL ||
  1243. !DELEGATES_TO_EXEC ||
  1244. FORCED
  1245. ) {
  1246. var nativeRegExpMethod = /./[SYMBOL];
  1247. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  1248. var $exec = regexp.exec;
  1249. if ($exec === regexpExec$1 || $exec === RegExpPrototype.exec) {
  1250. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  1251. // The native String method already delegates to @@method (this
  1252. // polyfilled function), leasing to infinite recursion.
  1253. // We avoid it by directly calling the native @@method method.
  1254. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  1255. }
  1256. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  1257. }
  1258. return { done: false };
  1259. });
  1260.  
  1261. redefine(String.prototype, KEY, methods[0]);
  1262. redefine(RegExpPrototype, SYMBOL, methods[1]);
  1263. }
  1264.  
  1265. if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
  1266. };
  1267.  
  1268. var toIntegerOrInfinity$1 = toIntegerOrInfinity$4;
  1269. var toString$1 = toString$3;
  1270. var requireObjectCoercible$1 = requireObjectCoercible$4;
  1271.  
  1272. var createMethod = function (CONVERT_TO_STRING) {
  1273. return function ($this, pos) {
  1274. var S = toString$1(requireObjectCoercible$1($this));
  1275. var position = toIntegerOrInfinity$1(pos);
  1276. var size = S.length;
  1277. var first, second;
  1278. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  1279. first = S.charCodeAt(position);
  1280. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  1281. || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
  1282. ? CONVERT_TO_STRING ? S.charAt(position) : first
  1283. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  1284. };
  1285. };
  1286.  
  1287. var stringMultibyte = {
  1288. // `String.prototype.codePointAt` method
  1289. // https://tc39.es/ecma262/#sec-string.prototype.codepointat
  1290. codeAt: createMethod(false),
  1291. // `String.prototype.at` method
  1292. // https://github.com/mathiasbynens/String.prototype.at
  1293. charAt: createMethod(true)
  1294. };
  1295.  
  1296. var charAt = stringMultibyte.charAt;
  1297.  
  1298. // `AdvanceStringIndex` abstract operation
  1299. // https://tc39.es/ecma262/#sec-advancestringindex
  1300. var advanceStringIndex$1 = function (S, index, unicode) {
  1301. return index + (unicode ? charAt(S, index).length : 1);
  1302. };
  1303.  
  1304. var toObject = toObject$2;
  1305.  
  1306. var floor = Math.floor;
  1307. var replace = ''.replace;
  1308. var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g;
  1309. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g;
  1310.  
  1311. // `GetSubstitution` abstract operation
  1312. // https://tc39.es/ecma262/#sec-getsubstitution
  1313. var getSubstitution$1 = function (matched, str, position, captures, namedCaptures, replacement) {
  1314. var tailPos = position + matched.length;
  1315. var m = captures.length;
  1316. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  1317. if (namedCaptures !== undefined) {
  1318. namedCaptures = toObject(namedCaptures);
  1319. symbols = SUBSTITUTION_SYMBOLS;
  1320. }
  1321. return replace.call(replacement, symbols, function (match, ch) {
  1322. var capture;
  1323. switch (ch.charAt(0)) {
  1324. case '$': return '$';
  1325. case '&': return matched;
  1326. case '`': return str.slice(0, position);
  1327. case "'": return str.slice(tailPos);
  1328. case '<':
  1329. capture = namedCaptures[ch.slice(1, -1)];
  1330. break;
  1331. default: // \d\d?
  1332. var n = +ch;
  1333. if (n === 0) return match;
  1334. if (n > m) {
  1335. var f = floor(n / 10);
  1336. if (f === 0) return match;
  1337. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  1338. return match;
  1339. }
  1340. capture = captures[n - 1];
  1341. }
  1342. return capture === undefined ? '' : capture;
  1343. });
  1344. };
  1345.  
  1346. var anObject$1 = anObject$7;
  1347. var isCallable$1 = isCallable$c;
  1348. var classof = classofRaw$1;
  1349. var regexpExec = regexpExec$2;
  1350.  
  1351. // `RegExpExec` abstract operation
  1352. // https://tc39.es/ecma262/#sec-regexpexec
  1353. var regexpExecAbstract = function (R, S) {
  1354. var exec = R.exec;
  1355. if (isCallable$1(exec)) {
  1356. var result = exec.call(R, S);
  1357. if (result !== null) anObject$1(result);
  1358. return result;
  1359. }
  1360. if (classof(R) === 'RegExp') return regexpExec.call(R, S);
  1361. throw TypeError('RegExp#exec called on incompatible receiver');
  1362. };
  1363.  
  1364. var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
  1365. var fails = fails$a;
  1366. var anObject = anObject$7;
  1367. var isCallable = isCallable$c;
  1368. var toIntegerOrInfinity = toIntegerOrInfinity$4;
  1369. var toLength = toLength$2;
  1370. var toString = toString$3;
  1371. var requireObjectCoercible = requireObjectCoercible$4;
  1372. var advanceStringIndex = advanceStringIndex$1;
  1373. var getMethod = getMethod$2;
  1374. var getSubstitution = getSubstitution$1;
  1375. var regExpExec = regexpExecAbstract;
  1376. var wellKnownSymbol = wellKnownSymbol$5;
  1377.  
  1378. var REPLACE = wellKnownSymbol('replace');
  1379. var max = Math.max;
  1380. var min = Math.min;
  1381.  
  1382. var maybeToString = function (it) {
  1383. return it === undefined ? it : String(it);
  1384. };
  1385.  
  1386. // IE <= 11 replaces $0 with the whole match, as if it was $&
  1387. // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
  1388. var REPLACE_KEEPS_$0 = (function () {
  1389. // eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
  1390. return 'a'.replace(/./, '$0') === '$0';
  1391. })();
  1392.  
  1393. // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
  1394. var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
  1395. if (/./[REPLACE]) {
  1396. return /./[REPLACE]('a', '$0') === '';
  1397. }
  1398. return false;
  1399. })();
  1400.  
  1401. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  1402. var re = /./;
  1403. re.exec = function () {
  1404. var result = [];
  1405. result.groups = { a: '7' };
  1406. return result;
  1407. };
  1408. // eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive
  1409. return ''.replace(re, '$<a>') !== '7';
  1410. });
  1411.  
  1412. // @@replace logic
  1413. fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) {
  1414. var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
  1415.  
  1416. return [
  1417. // `String.prototype.replace` method
  1418. // https://tc39.es/ecma262/#sec-string.prototype.replace
  1419. function replace(searchValue, replaceValue) {
  1420. var O = requireObjectCoercible(this);
  1421. var replacer = searchValue == undefined ? undefined : getMethod(searchValue, REPLACE);
  1422. return replacer
  1423. ? replacer.call(searchValue, O, replaceValue)
  1424. : nativeReplace.call(toString(O), searchValue, replaceValue);
  1425. },
  1426. // `RegExp.prototype[@@replace]` method
  1427. // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
  1428. function (string, replaceValue) {
  1429. var rx = anObject(this);
  1430. var S = toString(string);
  1431.  
  1432. if (
  1433. typeof replaceValue === 'string' &&
  1434. replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1 &&
  1435. replaceValue.indexOf('$<') === -1
  1436. ) {
  1437. var res = maybeCallNative(nativeReplace, rx, S, replaceValue);
  1438. if (res.done) return res.value;
  1439. }
  1440.  
  1441. var functionalReplace = isCallable(replaceValue);
  1442. if (!functionalReplace) replaceValue = toString(replaceValue);
  1443.  
  1444. var global = rx.global;
  1445. if (global) {
  1446. var fullUnicode = rx.unicode;
  1447. rx.lastIndex = 0;
  1448. }
  1449. var results = [];
  1450. while (true) {
  1451. var result = regExpExec(rx, S);
  1452. if (result === null) break;
  1453.  
  1454. results.push(result);
  1455. if (!global) break;
  1456.  
  1457. var matchStr = toString(result[0]);
  1458. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  1459. }
  1460.  
  1461. var accumulatedResult = '';
  1462. var nextSourcePosition = 0;
  1463. for (var i = 0; i < results.length; i++) {
  1464. result = results[i];
  1465.  
  1466. var matched = toString(result[0]);
  1467. var position = max(min(toIntegerOrInfinity(result.index), S.length), 0);
  1468. var captures = [];
  1469. // NOTE: This is equivalent to
  1470. // captures = result.slice(1).map(maybeToString)
  1471. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  1472. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  1473. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  1474. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  1475. var namedCaptures = result.groups;
  1476. if (functionalReplace) {
  1477. var replacerArgs = [matched].concat(captures, position, S);
  1478. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  1479. var replacement = toString(replaceValue.apply(undefined, replacerArgs));
  1480. } else {
  1481. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  1482. }
  1483. if (position >= nextSourcePosition) {
  1484. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  1485. nextSourcePosition = position + matched.length;
  1486. }
  1487. }
  1488. return accumulatedResult + S.slice(nextSourcePosition);
  1489. }
  1490. ];
  1491. }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);
  1492.  
  1493. const extStoragePrefix = "added_juejin_extension_"; // const marketplaceURL = "http://localhost:3000";
  1494.  
  1495. const marketplaceURL = "https://juejin-enhancer-extensions.vercel.app";
  1496.  
  1497. const isIExtension = object => {
  1498. return !!object && typeof object["slug"] === "string" && typeof object["version"] === "string" && typeof object["code"] === "string" && typeof object["url"] === "string";
  1499. };
  1500.  
  1501. const saveToStorage = (name, extension, isLocal) => {
  1502. GM_setValue(extStoragePrefix + `${isLocal ? "local_" : ""}` + name, extension);
  1503. };
  1504.  
  1505. const removeFromStorage = name => {
  1506. GM_deleteValue(extStoragePrefix + name);
  1507. };
  1508.  
  1509. const removeAllLocalExtensions = () => {
  1510. try {
  1511. const allLocalExtension = GM_listValues().filter(key => key.startsWith(extStoragePrefix + "local_"));
  1512. allLocalExtension.forEach(GM_deleteValue);
  1513. return "success";
  1514. } catch (e) {
  1515. return "error";
  1516. }
  1517. };
  1518.  
  1519. const removeAllExtensions = () => {
  1520. try {
  1521. const allExtension = GM_listValues().filter(key => key.startsWith(extStoragePrefix));
  1522. allExtension.forEach(GM_deleteValue);
  1523. return "success";
  1524. } catch (e) {
  1525. return "error";
  1526. }
  1527. };
  1528.  
  1529. const queryExtension = name => {
  1530. return GM_getValue(extStoragePrefix + name) || GM_getValue(extStoragePrefix + "local_" + name);
  1531. };
  1532.  
  1533. const listAllExtension = () => {
  1534. return GM_listValues().filter(key => key.startsWith(extStoragePrefix) && !key.startsWith(extStoragePrefix + "local_")).map(key => key.replace(new RegExp("^" + extStoragePrefix), ""));
  1535. };
  1536.  
  1537. const cleanDataCaches = () => {
  1538. GM_listValues().filter(key => !key.startsWith(extStoragePrefix)).forEach(key => GM_deleteValue(key));
  1539. };
  1540.  
  1541. const fetchPlugin = url => {
  1542. return new Promise((resolve, reject) => {
  1543. GM_xmlhttpRequest({
  1544. method: "GET",
  1545. url,
  1546.  
  1547. onload({
  1548. status,
  1549. response
  1550. }) {
  1551. if (status === 200) {
  1552. try {
  1553. resolve(response);
  1554. } catch (error) {
  1555. reject(error);
  1556. }
  1557. } else {
  1558. reject("error");
  1559. }
  1560. },
  1561.  
  1562. onerror(e) {
  1563. reject("request_error");
  1564. },
  1565.  
  1566. onabort() {
  1567. reject("aborted");
  1568. }
  1569.  
  1570. });
  1571. });
  1572. };
  1573.  
  1574. function installExtension(slug, url, version) {
  1575. return fetchPlugin(url).then(code => {
  1576. saveToStorage(slug, {
  1577. slug,
  1578. version,
  1579. code,
  1580. url
  1581. });
  1582. });
  1583. }
  1584.  
  1585. const plugins = restoreFromStorage();
  1586.  
  1587. function restoreFromStorage() {
  1588. const allStoragePlugins = GM_listValues().filter(key => key.startsWith(extStoragePrefix));
  1589. return allStoragePlugins.map(key => GM_getValue(key, null)).filter(isIExtension).map(({
  1590. slug,
  1591. code
  1592. }) => {
  1593. return executePlugin(slug, code);
  1594. }).filter(({
  1595. plugin
  1596. }) => {
  1597. return plugin && !(plugin !== null && plugin !== void 0 && plugin.isOffShelf);
  1598. });
  1599. }
  1600.  
  1601. function executePlugin(name, code) {
  1602. try {
  1603. const plugin = eval(code);
  1604. return {
  1605. name,
  1606. plugin
  1607. };
  1608. } catch (e) {
  1609. console.log(name, code);
  1610. return {
  1611. name,
  1612. plugin: null
  1613. };
  1614. }
  1615. }
  1616.  
  1617. function launchMarketplace() {
  1618. unsafeWindow.onAddLocalJuejinExtension = (filePath, code) => {
  1619. try {
  1620. const extension = {
  1621. slug: filePath,
  1622. version: "0.0.0",
  1623. code,
  1624. url: filePath
  1625. };
  1626. saveToStorage(filePath, extension, true);
  1627. return "success";
  1628. } catch (e) {
  1629. return "error";
  1630. }
  1631. };
  1632.  
  1633. unsafeWindow.onRemoveLocalJuejinExtension = () => {
  1634. try {
  1635. removeAllLocalExtensions();
  1636. return "success";
  1637. } catch (e) {
  1638. if (e instanceof Error) {
  1639. return "error:" + e.message;
  1640. } else {
  1641. return "error";
  1642. }
  1643. }
  1644. };
  1645.  
  1646. unsafeWindow.onAddJuejinExtension = (slug, {
  1647. url,
  1648. version
  1649. }) => {
  1650. return installExtension(slug, url, version).then(() => {
  1651. return "success";
  1652. }).catch(e => {
  1653. return "error:" + e.message;
  1654. });
  1655. };
  1656.  
  1657. unsafeWindow.onRemoveJuejinExtension = slug => {
  1658. return new Promise((resolve, reject) => {
  1659. try {
  1660. removeFromStorage(slug);
  1661. resolve("success");
  1662. } catch (e) {
  1663. reject("error");
  1664. }
  1665. });
  1666. };
  1667.  
  1668. unsafeWindow.checkJuejinExtension = (slug, version) => {
  1669. const extension = queryExtension(slug);
  1670.  
  1671. if (!extension) {
  1672. return {
  1673. added: false,
  1674. update: false
  1675. };
  1676. } else {
  1677. return {
  1678. added: true,
  1679. update: version !== extension.version
  1680. };
  1681. }
  1682. };
  1683.  
  1684. unsafeWindow.cleanExtensionDataCaches = () => {
  1685. try {
  1686. cleanDataCaches();
  1687. return "success";
  1688. } catch (e) {
  1689. return "error";
  1690. }
  1691. };
  1692. }
  1693.  
  1694. function launchJuejin() {
  1695. console.log($);
  1696. plugins.forEach(({
  1697. plugin
  1698. }) => {
  1699. var _plugin$onLoaded;
  1700.  
  1701. plugin === null || plugin === void 0 ? void 0 : (_plugin$onLoaded = plugin.onLoaded) === null || _plugin$onLoaded === void 0 ? void 0 : _plugin$onLoaded.call(plugin);
  1702. });
  1703. initRouter();
  1704.  
  1705. function initRouter() {
  1706. let currentRouterPathname = "";
  1707.  
  1708. function onRouteChange() {
  1709. const prevRouterPathname = currentRouterPathname;
  1710. currentRouterPathname = document.location.pathname;
  1711.  
  1712. if (prevRouterPathname !== currentRouterPathname) {
  1713. plugins.forEach(({
  1714. plugin
  1715. }) => {
  1716. var _plugin$onRouteChange;
  1717.  
  1718. plugin === null || plugin === void 0 ? void 0 : (_plugin$onRouteChange = plugin.onRouteChange) === null || _plugin$onRouteChange === void 0 ? void 0 : _plugin$onRouteChange.call(plugin, prevRouterPathname, currentRouterPathname);
  1719. });
  1720. }
  1721. }
  1722.  
  1723. const _historyPushState = history.pushState;
  1724. const _historyReplaceState = history.replaceState;
  1725.  
  1726. history.pushState = function (...rest) {
  1727. _historyPushState.apply(history, rest);
  1728.  
  1729. onRouteChange();
  1730. };
  1731.  
  1732. history.replaceState = function (...rest) {
  1733. _historyReplaceState.apply(history, rest);
  1734.  
  1735. onRouteChange();
  1736. };
  1737.  
  1738. window.addEventListener("popstate", function () {
  1739. onRouteChange();
  1740. });
  1741. }
  1742. }
  1743.  
  1744. function initMenu() {
  1745. GM_registerMenuCommand("扩展市场", () => {
  1746. GM_openInTab(marketplaceURL, {
  1747. active: true
  1748. });
  1749. });
  1750. GM_registerMenuCommand("手动添加扩展", () => {
  1751. const url = window.prompt("输入可访问链接");
  1752.  
  1753. if (url) {
  1754. installExtension(url, url, "0.0.0").then(() => {
  1755. window.alert("添加成功");
  1756. }).catch(() => {
  1757. window.alert("添加失败");
  1758. });
  1759. }
  1760. });
  1761. GM_registerMenuCommand("移除所有扩展", () => {
  1762. removeAllExtensions();
  1763. });
  1764. }
  1765.  
  1766. function autoCheckExtension() {
  1767. const duration = 30 * 60 * 1000;
  1768. const allExtensions = listAllExtension();
  1769. const lastCheckTime = GM_getValue("update_check", 0);
  1770. const isTimeToCheck = new Date().valueOf() - lastCheckTime > duration;
  1771.  
  1772. if (allExtensions.length > 0 && isTimeToCheck) {
  1773. GM_setValue("update_check", new Date().valueOf());
  1774. GM_xmlhttpRequest({
  1775. method: "POST",
  1776. url: `${marketplaceURL}/api/check`,
  1777. headers: {
  1778. "content-type": "application/json"
  1779. },
  1780. data: JSON.stringify({
  1781. slugs: allExtensions
  1782. }),
  1783. responseType: "json",
  1784.  
  1785. onload({
  1786. status,
  1787. response
  1788. }) {
  1789. if (status === 200) {
  1790. response.updated.forEach(({
  1791. slug,
  1792. rawURL,
  1793. version
  1794. }) => {
  1795. const localExt = queryExtension(slug);
  1796.  
  1797. if ((localExt === null || localExt === void 0 ? void 0 : localExt.version) !== version || localExt.url !== rawURL) {
  1798. installExtension(slug, rawURL, version);
  1799. }
  1800. });
  1801. response.deleted.forEach(slug => {
  1802. removeFromStorage(slug);
  1803. });
  1804. }
  1805. }
  1806.  
  1807. });
  1808. }
  1809.  
  1810. setTimeout(() => {
  1811. autoCheckExtension();
  1812. }, duration);
  1813. }
  1814.  
  1815. async function preInstallExtension() {
  1816. if (!GM_getValue("activated", false)) {
  1817. await installExtension("juejin-post-tracker", "https://gitee.com/curlly-brackets/juejin-post-tracker/raw/main/main.user.js", "0.0.1");
  1818. GM_setValue("activated", true);
  1819. }
  1820. }
  1821.  
  1822. (async function start() {
  1823. initMenu();
  1824. await preInstallExtension();
  1825. autoCheckExtension();
  1826.  
  1827. if (location.host === "juejin.cn") {
  1828. launchJuejin();
  1829. } else if (location.origin === marketplaceURL) {
  1830. launchMarketplace();
  1831. }
  1832. })();
  1833.  
  1834. })();