// ==UserScript==
// @name Juejin Extension Enhancer
// @namespace juejin-enhancer
// @version 1.0.3
// @description Enhances Juejin
// @include *
// @name:zh-CN 掘金扩展助手
// @description:zh-CN 提供一个扩展平台,聚合掘金社区的各类第三方扩展,可插拔使用。扩展旨在为掘金社区提供辅助支持。
// @match *
// @run-at document-end
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @grant GM_addStyle
// @grant GM_addElement
// @grant GM_log
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_listValues
// @grant GM_addValueChangeListener
// @grant GM_removeValueChangeListener
// @grant GM_getResourceText
// @grant GM_getResourceURL
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_openInTab
// @grant GM_xmlhttpRequest
// @grant GM_download
// @grant GM_getTab
// @grant GM_saveTab
// @grant GM_getTabs
// @grant GM_notification
// @grant GM_setClipboard
// @connect juejin.cn
// @connect github.com
// @connect gitee.com
// @connect juejin-enhancer-extensions.vercel.app
// ==/UserScript==
(function () {
'use strict';
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var check = function (it) {
return it && it.Math == Math && it;
};
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global$e =
// eslint-disable-next-line es/no-global-this -- safe
check(typeof globalThis == 'object' && globalThis) ||
check(typeof window == 'object' && window) ||
// eslint-disable-next-line no-restricted-globals -- safe
check(typeof self == 'object' && self) ||
check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
// eslint-disable-next-line no-new-func -- fallback
(function () { return this; })() || Function('return this')();
var objectGetOwnPropertyDescriptor = {};
var fails$a = function (exec) {
try {
return !!exec();
} catch (error) {
return true;
}
};
var fails$9 = fails$a;
// Detect IE8's incomplete defineProperty implementation
var descriptors = !fails$9(function () {
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
});
var objectPropertyIsEnumerable = {};
var $propertyIsEnumerable = {}.propertyIsEnumerable;
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
// Nashorn ~ JDK8 bug
var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
// `Object.prototype.propertyIsEnumerable` method implementation
// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
var descriptor = getOwnPropertyDescriptor$1(this, V);
return !!descriptor && descriptor.enumerable;
} : $propertyIsEnumerable;
var createPropertyDescriptor$2 = function (bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value: value
};
};
var toString$4 = {}.toString;
var classofRaw$1 = function (it) {
return toString$4.call(it).slice(8, -1);
};
var fails$8 = fails$a;
var classof$3 = classofRaw$1;
var split = ''.split;
// fallback for non-array-like ES3 and non-enumerable old V8 strings
var indexedObject = fails$8(function () {
// throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
// eslint-disable-next-line no-prototype-builtins -- safe
return !Object('z').propertyIsEnumerable(0);
}) ? function (it) {
return classof$3(it) == 'String' ? split.call(it, '') : Object(it);
} : Object;
// `RequireObjectCoercible` abstract operation
// https://tc39.es/ecma262/#sec-requireobjectcoercible
var requireObjectCoercible$4 = function (it) {
if (it == undefined) throw TypeError("Can't call method on " + it);
return it;
};
// toObject with fallback for non-array-like ES3 strings
var IndexedObject = indexedObject;
var requireObjectCoercible$3 = requireObjectCoercible$4;
var toIndexedObject$3 = function (it) {
return IndexedObject(requireObjectCoercible$3(it));
};
// `IsCallable` abstract operation
// https://tc39.es/ecma262/#sec-iscallable
var isCallable$c = function (argument) {
return typeof argument === 'function';
};
var isCallable$b = isCallable$c;
var isObject$5 = function (it) {
return typeof it === 'object' ? it !== null : isCallable$b(it);
};
var global$d = global$e;
var isCallable$a = isCallable$c;
var aFunction = function (argument) {
return isCallable$a(argument) ? argument : undefined;
};
var getBuiltIn$4 = function (namespace, method) {
return arguments.length < 2 ? aFunction(global$d[namespace]) : global$d[namespace] && global$d[namespace][method];
};
var getBuiltIn$3 = getBuiltIn$4;
var engineUserAgent = getBuiltIn$3('navigator', 'userAgent') || '';
var global$c = global$e;
var userAgent = engineUserAgent;
var process = global$c.process;
var Deno = global$c.Deno;
var versions = process && process.versions || Deno && Deno.version;
var v8 = versions && versions.v8;
var match, version;
if (v8) {
match = v8.split('.');
version = match[0] < 4 ? 1 : match[0] + match[1];
} else if (userAgent) {
match = userAgent.match(/Edge\/(\d+)/);
if (!match || match[1] >= 74) {
match = userAgent.match(/Chrome\/(\d+)/);
if (match) version = match[1];
}
}
var engineV8Version = version && +version;
/* eslint-disable es/no-symbol -- required for testing */
var V8_VERSION = engineV8Version;
var fails$7 = fails$a;
// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$7(function () {
var symbol = Symbol();
// Chrome 38 Symbol has incorrect toString conversion
// `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
// Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
!Symbol.sham && V8_VERSION && V8_VERSION < 41;
});
/* eslint-disable es/no-symbol -- required for testing */
var NATIVE_SYMBOL$1 = nativeSymbol;
var useSymbolAsUid = NATIVE_SYMBOL$1
&& !Symbol.sham
&& typeof Symbol.iterator == 'symbol';
var isCallable$9 = isCallable$c;
var getBuiltIn$2 = getBuiltIn$4;
var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
return typeof it == 'symbol';
} : function (it) {
var $Symbol = getBuiltIn$2('Symbol');
return isCallable$9($Symbol) && Object(it) instanceof $Symbol;
};
var tryToString$1 = function (argument) {
try {
return String(argument);
} catch (error) {
return 'Object';
}
};
var isCallable$8 = isCallable$c;
var tryToString = tryToString$1;
// `Assert: IsCallable(argument) is true`
var aCallable$1 = function (argument) {
if (isCallable$8(argument)) return argument;
throw TypeError(tryToString(argument) + ' is not a function');
};
var aCallable = aCallable$1;
// `GetMethod` abstract operation
// https://tc39.es/ecma262/#sec-getmethod
var getMethod$2 = function (V, P) {
var func = V[P];
return func == null ? undefined : aCallable(func);
};
var isCallable$7 = isCallable$c;
var isObject$4 = isObject$5;
// `OrdinaryToPrimitive` abstract operation
// https://tc39.es/ecma262/#sec-ordinarytoprimitive
var ordinaryToPrimitive$1 = function (input, pref) {
var fn, val;
if (pref === 'string' && isCallable$7(fn = input.toString) && !isObject$4(val = fn.call(input))) return val;
if (isCallable$7(fn = input.valueOf) && !isObject$4(val = fn.call(input))) return val;
if (pref !== 'string' && isCallable$7(fn = input.toString) && !isObject$4(val = fn.call(input))) return val;
throw TypeError("Can't convert object to primitive value");
};
var shared$4 = {exports: {}};
var global$b = global$e;
var setGlobal$3 = function (key, value) {
try {
// eslint-disable-next-line es/no-object-defineproperty -- safe
Object.defineProperty(global$b, key, { value: value, configurable: true, writable: true });
} catch (error) {
global$b[key] = value;
} return value;
};
var global$a = global$e;
var setGlobal$2 = setGlobal$3;
var SHARED = '__core-js_shared__';
var store$3 = global$a[SHARED] || setGlobal$2(SHARED, {});
var sharedStore = store$3;
var store$2 = sharedStore;
(shared$4.exports = function (key, value) {
return store$2[key] || (store$2[key] = value !== undefined ? value : {});
})('versions', []).push({
version: '3.18.3',
mode: 'global',
copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
});
var requireObjectCoercible$2 = requireObjectCoercible$4;
// `ToObject` abstract operation
// https://tc39.es/ecma262/#sec-toobject
var toObject$2 = function (argument) {
return Object(requireObjectCoercible$2(argument));
};
var toObject$1 = toObject$2;
var hasOwnProperty = {}.hasOwnProperty;
// `HasOwnProperty` abstract operation
// https://tc39.es/ecma262/#sec-hasownproperty
var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
return hasOwnProperty.call(toObject$1(it), key);
};
var id = 0;
var postfix = Math.random();
var uid$2 = function (key) {
return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
};
var global$9 = global$e;
var shared$3 = shared$4.exports;
var hasOwn$6 = hasOwnProperty_1;
var uid$1 = uid$2;
var NATIVE_SYMBOL = nativeSymbol;
var USE_SYMBOL_AS_UID = useSymbolAsUid;
var WellKnownSymbolsStore = shared$3('wks');
var Symbol$1 = global$9.Symbol;
var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
var wellKnownSymbol$5 = function (name) {
if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
if (NATIVE_SYMBOL && hasOwn$6(Symbol$1, name)) {
WellKnownSymbolsStore[name] = Symbol$1[name];
} else {
WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
}
} return WellKnownSymbolsStore[name];
};
var isObject$3 = isObject$5;
var isSymbol$1 = isSymbol$2;
var getMethod$1 = getMethod$2;
var ordinaryToPrimitive = ordinaryToPrimitive$1;
var wellKnownSymbol$4 = wellKnownSymbol$5;
var TO_PRIMITIVE = wellKnownSymbol$4('toPrimitive');
// `ToPrimitive` abstract operation
// https://tc39.es/ecma262/#sec-toprimitive
var toPrimitive$1 = function (input, pref) {
if (!isObject$3(input) || isSymbol$1(input)) return input;
var exoticToPrim = getMethod$1(input, TO_PRIMITIVE);
var result;
if (exoticToPrim) {
if (pref === undefined) pref = 'default';
result = exoticToPrim.call(input, pref);
if (!isObject$3(result) || isSymbol$1(result)) return result;
throw TypeError("Can't convert object to primitive value");
}
if (pref === undefined) pref = 'number';
return ordinaryToPrimitive(input, pref);
};
var toPrimitive = toPrimitive$1;
var isSymbol = isSymbol$2;
// `ToPropertyKey` abstract operation
// https://tc39.es/ecma262/#sec-topropertykey
var toPropertyKey$2 = function (argument) {
var key = toPrimitive(argument, 'string');
return isSymbol(key) ? key : String(key);
};
var global$8 = global$e;
var isObject$2 = isObject$5;
var document$1 = global$8.document;
// typeof document.createElement is 'object' in old IE
var EXISTS$1 = isObject$2(document$1) && isObject$2(document$1.createElement);
var documentCreateElement$1 = function (it) {
return EXISTS$1 ? document$1.createElement(it) : {};
};
var DESCRIPTORS$5 = descriptors;
var fails$6 = fails$a;
var createElement = documentCreateElement$1;
// Thank's IE8 for his funny defineProperty
var ie8DomDefine = !DESCRIPTORS$5 && !fails$6(function () {
// eslint-disable-next-line es/no-object-defineproperty -- requied for testing
return Object.defineProperty(createElement('div'), 'a', {
get: function () { return 7; }
}).a != 7;
});
var DESCRIPTORS$4 = descriptors;
var propertyIsEnumerableModule = objectPropertyIsEnumerable;
var createPropertyDescriptor$1 = createPropertyDescriptor$2;
var toIndexedObject$2 = toIndexedObject$3;
var toPropertyKey$1 = toPropertyKey$2;
var hasOwn$5 = hasOwnProperty_1;
var IE8_DOM_DEFINE$1 = ie8DomDefine;
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
// `Object.getOwnPropertyDescriptor` method
// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
O = toIndexedObject$2(O);
P = toPropertyKey$1(P);
if (IE8_DOM_DEFINE$1) try {
return $getOwnPropertyDescriptor(O, P);
} catch (error) { /* empty */ }
if (hasOwn$5(O, P)) return createPropertyDescriptor$1(!propertyIsEnumerableModule.f.call(O, P), O[P]);
};
var objectDefineProperty = {};
var isObject$1 = isObject$5;
// `Assert: Type(argument) is Object`
var anObject$7 = function (argument) {
if (isObject$1(argument)) return argument;
throw TypeError(String(argument) + ' is not an object');
};
var DESCRIPTORS$3 = descriptors;
var IE8_DOM_DEFINE = ie8DomDefine;
var anObject$6 = anObject$7;
var toPropertyKey = toPropertyKey$2;
// eslint-disable-next-line es/no-object-defineproperty -- safe
var $defineProperty = Object.defineProperty;
// `Object.defineProperty` method
// https://tc39.es/ecma262/#sec-object.defineproperty
objectDefineProperty.f = DESCRIPTORS$3 ? $defineProperty : function defineProperty(O, P, Attributes) {
anObject$6(O);
P = toPropertyKey(P);
anObject$6(Attributes);
if (IE8_DOM_DEFINE) try {
return $defineProperty(O, P, Attributes);
} catch (error) { /* empty */ }
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
var DESCRIPTORS$2 = descriptors;
var definePropertyModule$2 = objectDefineProperty;
var createPropertyDescriptor = createPropertyDescriptor$2;
var createNonEnumerableProperty$4 = DESCRIPTORS$2 ? function (object, key, value) {
return definePropertyModule$2.f(object, key, createPropertyDescriptor(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
var redefine$2 = {exports: {}};
var isCallable$6 = isCallable$c;
var store$1 = sharedStore;
var functionToString = Function.toString;
// this helper broken in `[email protected]`, so we can't use `shared` helper
if (!isCallable$6(store$1.inspectSource)) {
store$1.inspectSource = function (it) {
return functionToString.call(it);
};
}
var inspectSource$2 = store$1.inspectSource;
var global$7 = global$e;
var isCallable$5 = isCallable$c;
var inspectSource$1 = inspectSource$2;
var WeakMap$1 = global$7.WeakMap;
var nativeWeakMap = isCallable$5(WeakMap$1) && /native code/.test(inspectSource$1(WeakMap$1));
var shared$2 = shared$4.exports;
var uid = uid$2;
var keys = shared$2('keys');
var sharedKey$2 = function (key) {
return keys[key] || (keys[key] = uid(key));
};
var hiddenKeys$4 = {};
var NATIVE_WEAK_MAP = nativeWeakMap;
var global$6 = global$e;
var isObject = isObject$5;
var createNonEnumerableProperty$3 = createNonEnumerableProperty$4;
var hasOwn$4 = hasOwnProperty_1;
var shared$1 = sharedStore;
var sharedKey$1 = sharedKey$2;
var hiddenKeys$3 = hiddenKeys$4;
var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
var WeakMap = global$6.WeakMap;
var set, get, has;
var enforce = function (it) {
return has(it) ? get(it) : set(it, {});
};
var getterFor = function (TYPE) {
return function (it) {
var state;
if (!isObject(it) || (state = get(it)).type !== TYPE) {
throw TypeError('Incompatible receiver, ' + TYPE + ' required');
} return state;
};
};
if (NATIVE_WEAK_MAP || shared$1.state) {
var store = shared$1.state || (shared$1.state = new WeakMap());
var wmget = store.get;
var wmhas = store.has;
var wmset = store.set;
set = function (it, metadata) {
if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
metadata.facade = it;
wmset.call(store, it, metadata);
return metadata;
};
get = function (it) {
return wmget.call(store, it) || {};
};
has = function (it) {
return wmhas.call(store, it);
};
} else {
var STATE = sharedKey$1('state');
hiddenKeys$3[STATE] = true;
set = function (it, metadata) {
if (hasOwn$4(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
metadata.facade = it;
createNonEnumerableProperty$3(it, STATE, metadata);
return metadata;
};
get = function (it) {
return hasOwn$4(it, STATE) ? it[STATE] : {};
};
has = function (it) {
return hasOwn$4(it, STATE);
};
}
var internalState = {
set: set,
get: get,
has: has,
enforce: enforce,
getterFor: getterFor
};
var DESCRIPTORS$1 = descriptors;
var hasOwn$3 = hasOwnProperty_1;
var FunctionPrototype = Function.prototype;
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
var EXISTS = hasOwn$3(FunctionPrototype, 'name');
// additional protection from minified / mangled / dropped function names
var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || (DESCRIPTORS$1 && getDescriptor(FunctionPrototype, 'name').configurable));
var functionName = {
EXISTS: EXISTS,
PROPER: PROPER,
CONFIGURABLE: CONFIGURABLE
};
var global$5 = global$e;
var isCallable$4 = isCallable$c;
var hasOwn$2 = hasOwnProperty_1;
var createNonEnumerableProperty$2 = createNonEnumerableProperty$4;
var setGlobal$1 = setGlobal$3;
var inspectSource = inspectSource$2;
var InternalStateModule = internalState;
var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
var getInternalState$1 = InternalStateModule.get;
var enforceInternalState = InternalStateModule.enforce;
var TEMPLATE = String(String).split('String');
(redefine$2.exports = function (O, key, value, options) {
var unsafe = options ? !!options.unsafe : false;
var simple = options ? !!options.enumerable : false;
var noTargetGet = options ? !!options.noTargetGet : false;
var name = options && options.name !== undefined ? options.name : key;
var state;
if (isCallable$4(value)) {
if (String(name).slice(0, 7) === 'Symbol(') {
name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
}
if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
createNonEnumerableProperty$2(value, 'name', name);
}
state = enforceInternalState(value);
if (!state.source) {
state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
}
}
if (O === global$5) {
if (simple) O[key] = value;
else setGlobal$1(key, value);
return;
} else if (!unsafe) {
delete O[key];
} else if (!noTargetGet && O[key]) {
simple = true;
}
if (simple) O[key] = value;
else createNonEnumerableProperty$2(O, key, value);
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
})(Function.prototype, 'toString', function toString() {
return isCallable$4(this) && getInternalState$1(this).source || inspectSource(this);
});
var objectGetOwnPropertyNames = {};
var ceil = Math.ceil;
var floor$1 = Math.floor;
// `ToIntegerOrInfinity` abstract operation
// https://tc39.es/ecma262/#sec-tointegerorinfinity
var toIntegerOrInfinity$4 = function (argument) {
var number = +argument;
// eslint-disable-next-line no-self-compare -- safe
return number !== number || number === 0 ? 0 : (number > 0 ? floor$1 : ceil)(number);
};
var toIntegerOrInfinity$3 = toIntegerOrInfinity$4;
var max$1 = Math.max;
var min$2 = Math.min;
// Helper for a popular repeating case of the spec:
// Let integer be ? ToInteger(index).
// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
var toAbsoluteIndex$1 = function (index, length) {
var integer = toIntegerOrInfinity$3(index);
return integer < 0 ? max$1(integer + length, 0) : min$2(integer, length);
};
var toIntegerOrInfinity$2 = toIntegerOrInfinity$4;
var min$1 = Math.min;
// `ToLength` abstract operation
// https://tc39.es/ecma262/#sec-tolength
var toLength$2 = function (argument) {
return argument > 0 ? min$1(toIntegerOrInfinity$2(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
};
var toLength$1 = toLength$2;
// `LengthOfArrayLike` abstract operation
// https://tc39.es/ecma262/#sec-lengthofarraylike
var lengthOfArrayLike$1 = function (obj) {
return toLength$1(obj.length);
};
var toIndexedObject$1 = toIndexedObject$3;
var toAbsoluteIndex = toAbsoluteIndex$1;
var lengthOfArrayLike = lengthOfArrayLike$1;
// `Array.prototype.{ indexOf, includes }` methods implementation
var createMethod$1 = function (IS_INCLUDES) {
return function ($this, el, fromIndex) {
var O = toIndexedObject$1($this);
var length = lengthOfArrayLike(O);
var index = toAbsoluteIndex(fromIndex, length);
var value;
// Array#includes uses SameValueZero equality algorithm
// eslint-disable-next-line no-self-compare -- NaN check
if (IS_INCLUDES && el != el) while (length > index) {
value = O[index++];
// eslint-disable-next-line no-self-compare -- NaN check
if (value != value) return true;
// Array#indexOf ignores holes, Array#includes - not
} else for (;length > index; index++) {
if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
} return !IS_INCLUDES && -1;
};
};
var arrayIncludes = {
// `Array.prototype.includes` method
// https://tc39.es/ecma262/#sec-array.prototype.includes
includes: createMethod$1(true),
// `Array.prototype.indexOf` method
// https://tc39.es/ecma262/#sec-array.prototype.indexof
indexOf: createMethod$1(false)
};
var hasOwn$1 = hasOwnProperty_1;
var toIndexedObject = toIndexedObject$3;
var indexOf = arrayIncludes.indexOf;
var hiddenKeys$2 = hiddenKeys$4;
var objectKeysInternal = function (object, names) {
var O = toIndexedObject(object);
var i = 0;
var result = [];
var key;
for (key in O) !hasOwn$1(hiddenKeys$2, key) && hasOwn$1(O, key) && result.push(key);
// Don't enum bug & hidden keys
while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
~indexOf(result, key) || result.push(key);
}
return result;
};
// IE8- don't enum bug keys
var enumBugKeys$3 = [
'constructor',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'toLocaleString',
'toString',
'valueOf'
];
var internalObjectKeys$1 = objectKeysInternal;
var enumBugKeys$2 = enumBugKeys$3;
var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
// `Object.getOwnPropertyNames` method
// https://tc39.es/ecma262/#sec-object.getownpropertynames
// eslint-disable-next-line es/no-object-getownpropertynames -- safe
objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
return internalObjectKeys$1(O, hiddenKeys$1);
};
var objectGetOwnPropertySymbols = {};
// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
var getBuiltIn$1 = getBuiltIn$4;
var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
var anObject$5 = anObject$7;
// all object keys, includes non-enumerable and symbols
var ownKeys$1 = getBuiltIn$1('Reflect', 'ownKeys') || function ownKeys(it) {
var keys = getOwnPropertyNamesModule.f(anObject$5(it));
var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
};
var hasOwn = hasOwnProperty_1;
var ownKeys = ownKeys$1;
var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
var definePropertyModule$1 = objectDefineProperty;
var copyConstructorProperties$1 = function (target, source) {
var keys = ownKeys(source);
var defineProperty = definePropertyModule$1.f;
var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (!hasOwn(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
}
};
var fails$5 = fails$a;
var isCallable$3 = isCallable$c;
var replacement = /#|\.prototype\./;
var isForced$1 = function (feature, detection) {
var value = data[normalize(feature)];
return value == POLYFILL ? true
: value == NATIVE ? false
: isCallable$3(detection) ? fails$5(detection)
: !!detection;
};
var normalize = isForced$1.normalize = function (string) {
return String(string).replace(replacement, '.').toLowerCase();
};
var data = isForced$1.data = {};
var NATIVE = isForced$1.NATIVE = 'N';
var POLYFILL = isForced$1.POLYFILL = 'P';
var isForced_1 = isForced$1;
var global$4 = global$e;
var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
var createNonEnumerableProperty$1 = createNonEnumerableProperty$4;
var redefine$1 = redefine$2.exports;
var setGlobal = setGlobal$3;
var copyConstructorProperties = copyConstructorProperties$1;
var isForced = isForced_1;
/*
options.target - name of the target object
options.global - target is the global object
options.stat - export as static methods of target
options.proto - export as prototype methods of target
options.real - real prototype method for the `pure` version
options.forced - export even if the native feature is available
options.bind - bind methods to the target, required for the `pure` version
options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
options.unsafe - use the simple assignment of property instead of delete + defineProperty
options.sham - add a flag to not completely full polyfills
options.enumerable - export as enumerable property
options.noTargetGet - prevent calling a getter on target
options.name - the .name of the function if it does not match the key
*/
var _export = function (options, source) {
var TARGET = options.target;
var GLOBAL = options.global;
var STATIC = options.stat;
var FORCED, target, key, targetProperty, sourceProperty, descriptor;
if (GLOBAL) {
target = global$4;
} else if (STATIC) {
target = global$4[TARGET] || setGlobal(TARGET, {});
} else {
target = (global$4[TARGET] || {}).prototype;
}
if (target) for (key in source) {
sourceProperty = source[key];
if (options.noTargetGet) {
descriptor = getOwnPropertyDescriptor(target, key);
targetProperty = descriptor && descriptor.value;
} else targetProperty = target[key];
FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
// contained in target
if (!FORCED && targetProperty !== undefined) {
if (typeof sourceProperty === typeof targetProperty) continue;
copyConstructorProperties(sourceProperty, targetProperty);
}
// add a flag to not completely full polyfills
if (options.sham || (targetProperty && targetProperty.sham)) {
createNonEnumerableProperty$1(sourceProperty, 'sham', true);
}
// extend global
redefine$1(target, key, sourceProperty, options);
}
};
var wellKnownSymbol$3 = wellKnownSymbol$5;
var TO_STRING_TAG$1 = wellKnownSymbol$3('toStringTag');
var test = {};
test[TO_STRING_TAG$1] = 'z';
var toStringTagSupport = String(test) === '[object z]';
var TO_STRING_TAG_SUPPORT = toStringTagSupport;
var isCallable$2 = isCallable$c;
var classofRaw = classofRaw$1;
var wellKnownSymbol$2 = wellKnownSymbol$5;
var TO_STRING_TAG = wellKnownSymbol$2('toStringTag');
// ES3 wrong here
var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
// fallback for IE11 Script Access Denied error
var tryGet = function (it, key) {
try {
return it[key];
} catch (error) { /* empty */ }
};
// getting tag from ES6+ `Object.prototype.toString`
var classof$2 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
var O, tag, result;
return it === undefined ? 'Undefined' : it === null ? 'Null'
// @@toStringTag case
: typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
// builtinTag case
: CORRECT_ARGUMENTS ? classofRaw(O)
// ES3 arguments fallback
: (result = classofRaw(O)) == 'Object' && isCallable$2(O.callee) ? 'Arguments' : result;
};
var classof$1 = classof$2;
var toString$3 = function (argument) {
if (classof$1(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
return String(argument);
};
var anObject$4 = anObject$7;
// `RegExp.prototype.flags` getter implementation
// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
var regexpFlags$1 = function () {
var that = anObject$4(this);
var result = '';
if (that.global) result += 'g';
if (that.ignoreCase) result += 'i';
if (that.multiline) result += 'm';
if (that.dotAll) result += 's';
if (that.unicode) result += 'u';
if (that.sticky) result += 'y';
return result;
};
var regexpStickyHelpers = {};
var fails$4 = fails$a;
var global$3 = global$e;
// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
var $RegExp$2 = global$3.RegExp;
regexpStickyHelpers.UNSUPPORTED_Y = fails$4(function () {
var re = $RegExp$2('a', 'y');
re.lastIndex = 2;
return re.exec('abcd') != null;
});
regexpStickyHelpers.BROKEN_CARET = fails$4(function () {
// https://bugzilla.mozilla.org/show_bug.cgi?id=773687
var re = $RegExp$2('^r', 'gy');
re.lastIndex = 2;
return re.exec('str') != null;
});
var internalObjectKeys = objectKeysInternal;
var enumBugKeys$1 = enumBugKeys$3;
// `Object.keys` method
// https://tc39.es/ecma262/#sec-object.keys
// eslint-disable-next-line es/no-object-keys -- safe
var objectKeys$1 = Object.keys || function keys(O) {
return internalObjectKeys(O, enumBugKeys$1);
};
var DESCRIPTORS = descriptors;
var definePropertyModule = objectDefineProperty;
var anObject$3 = anObject$7;
var objectKeys = objectKeys$1;
// `Object.defineProperties` method
// https://tc39.es/ecma262/#sec-object.defineproperties
// eslint-disable-next-line es/no-object-defineproperties -- safe
var objectDefineProperties = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
anObject$3(O);
var keys = objectKeys(Properties);
var length = keys.length;
var index = 0;
var key;
while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);
return O;
};
var getBuiltIn = getBuiltIn$4;
var html$1 = getBuiltIn('document', 'documentElement');
/* global ActiveXObject -- old IE, WSH */
var anObject$2 = anObject$7;
var defineProperties = objectDefineProperties;
var enumBugKeys = enumBugKeys$3;
var hiddenKeys = hiddenKeys$4;
var html = html$1;
var documentCreateElement = documentCreateElement$1;
var sharedKey = sharedKey$2;
var GT = '>';
var LT = '<';
var PROTOTYPE = 'prototype';
var SCRIPT = 'script';
var IE_PROTO = sharedKey('IE_PROTO');
var EmptyConstructor = function () { /* empty */ };
var scriptTag = function (content) {
return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
};
// Create object with fake `null` prototype: use ActiveX Object with cleared prototype
var NullProtoObjectViaActiveX = function (activeXDocument) {
activeXDocument.write(scriptTag(''));
activeXDocument.close();
var temp = activeXDocument.parentWindow.Object;
activeXDocument = null; // avoid memory leak
return temp;
};
// Create object with fake `null` prototype: use iframe Object with cleared prototype
var NullProtoObjectViaIFrame = function () {
// Thrash, waste and sodomy: IE GC bug
var iframe = documentCreateElement('iframe');
var JS = 'java' + SCRIPT + ':';
var iframeDocument;
iframe.style.display = 'none';
html.appendChild(iframe);
// https://github.com/zloirock/core-js/issues/475
iframe.src = String(JS);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(scriptTag('document.F=Object'));
iframeDocument.close();
return iframeDocument.F;
};
// Check for document.domain and active x support
// No need to use active x approach when document.domain is not set
// see https://github.com/es-shims/es5-shim/issues/150
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
// avoid IE GC bug
var activeXDocument;
var NullProtoObject = function () {
try {
activeXDocument = new ActiveXObject('htmlfile');
} catch (error) { /* ignore */ }
NullProtoObject = typeof document != 'undefined'
? document.domain && activeXDocument
? NullProtoObjectViaActiveX(activeXDocument) // old IE
: NullProtoObjectViaIFrame()
: NullProtoObjectViaActiveX(activeXDocument); // WSH
var length = enumBugKeys.length;
while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
return NullProtoObject();
};
hiddenKeys[IE_PROTO] = true;
// `Object.create` method
// https://tc39.es/ecma262/#sec-object.create
var objectCreate = Object.create || function create(O, Properties) {
var result;
if (O !== null) {
EmptyConstructor[PROTOTYPE] = anObject$2(O);
result = new EmptyConstructor();
EmptyConstructor[PROTOTYPE] = null;
// add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = NullProtoObject();
return Properties === undefined ? result : defineProperties(result, Properties);
};
var fails$3 = fails$a;
var global$2 = global$e;
// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
var $RegExp$1 = global$2.RegExp;
var regexpUnsupportedDotAll = fails$3(function () {
var re = $RegExp$1('.', 's');
return !(re.dotAll && re.exec('\n') && re.flags === 's');
});
var fails$2 = fails$a;
var global$1 = global$e;
// babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
var $RegExp = global$1.RegExp;
var regexpUnsupportedNcg = fails$2(function () {
var re = $RegExp('(?<a>b)', 'g');
return re.exec('b').groups.a !== 'b' ||
'b'.replace(re, '$<a>c') !== 'bc';
});
/* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
/* eslint-disable regexp/no-useless-quantifier -- testing */
var toString$2 = toString$3;
var regexpFlags = regexpFlags$1;
var stickyHelpers = regexpStickyHelpers;
var shared = shared$4.exports;
var create = objectCreate;
var getInternalState = internalState.get;
var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll;
var UNSUPPORTED_NCG = regexpUnsupportedNcg;
var nativeExec = RegExp.prototype.exec;
var nativeReplace = shared('native-string-replace', String.prototype.replace);
var patchedExec = nativeExec;
var UPDATES_LAST_INDEX_WRONG = (function () {
var re1 = /a/;
var re2 = /b*/g;
nativeExec.call(re1, 'a');
nativeExec.call(re2, 'a');
return re1.lastIndex !== 0 || re2.lastIndex !== 0;
})();
var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;
// nonparticipating capturing group, copied from es5-shim's String#split patch.
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
if (PATCH) {
// eslint-disable-next-line max-statements -- TODO
patchedExec = function exec(string) {
var re = this;
var state = getInternalState(re);
var str = toString$2(string);
var raw = state.raw;
var result, reCopy, lastIndex, match, i, object, group;
if (raw) {
raw.lastIndex = re.lastIndex;
result = patchedExec.call(raw, str);
re.lastIndex = raw.lastIndex;
return result;
}
var groups = state.groups;
var sticky = UNSUPPORTED_Y && re.sticky;
var flags = regexpFlags.call(re);
var source = re.source;
var charsAdded = 0;
var strCopy = str;
if (sticky) {
flags = flags.replace('y', '');
if (flags.indexOf('g') === -1) {
flags += 'g';
}
strCopy = str.slice(re.lastIndex);
// Support anchored sticky behavior.
if (re.lastIndex > 0 && (!re.multiline || re.multiline && str.charAt(re.lastIndex - 1) !== '\n')) {
source = '(?: ' + source + ')';
strCopy = ' ' + strCopy;
charsAdded++;
}
// ^(? + rx + ) is needed, in combination with some str slicing, to
// simulate the 'y' flag.
reCopy = new RegExp('^(?:' + source + ')', flags);
}
if (NPCG_INCLUDED) {
reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
}
if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
match = nativeExec.call(sticky ? reCopy : re, strCopy);
if (sticky) {
if (match) {
match.input = match.input.slice(charsAdded);
match[0] = match[0].slice(charsAdded);
match.index = re.lastIndex;
re.lastIndex += match[0].length;
} else re.lastIndex = 0;
} else if (UPDATES_LAST_INDEX_WRONG && match) {
re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
}
if (NPCG_INCLUDED && match && match.length > 1) {
// Fix browsers whose `exec` methods don't consistently return `undefined`
// for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
nativeReplace.call(match[0], reCopy, function () {
for (i = 1; i < arguments.length - 2; i++) {
if (arguments[i] === undefined) match[i] = undefined;
}
});
}
if (match && groups) {
match.groups = object = create(null);
for (i = 0; i < groups.length; i++) {
group = groups[i];
object[group[0]] = match[group[1]];
}
}
return match;
};
}
var regexpExec$2 = patchedExec;
var $$1 = _export;
var exec = regexpExec$2;
// `RegExp.prototype.exec` method
// https://tc39.es/ecma262/#sec-regexp.prototype.exec
$$1({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {
exec: exec
});
// TODO: Remove from `core-js@4` since it's moved to entry points
var redefine = redefine$2.exports;
var regexpExec$1 = regexpExec$2;
var fails$1 = fails$a;
var wellKnownSymbol$1 = wellKnownSymbol$5;
var createNonEnumerableProperty = createNonEnumerableProperty$4;
var SPECIES = wellKnownSymbol$1('species');
var RegExpPrototype = RegExp.prototype;
var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
var SYMBOL = wellKnownSymbol$1(KEY);
var DELEGATES_TO_SYMBOL = !fails$1(function () {
// String methods call symbol-named RegEp methods
var O = {};
O[SYMBOL] = function () { return 7; };
return ''[KEY](O) != 7;
});
var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$1(function () {
// Symbol-named RegExp methods call .exec
var execCalled = false;
var re = /a/;
if (KEY === 'split') {
// We can't use real regex here since it causes deoptimization
// and serious performance degradation in V8
// https://github.com/zloirock/core-js/issues/306
re = {};
// RegExp[@@split] doesn't call the regex's exec method, but first creates
// a new one. We need to return the patched regex when creating the new one.
re.constructor = {};
re.constructor[SPECIES] = function () { return re; };
re.flags = '';
re[SYMBOL] = /./[SYMBOL];
}
re.exec = function () { execCalled = true; return null; };
re[SYMBOL]('');
return !execCalled;
});
if (
!DELEGATES_TO_SYMBOL ||
!DELEGATES_TO_EXEC ||
FORCED
) {
var nativeRegExpMethod = /./[SYMBOL];
var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
var $exec = regexp.exec;
if ($exec === regexpExec$1 || $exec === RegExpPrototype.exec) {
if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
// The native String method already delegates to @@method (this
// polyfilled function), leasing to infinite recursion.
// We avoid it by directly calling the native @@method method.
return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
}
return { done: true, value: nativeMethod.call(str, regexp, arg2) };
}
return { done: false };
});
redefine(String.prototype, KEY, methods[0]);
redefine(RegExpPrototype, SYMBOL, methods[1]);
}
if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
};
var toIntegerOrInfinity$1 = toIntegerOrInfinity$4;
var toString$1 = toString$3;
var requireObjectCoercible$1 = requireObjectCoercible$4;
var createMethod = function (CONVERT_TO_STRING) {
return function ($this, pos) {
var S = toString$1(requireObjectCoercible$1($this));
var position = toIntegerOrInfinity$1(pos);
var size = S.length;
var first, second;
if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
first = S.charCodeAt(position);
return first < 0xD800 || first > 0xDBFF || position + 1 === size
|| (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
? CONVERT_TO_STRING ? S.charAt(position) : first
: CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
};
};
var stringMultibyte = {
// `String.prototype.codePointAt` method
// https://tc39.es/ecma262/#sec-string.prototype.codepointat
codeAt: createMethod(false),
// `String.prototype.at` method
// https://github.com/mathiasbynens/String.prototype.at
charAt: createMethod(true)
};
var charAt = stringMultibyte.charAt;
// `AdvanceStringIndex` abstract operation
// https://tc39.es/ecma262/#sec-advancestringindex
var advanceStringIndex$1 = function (S, index, unicode) {
return index + (unicode ? charAt(S, index).length : 1);
};
var toObject = toObject$2;
var floor = Math.floor;
var replace = ''.replace;
var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g;
var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g;
// `GetSubstitution` abstract operation
// https://tc39.es/ecma262/#sec-getsubstitution
var getSubstitution$1 = function (matched, str, position, captures, namedCaptures, replacement) {
var tailPos = position + matched.length;
var m = captures.length;
var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
if (namedCaptures !== undefined) {
namedCaptures = toObject(namedCaptures);
symbols = SUBSTITUTION_SYMBOLS;
}
return replace.call(replacement, symbols, function (match, ch) {
var capture;
switch (ch.charAt(0)) {
case '$': return '$';
case '&': return matched;
case '`': return str.slice(0, position);
case "'": return str.slice(tailPos);
case '<':
capture = namedCaptures[ch.slice(1, -1)];
break;
default: // \d\d?
var n = +ch;
if (n === 0) return match;
if (n > m) {
var f = floor(n / 10);
if (f === 0) return match;
if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
return match;
}
capture = captures[n - 1];
}
return capture === undefined ? '' : capture;
});
};
var anObject$1 = anObject$7;
var isCallable$1 = isCallable$c;
var classof = classofRaw$1;
var regexpExec = regexpExec$2;
// `RegExpExec` abstract operation
// https://tc39.es/ecma262/#sec-regexpexec
var regexpExecAbstract = function (R, S) {
var exec = R.exec;
if (isCallable$1(exec)) {
var result = exec.call(R, S);
if (result !== null) anObject$1(result);
return result;
}
if (classof(R) === 'RegExp') return regexpExec.call(R, S);
throw TypeError('RegExp#exec called on incompatible receiver');
};
var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
var fails = fails$a;
var anObject = anObject$7;
var isCallable = isCallable$c;
var toIntegerOrInfinity = toIntegerOrInfinity$4;
var toLength = toLength$2;
var toString = toString$3;
var requireObjectCoercible = requireObjectCoercible$4;
var advanceStringIndex = advanceStringIndex$1;
var getMethod = getMethod$2;
var getSubstitution = getSubstitution$1;
var regExpExec = regexpExecAbstract;
var wellKnownSymbol = wellKnownSymbol$5;
var REPLACE = wellKnownSymbol('replace');
var max = Math.max;
var min = Math.min;
var maybeToString = function (it) {
return it === undefined ? it : String(it);
};
// IE <= 11 replaces $0 with the whole match, as if it was $&
// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
var REPLACE_KEEPS_$0 = (function () {
// eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
return 'a'.replace(/./, '$0') === '$0';
})();
// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
if (/./[REPLACE]) {
return /./[REPLACE]('a', '$0') === '';
}
return false;
})();
var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
var re = /./;
re.exec = function () {
var result = [];
result.groups = { a: '7' };
return result;
};
// eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive
return ''.replace(re, '$<a>') !== '7';
});
// @@replace logic
fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) {
var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
return [
// `String.prototype.replace` method
// https://tc39.es/ecma262/#sec-string.prototype.replace
function replace(searchValue, replaceValue) {
var O = requireObjectCoercible(this);
var replacer = searchValue == undefined ? undefined : getMethod(searchValue, REPLACE);
return replacer
? replacer.call(searchValue, O, replaceValue)
: nativeReplace.call(toString(O), searchValue, replaceValue);
},
// `RegExp.prototype[@@replace]` method
// https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
function (string, replaceValue) {
var rx = anObject(this);
var S = toString(string);
if (
typeof replaceValue === 'string' &&
replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1 &&
replaceValue.indexOf('$<') === -1
) {
var res = maybeCallNative(nativeReplace, rx, S, replaceValue);
if (res.done) return res.value;
}
var functionalReplace = isCallable(replaceValue);
if (!functionalReplace) replaceValue = toString(replaceValue);
var global = rx.global;
if (global) {
var fullUnicode = rx.unicode;
rx.lastIndex = 0;
}
var results = [];
while (true) {
var result = regExpExec(rx, S);
if (result === null) break;
results.push(result);
if (!global) break;
var matchStr = toString(result[0]);
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
}
var accumulatedResult = '';
var nextSourcePosition = 0;
for (var i = 0; i < results.length; i++) {
result = results[i];
var matched = toString(result[0]);
var position = max(min(toIntegerOrInfinity(result.index), S.length), 0);
var captures = [];
// NOTE: This is equivalent to
// captures = result.slice(1).map(maybeToString)
// but for some reason `nativeSlice.call(result, 1, result.length)` (called in
// the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
// causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
var namedCaptures = result.groups;
if (functionalReplace) {
var replacerArgs = [matched].concat(captures, position, S);
if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
var replacement = toString(replaceValue.apply(undefined, replacerArgs));
} else {
replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
}
if (position >= nextSourcePosition) {
accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
nextSourcePosition = position + matched.length;
}
}
return accumulatedResult + S.slice(nextSourcePosition);
}
];
}, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);
const extStoragePrefix = "added_juejin_extension_"; // const marketplaceURL = "http://localhost:3000";
const marketplaceURL = "https://juejin-enhancer-extensions.vercel.app";
const isIExtension = object => {
return !!object && typeof object["slug"] === "string" && typeof object["version"] === "string" && typeof object["code"] === "string" && typeof object["url"] === "string";
};
const saveToStorage = (name, extension, isLocal) => {
GM_setValue(extStoragePrefix + `${isLocal ? "local_" : ""}` + name, extension);
};
const removeFromStorage = name => {
GM_deleteValue(extStoragePrefix + name);
};
const removeAllLocalExtensions = () => {
try {
const allLocalExtension = GM_listValues().filter(key => key.startsWith(extStoragePrefix + "local_"));
allLocalExtension.forEach(GM_deleteValue);
return "success";
} catch (e) {
return "error";
}
};
const removeAllExtensions = () => {
try {
const allExtension = GM_listValues().filter(key => key.startsWith(extStoragePrefix));
allExtension.forEach(GM_deleteValue);
return "success";
} catch (e) {
return "error";
}
};
const queryExtension = name => {
return GM_getValue(extStoragePrefix + name) || GM_getValue(extStoragePrefix + "local_" + name);
};
const listAllExtension = () => {
return GM_listValues().filter(key => key.startsWith(extStoragePrefix) && !key.startsWith(extStoragePrefix + "local_")).map(key => key.replace(new RegExp("^" + extStoragePrefix), ""));
};
const cleanDataCaches = () => {
GM_listValues().filter(key => !key.startsWith(extStoragePrefix)).forEach(key => GM_deleteValue(key));
};
const fetchPlugin = url => {
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url,
onload({
status,
response
}) {
if (status === 200) {
try {
resolve(response);
} catch (error) {
reject(error);
}
} else {
reject("error");
}
},
onerror(e) {
reject("request_error");
},
onabort() {
reject("aborted");
}
});
});
};
function installExtension(slug, url, version) {
return fetchPlugin(url).then(code => {
saveToStorage(slug, {
slug,
version,
code,
url
});
});
}
const plugins = restoreFromStorage();
function restoreFromStorage() {
const allStoragePlugins = GM_listValues().filter(key => key.startsWith(extStoragePrefix));
return allStoragePlugins.map(key => GM_getValue(key, null)).filter(isIExtension).map(({
slug,
code
}) => {
return executePlugin(slug, code);
}).filter(({
plugin
}) => {
return plugin && !(plugin !== null && plugin !== void 0 && plugin.isOffShelf);
});
}
function executePlugin(name, code) {
try {
const plugin = eval(code);
return {
name,
plugin
};
} catch (e) {
console.log(name, code);
return {
name,
plugin: null
};
}
}
function launchMarketplace() {
unsafeWindow.onAddLocalJuejinExtension = (filePath, code) => {
try {
const extension = {
slug: filePath,
version: "0.0.0",
code,
url: filePath
};
saveToStorage(filePath, extension, true);
return "success";
} catch (e) {
return "error";
}
};
unsafeWindow.onRemoveLocalJuejinExtension = () => {
try {
removeAllLocalExtensions();
return "success";
} catch (e) {
if (e instanceof Error) {
return "error:" + e.message;
} else {
return "error";
}
}
};
unsafeWindow.onAddJuejinExtension = (slug, {
url,
version
}) => {
return installExtension(slug, url, version).then(() => {
return "success";
}).catch(e => {
return "error:" + e.message;
});
};
unsafeWindow.onRemoveJuejinExtension = slug => {
return new Promise((resolve, reject) => {
try {
removeFromStorage(slug);
resolve("success");
} catch (e) {
reject("error");
}
});
};
unsafeWindow.checkJuejinExtension = (slug, version) => {
const extension = queryExtension(slug);
if (!extension) {
return {
added: false,
update: false
};
} else {
return {
added: true,
update: version !== extension.version
};
}
};
unsafeWindow.cleanExtensionDataCaches = () => {
try {
cleanDataCaches();
return "success";
} catch (e) {
return "error";
}
};
}
function launchJuejin() {
console.log($);
plugins.forEach(({
plugin
}) => {
var _plugin$onLoaded;
plugin === null || plugin === void 0 ? void 0 : (_plugin$onLoaded = plugin.onLoaded) === null || _plugin$onLoaded === void 0 ? void 0 : _plugin$onLoaded.call(plugin);
});
initRouter();
function initRouter() {
let currentRouterPathname = "";
function onRouteChange() {
const prevRouterPathname = currentRouterPathname;
currentRouterPathname = document.location.pathname;
if (prevRouterPathname !== currentRouterPathname) {
plugins.forEach(({
plugin
}) => {
var _plugin$onRouteChange;
plugin === null || plugin === void 0 ? void 0 : (_plugin$onRouteChange = plugin.onRouteChange) === null || _plugin$onRouteChange === void 0 ? void 0 : _plugin$onRouteChange.call(plugin, prevRouterPathname, currentRouterPathname);
});
}
}
const _historyPushState = history.pushState;
const _historyReplaceState = history.replaceState;
history.pushState = function (...rest) {
_historyPushState.apply(history, rest);
onRouteChange();
};
history.replaceState = function (...rest) {
_historyReplaceState.apply(history, rest);
onRouteChange();
};
window.addEventListener("popstate", function () {
onRouteChange();
});
}
}
function initMenu() {
GM_registerMenuCommand("扩展市场", () => {
GM_openInTab(marketplaceURL, {
active: true
});
});
GM_registerMenuCommand("手动添加扩展", () => {
const url = window.prompt("输入可访问链接");
if (url) {
installExtension(url, url, "0.0.0").then(() => {
window.alert("添加成功");
}).catch(() => {
window.alert("添加失败");
});
}
});
GM_registerMenuCommand("移除所有扩展", () => {
removeAllExtensions();
});
}
function autoCheckExtension() {
const duration = 30 * 60 * 1000;
const allExtensions = listAllExtension();
const lastCheckTime = GM_getValue("update_check", 0);
const isTimeToCheck = new Date().valueOf() - lastCheckTime > duration;
if (allExtensions.length > 0 && isTimeToCheck) {
GM_setValue("update_check", new Date().valueOf());
GM_xmlhttpRequest({
method: "POST",
url: `${marketplaceURL}/api/check`,
headers: {
"content-type": "application/json"
},
data: JSON.stringify({
slugs: allExtensions
}),
responseType: "json",
onload({
status,
response
}) {
if (status === 200) {
response.updated.forEach(({
slug,
rawURL,
version
}) => {
const localExt = queryExtension(slug);
if ((localExt === null || localExt === void 0 ? void 0 : localExt.version) !== version || localExt.url !== rawURL) {
installExtension(slug, rawURL, version);
}
});
response.deleted.forEach(slug => {
removeFromStorage(slug);
});
}
}
});
}
setTimeout(() => {
autoCheckExtension();
}, duration);
}
async function preInstallExtension() {
if (!GM_getValue("activated", false)) {
await installExtension("juejin-post-tracker", "https://gitee.com/curlly-brackets/juejin-post-tracker/raw/main/main.user.js", "0.0.1");
GM_setValue("activated", true);
}
}
(async function start() {
initMenu();
await preInstallExtension();
autoCheckExtension();
if (location.host === "juejin.cn") {
launchJuejin();
} else if (location.origin === marketplaceURL) {
launchMarketplace();
}
})();
})();