Greasy Fork is available in English.
bilibili免登录,看高清直播,看高清视频,随时看所有评论。观看历史记录,收藏功能正在支持中,欢迎来给项目star和pr!通过拦截一些特定 Bilibili 接口请求或响应,让你的体验能够像登录用户一样丝滑!
// ==UserScript== // @name 哔哩免登录看评论+1080p视频+免弹窗 // @namespace vruses // @version 2.2.2 // @author <[email protected]> // @description bilibili免登录,看高清直播,看高清视频,随时看所有评论。观看历史记录,收藏功能正在支持中,欢迎来给项目star和pr!通过拦截一些特定 Bilibili 接口请求或响应,让你的体验能够像登录用户一样丝滑! // @license MIT // @icon data:image/jpeg;base64,AAAAHGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZgAAAOptZXRhAAAAAAAAACFoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAAAAAAA5waXRtAAAAAAABAAAAImlsb2MAAAAAREAAAQABAAAAAAEOAAEAAAAAAAAF6wAAACNpaW5mAAAAAAABAAAAFWluZmUCAAAAAAEAAGF2MDEAAAAAamlwcnAAAABLaXBjbwAAABNjb2xybmNseAABAA0ABoAAAAAMYXYxQ4EADAAAAAAUaXNwZQAAAAAAAADwAAAA8AAAABBwaXhpAAAAAAMICAgAAAAXaXBtYQAAAAAAAAABAAEEAYIDBAAABfNtZGF0EgAKChgd+/vYICGg0IAy2gtEgACiiihQtIDqrkvPF1l+b90DLzEPNo7jbm8MUMGGUuKslo1owZD1WKBRgQ/2f406AlN00FgeyTrTTgl2N3L2WtrdDuFrTP1h/Nj/y8vB30i3CyIM1dTrmSCUOgVaFhBiXR2FxcZJOI9yBw/GBIZZ5KdPQafrWOAFWYuhbVmQSBwGnqsRBA76x+yeYrO4V2yLQ6OnFqpyZ9mIuhOlS/TePUfELDQ55lN1pmnFx58An5dtTY6L9N7ew5/j4LZnle2loske4Sld/QT6tT09zRcfCjsLSgX6J17LA4EpWo7Fd8ZA7+4FTZ5kICFXPMkitgbgMmPX9FksaV4I3oRT0gc5P/OQAwTb80beqnROrknzLfvadRXOc3jL5XXFt9xrGs5SyYmSqsvJJhGYhn+DeFM2qs1eh5iryQJVkIxmgRBn5HL/3CQfVPjCEw8x9jIduTsWlhUXXGOZFxIN6dFW1x+gLex+dFcUxA62vGuVLSqynO5qUrRIWlDowhE0CvocZsAm6m+bESQ9lx2myX665hAXO8FQtYXXVjUtmFyR5cB56kzFS50iigWSMzYFpqQUDI0ubvn891dbuwf0Env9w7tMiWbT7rBdkLNb/X/l6Q/zMzOlpTSyKn0GklbBr5yismlx5IWFn/p5+idowJyI7yk14X/Q3sq9ypkVrkTerhgjYf7gIAcdSsmJOHvwquxc222exmrpl5CubUT+tVh3S+j3XptKG+gdgXXGeTiwcpqq3aydRD3IEz1Fer514wFvs1iu2s4A1Bjb9vNBf3p/zvsyoAQGhwWunOZGJcEV2BgOZXb9HQsqUP/S0UV4yeWxZOLmO8OExFk+QTe1ieKha5J9+G9xX1uX3k5GgLchVEKjSVR9KVYftuY4ipGHFxlTtwN9igRt/kNJnmXUBXSC/zONSU18J2o8cVBETIGNpzwzetj9XG0Y0sXhjmUz95zo1h6Gqm91lIyYau6f8zEBRucpsiY4rESvn8QtCGUuzd2MmqVpSjI6vmS6DBqp8Te6lwdT40tTJiYI7AVcdZIMuAMW60/UqXwnwv490LrLg1lrrgK0LSkMjlTCEIVr3dO14WtF1aUEKFKklL7PPVouB+IGsMRE958I4TITUbZ4s2CYKn9C+JDog+MszzWF9NZ0ZYIjFgML2a1ma8IlGPXEWOGbEbWt/DU6NOwVQZ3GFXQs8zvF2QE+2+mZEuB6XFvg5STbTRaWSNkZDZAK79Hk5UH/t2/9BhJr3q2IuYFqDw6To2Clf0rA3dSg4ebYAi4JKnJrz/NTJ/eWI35B+Z312mZuGr+EwS7pvQyJiIa2rWdmfeFoSKcxtLe/eHH2ZBq6Ye/+3/dDhsBEMg1JZrwEGvTs3hf0qNZKdaaLpEdRx2gmyPgtnesn4BfNXD0oko7NbxtjsRtk6nQAKCl/Np5DPLz2FHs52M+JlBPd12AES58muiDS6lWRNq4f9nnvFL2ShZQCc9HooGBfCpOFcpugDer0/kyHJJTfja8rOJobIu/BTUd17QOqEnnULMa2GZlo/KYjzPAvVtle9AZC3DCU4Z1JHIXIR8TWrTe9a7HA8tccL+0V1oFZQUHbygW2oVqLnVGxJOoROhQJ8/OMD/R/j8gOceE+M29bxFRFhYMwsPUrm79cj/sOQ6hhVCEClGfK+Of3ILxjlwfwN2O5UF28QIYG4DDFIpaH2jvSv4EDgQnbCvV8Fi9DTk5BW47JBaZv40VBrBoGEoZnJA0VokU2hnT6cuGhW8PuDc+AWNocs29yOBfvxmP/BVx35a85olXPGeQWzAgPub5F2OPrv5FNP4nbeuDC/rMdhtRDL+5q7EPBy6mHCLeqq7huUV9QIwmELMLKLo2btWstDirvPzfxSCPhacfJjTi4aXc8/e5sR//+KJusEYHymIEhSKEiPqT+WnBTgB1m747UE1HuldvkPt8ap87oSEALbQhf1wiaLRYDSxxXFt/bh/Ozu02nZN2Sk3eJ20LA9w3cUZpk // @homepage https://github.com/vruses/beefreely // @source https://github.com/vruses/beefreely.git // @supportURL https://github.com/vruses/beefreely // @match *://*.bilibili.com/* // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/protobuf.min.js // @require https://cdn.jsdelivr.net/npm/@vue/[email protected]/dist/reactivity.global.min.js // @grant none // @run-at document-start // ==/UserScript== (function (reactivity, protobuf) { 'use strict'; var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); var require_main_001 = __commonJS({ "main-C-O_IPuk.js"(exports, module) { var _a; var freeGlobal = typeof global == "object" && global && global.Object === Object && global; var freeSelf = typeof self == "object" && self && self.Object === Object && self; var root = freeGlobal || freeSelf || Function("return this")(); var Symbol$1 = root.Symbol; var objectProto$b = Object.prototype; var hasOwnProperty$8 = objectProto$b.hasOwnProperty; var nativeObjectToString$1 = objectProto$b.toString; var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : void 0; function getRawTag(value) { var isOwn = hasOwnProperty$8.call(value, symToStringTag$1), tag = value[symToStringTag$1]; try { value[symToStringTag$1] = void 0; var unmasked = true; } catch (e) { } var result = nativeObjectToString$1.call(value); if (unmasked) { if (isOwn) { value[symToStringTag$1] = tag; } else { delete value[symToStringTag$1]; } } return result; } var objectProto$a = Object.prototype; var nativeObjectToString = objectProto$a.toString; function objectToString(value) { return nativeObjectToString.call(value); } var nullTag = "[object Null]", undefinedTag = "[object Undefined]"; var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0; function baseGetTag(value) { if (value == null) { return value === void 0 ? undefinedTag : nullTag; } return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); } function isObjectLike(value) { return value != null && typeof value == "object"; } var symbolTag$1 = "[object Symbol]"; function isSymbol(value) { return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag$1; } function arrayMap(array, iteratee) { var index = -1, length = array == null ? 0 : array.length, result = Array(length); while (++index < length) { result[index] = iteratee(array[index], index, array); } return result; } var isArray = Array.isArray; var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto$1 ? symbolProto$1.toString : void 0; function baseToString(value) { if (typeof value == "string") { return value; } if (isArray(value)) { return arrayMap(value, baseToString) + ""; } if (isSymbol(value)) { return symbolToString ? symbolToString.call(value) : ""; } var result = value + ""; return result == "0" && 1 / value == -Infinity ? "-0" : result; } var reWhitespace = /\s/; function trimmedEndIndex(string) { var index = string.length; while (index-- && reWhitespace.test(string.charAt(index))) { } return index; } var reTrimStart = /^\s+/; function baseTrim(string) { return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string; } function isObject(value) { var type = typeof value; return value != null && (type == "object" || type == "function"); } var NAN = 0 / 0; var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; var reIsBinary = /^0b[01]+$/i; var reIsOctal = /^0o[0-7]+$/i; var freeParseInt = parseInt; function toNumber(value) { if (typeof value == "number") { return value; } if (isSymbol(value)) { return NAN; } if (isObject(value)) { var other = typeof value.valueOf == "function" ? value.valueOf() : value; value = isObject(other) ? other + "" : other; } if (typeof value != "string") { return value === 0 ? value : +value; } value = baseTrim(value); var isBinary = reIsBinary.test(value); return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; } var INFINITY = 1 / 0, MAX_INTEGER = 17976931348623157e292; function toFinite(value) { if (!value) { return value === 0 ? value : 0; } value = toNumber(value); if (value === INFINITY || value === -INFINITY) { var sign = value < 0 ? -1 : 1; return sign * MAX_INTEGER; } return value === value ? value : 0; } function identity(value) { return value; } var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]"; function isFunction(value) { if (!isObject(value)) { return false; } var tag = baseGetTag(value); return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag; } var coreJsData = root["__core-js_shared__"]; var maskSrcKey = (function() { var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ""); return uid ? "Symbol(src)_1." + uid : ""; })(); function isMasked(func) { return !!maskSrcKey && maskSrcKey in func; } var funcProto$1 = Function.prototype; var funcToString$1 = funcProto$1.toString; function toSource(func) { if (func != null) { try { return funcToString$1.call(func); } catch (e) { } try { return func + ""; } catch (e) { } } return ""; } var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; var reIsHostCtor = /^\[object .+?Constructor\]$/; var funcProto = Function.prototype, objectProto$9 = Object.prototype; var funcToString = funcProto.toString; var hasOwnProperty$7 = objectProto$9.hasOwnProperty; var reIsNative = RegExp( "^" + funcToString.call(hasOwnProperty$7).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" ); function baseIsNative(value) { if (!isObject(value) || isMasked(value)) { return false; } var pattern = isFunction(value) ? reIsNative : reIsHostCtor; return pattern.test(toSource(value)); } function getValue(object, key) { return object == null ? void 0 : object[key]; } function getNative(object, key) { var value = getValue(object, key); return baseIsNative(value) ? value : void 0; } var WeakMap = getNative(root, "WeakMap"); var defineProperty = (function() { try { var func = getNative(Object, "defineProperty"); func({}, "", {}); return func; } catch (e) { } })(); var MAX_SAFE_INTEGER$1 = 9007199254740991; var reIsUint = /^(?:0|[1-9]\d*)$/; function isIndex(value, length) { var type = typeof value; length = length == null ? MAX_SAFE_INTEGER$1 : length; return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); } function baseAssignValue(object, key, value) { if (key == "__proto__" && defineProperty) { defineProperty(object, key, { "configurable": true, "enumerable": true, "value": value, "writable": true }); } else { object[key] = value; } } function eq(value, other) { return value === other || value !== value && other !== other; } var MAX_SAFE_INTEGER = 9007199254740991; function isLength(value) { return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } function isArrayLike(value) { return value != null && isLength(value.length) && !isFunction(value); } function isIterateeCall(value, index, object) { if (!isObject(object)) { return false; } var type = typeof index; if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) { return eq(object[index], value); } return false; } var objectProto$8 = Object.prototype; function isPrototype(value) { var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$8; return value === proto; } function baseTimes(n, iteratee) { var index = -1, result = Array(n); while (++index < n) { result[index] = iteratee(index); } return result; } var argsTag$2 = "[object Arguments]"; function baseIsArguments(value) { return isObjectLike(value) && baseGetTag(value) == argsTag$2; } var objectProto$7 = Object.prototype; var hasOwnProperty$6 = objectProto$7.hasOwnProperty; var propertyIsEnumerable$1 = objectProto$7.propertyIsEnumerable; var isArguments = baseIsArguments(/* @__PURE__ */ (function() { return arguments; })()) ? baseIsArguments : function(value) { return isObjectLike(value) && hasOwnProperty$6.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee"); }; function stubFalse() { return false; } var freeExports$1 = typeof exports == "object" && exports && !exports.nodeType && exports; var freeModule$1 = freeExports$1 && typeof module == "object" && module && !module.nodeType && module; var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1; var Buffer2 = moduleExports$1 ? root.Buffer : void 0; var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0; var isBuffer = nativeIsBuffer || stubFalse; var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", errorTag$1 = "[object Error]", funcTag = "[object Function]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", objectTag$2 = "[object Object]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", weakMapTag$1 = "[object WeakMap]"; var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$2 = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]"; var typedArrayTags = {}; typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false; function baseIsTypedArray(value) { return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; } function baseUnary(func) { return function(value) { return func(value); }; } var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports; var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module; var moduleExports = freeModule && freeModule.exports === freeExports; var freeProcess = moduleExports && freeGlobal.process; var nodeUtil = (function() { try { var types = freeModule && freeModule.require && freeModule.require("util").types; if (types) { return types; } return freeProcess && freeProcess.binding && freeProcess.binding("util"); } catch (e) { } })(); var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; var objectProto$6 = Object.prototype; var hasOwnProperty$5 = objectProto$6.hasOwnProperty; function arrayLikeKeys(value, inherited) { var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; for (var key in value) { if (hasOwnProperty$5.call(value, key) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. isIndex(key, length)))) { result.push(key); } } return result; } function overArg(func, transform) { return function(arg) { return func(transform(arg)); }; } var nativeKeys = overArg(Object.keys, Object); var objectProto$5 = Object.prototype; var hasOwnProperty$4 = objectProto$5.hasOwnProperty; function baseKeys(object) { if (!isPrototype(object)) { return nativeKeys(object); } var result = []; for (var key in Object(object)) { if (hasOwnProperty$4.call(object, key) && key != "constructor") { result.push(key); } } return result; } function keys(object) { return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/; function isKey(value, object) { if (isArray(value)) { return false; } var type = typeof value; if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) { return true; } return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object); } var nativeCreate = getNative(Object, "create"); function hashClear() { this.__data__ = nativeCreate ? nativeCreate(null) : {}; this.size = 0; } function hashDelete(key) { var result = this.has(key) && delete this.__data__[key]; this.size -= result ? 1 : 0; return result; } var HASH_UNDEFINED$2 = "__lodash_hash_undefined__"; var objectProto$4 = Object.prototype; var hasOwnProperty$3 = objectProto$4.hasOwnProperty; function hashGet(key) { var data = this.__data__; if (nativeCreate) { var result = data[key]; return result === HASH_UNDEFINED$2 ? void 0 : result; } return hasOwnProperty$3.call(data, key) ? data[key] : void 0; } var objectProto$3 = Object.prototype; var hasOwnProperty$2 = objectProto$3.hasOwnProperty; function hashHas(key) { var data = this.__data__; return nativeCreate ? data[key] !== void 0 : hasOwnProperty$2.call(data, key); } var HASH_UNDEFINED$1 = "__lodash_hash_undefined__"; function hashSet(key, value) { var data = this.__data__; this.size += this.has(key) ? 0 : 1; data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED$1 : value; return this; } function Hash(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } Hash.prototype.clear = hashClear; Hash.prototype["delete"] = hashDelete; Hash.prototype.get = hashGet; Hash.prototype.has = hashHas; Hash.prototype.set = hashSet; function listCacheClear() { this.__data__ = []; this.size = 0; } function assocIndexOf(array, key) { var length = array.length; while (length--) { if (eq(array[length][0], key)) { return length; } } return -1; } var arrayProto = Array.prototype; var splice = arrayProto.splice; function listCacheDelete(key) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { return false; } var lastIndex = data.length - 1; if (index == lastIndex) { data.pop(); } else { splice.call(data, index, 1); } --this.size; return true; } function listCacheGet(key) { var data = this.__data__, index = assocIndexOf(data, key); return index < 0 ? void 0 : data[index][1]; } function listCacheHas(key) { return assocIndexOf(this.__data__, key) > -1; } function listCacheSet(key, value) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { ++this.size; data.push([key, value]); } else { data[index][1] = value; } return this; } function ListCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } ListCache.prototype.clear = listCacheClear; ListCache.prototype["delete"] = listCacheDelete; ListCache.prototype.get = listCacheGet; ListCache.prototype.has = listCacheHas; ListCache.prototype.set = listCacheSet; var Map = getNative(root, "Map"); function mapCacheClear() { this.size = 0; this.__data__ = { "hash": new Hash(), "map": new (Map || ListCache)(), "string": new Hash() }; } function isKeyable(value) { var type = typeof value; return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null; } function getMapData(map, key) { var data = map.__data__; return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; } function mapCacheDelete(key) { var result = getMapData(this, key)["delete"](key); this.size -= result ? 1 : 0; return result; } function mapCacheGet(key) { return getMapData(this, key).get(key); } function mapCacheHas(key) { return getMapData(this, key).has(key); } function mapCacheSet(key, value) { var data = getMapData(this, key), size = data.size; data.set(key, value); this.size += data.size == size ? 0 : 1; return this; } function MapCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } MapCache.prototype.clear = mapCacheClear; MapCache.prototype["delete"] = mapCacheDelete; MapCache.prototype.get = mapCacheGet; MapCache.prototype.has = mapCacheHas; MapCache.prototype.set = mapCacheSet; var FUNC_ERROR_TEXT = "Expected a function"; function memoize(func, resolver) { if (typeof func != "function" || resolver != null && typeof resolver != "function") { throw new TypeError(FUNC_ERROR_TEXT); } var memoized = function() { var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache; if (cache.has(key)) { return cache.get(key); } var result = func.apply(this, args); memoized.cache = cache.set(key, result) || cache; return result; }; memoized.cache = new (memoize.Cache || MapCache)(); return memoized; } memoize.Cache = MapCache; var MAX_MEMOIZE_SIZE = 500; function memoizeCapped(func) { var result = memoize(func, function(key) { if (cache.size === MAX_MEMOIZE_SIZE) { cache.clear(); } return key; }); var cache = result.cache; return result; } var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; var reEscapeChar = /\\(\\)?/g; var stringToPath = memoizeCapped(function(string) { var result = []; if (string.charCodeAt(0) === 46) { result.push(""); } string.replace(rePropName, function(match, number, quote, subString) { result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match); }); return result; }); function toString(value) { return value == null ? "" : baseToString(value); } function castPath(value, object) { if (isArray(value)) { return value; } return isKey(value, object) ? [value] : stringToPath(toString(value)); } function toKey(value) { if (typeof value == "string" || isSymbol(value)) { return value; } var result = value + ""; return result == "0" && 1 / value == -Infinity ? "-0" : result; } function baseGet(object, path) { path = castPath(path, object); var index = 0, length = path.length; while (object != null && index < length) { object = object[toKey(path[index++])]; } return index && index == length ? object : void 0; } function get(object, path, defaultValue) { var result = object == null ? void 0 : baseGet(object, path); return result === void 0 ? defaultValue : result; } function arrayPush(array, values) { var index = -1, length = values.length, offset = array.length; while (++index < length) { array[offset + index] = values[index]; } return array; } function baseSlice(array, start2, end) { var index = -1, length = array.length; if (start2 < 0) { start2 = -start2 > length ? 0 : length + start2; } end = end > length ? length : end; if (end < 0) { end += length; } length = start2 > end ? 0 : end - start2 >>> 0; start2 >>>= 0; var result = Array(length); while (++index < length) { result[index] = array[index + start2]; } return result; } function castSlice(array, start2, end) { var length = array.length; end = end === void 0 ? length : end; return !start2 && end >= length ? array : baseSlice(array, start2, end); } var rsAstralRange$2 = "\\ud800-\\udfff", rsComboMarksRange$3 = "\\u0300-\\u036f", reComboHalfMarksRange$3 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$3 = "\\u20d0-\\u20ff", rsComboRange$3 = rsComboMarksRange$3 + reComboHalfMarksRange$3 + rsComboSymbolsRange$3, rsVarRange$2 = "\\ufe0e\\ufe0f"; var rsZWJ$2 = "\\u200d"; var reHasUnicode = RegExp("[" + rsZWJ$2 + rsAstralRange$2 + rsComboRange$3 + rsVarRange$2 + "]"); function hasUnicode(string) { return reHasUnicode.test(string); } function asciiToArray(string) { return string.split(""); } var rsAstralRange$1 = "\\ud800-\\udfff", rsComboMarksRange$2 = "\\u0300-\\u036f", reComboHalfMarksRange$2 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$2 = "\\u20d0-\\u20ff", rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2, rsVarRange$1 = "\\ufe0e\\ufe0f"; var rsAstral = "[" + rsAstralRange$1 + "]", rsCombo$2 = "[" + rsComboRange$2 + "]", rsFitz$1 = "\\ud83c[\\udffb-\\udfff]", rsModifier$1 = "(?:" + rsCombo$2 + "|" + rsFitz$1 + ")", rsNonAstral$1 = "[^" + rsAstralRange$1 + "]", rsRegional$1 = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair$1 = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsZWJ$1 = "\\u200d"; var reOptMod$1 = rsModifier$1 + "?", rsOptVar$1 = "[" + rsVarRange$1 + "]?", rsOptJoin$1 = "(?:" + rsZWJ$1 + "(?:" + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join("|") + ")" + rsOptVar$1 + reOptMod$1 + ")*", rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1, rsSymbol = "(?:" + [rsNonAstral$1 + rsCombo$2 + "?", rsCombo$2, rsRegional$1, rsSurrPair$1, rsAstral].join("|") + ")"; var reUnicode = RegExp(rsFitz$1 + "(?=" + rsFitz$1 + ")|" + rsSymbol + rsSeq$1, "g"); function unicodeToArray(string) { return string.match(reUnicode) || []; } function stringToArray(string) { return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string); } function createCaseFirst(methodName) { return function(string) { string = toString(string); var strSymbols = hasUnicode(string) ? stringToArray(string) : void 0; var chr = strSymbols ? strSymbols[0] : string.charAt(0); var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string.slice(1); return chr[methodName]() + trailing; }; } var upperFirst = createCaseFirst("toUpperCase"); function capitalize(string) { return upperFirst(toString(string).toLowerCase()); } function arrayReduce(array, iteratee, accumulator, initAccum) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { accumulator = iteratee(accumulator, array[index], index, array); } return accumulator; } function basePropertyOf(object) { return function(key) { return object == null ? void 0 : object[key]; }; } var deburredLetters = { // Latin-1 Supplement block. "À": "A", "Á": "A", "Â": "A", "Ã": "A", "Ä": "A", "Å": "A", "à": "a", "á": "a", "â": "a", "ã": "a", "ä": "a", "å": "a", "Ç": "C", "ç": "c", "Ð": "D", "ð": "d", "È": "E", "É": "E", "Ê": "E", "Ë": "E", "è": "e", "é": "e", "ê": "e", "ë": "e", "Ì": "I", "Í": "I", "Î": "I", "Ï": "I", "ì": "i", "í": "i", "î": "i", "ï": "i", "Ñ": "N", "ñ": "n", "Ò": "O", "Ó": "O", "Ô": "O", "Õ": "O", "Ö": "O", "Ø": "O", "ò": "o", "ó": "o", "ô": "o", "õ": "o", "ö": "o", "ø": "o", "Ù": "U", "Ú": "U", "Û": "U", "Ü": "U", "ù": "u", "ú": "u", "û": "u", "ü": "u", "Ý": "Y", "ý": "y", "ÿ": "y", "Æ": "Ae", "æ": "ae", "Þ": "Th", "þ": "th", "ß": "ss", // Latin Extended-A block. "Ā": "A", "Ă": "A", "Ą": "A", "ā": "a", "ă": "a", "ą": "a", "Ć": "C", "Ĉ": "C", "Ċ": "C", "Č": "C", "ć": "c", "ĉ": "c", "ċ": "c", "č": "c", "Ď": "D", "Đ": "D", "ď": "d", "đ": "d", "Ē": "E", "Ĕ": "E", "Ė": "E", "Ę": "E", "Ě": "E", "ē": "e", "ĕ": "e", "ė": "e", "ę": "e", "ě": "e", "Ĝ": "G", "Ğ": "G", "Ġ": "G", "Ģ": "G", "ĝ": "g", "ğ": "g", "ġ": "g", "ģ": "g", "Ĥ": "H", "Ħ": "H", "ĥ": "h", "ħ": "h", "Ĩ": "I", "Ī": "I", "Ĭ": "I", "Į": "I", "İ": "I", "ĩ": "i", "ī": "i", "ĭ": "i", "į": "i", "ı": "i", "Ĵ": "J", "ĵ": "j", "Ķ": "K", "ķ": "k", "ĸ": "k", "Ĺ": "L", "Ļ": "L", "Ľ": "L", "Ŀ": "L", "Ł": "L", "ĺ": "l", "ļ": "l", "ľ": "l", "ŀ": "l", "ł": "l", "Ń": "N", "Ņ": "N", "Ň": "N", "Ŋ": "N", "ń": "n", "ņ": "n", "ň": "n", "ŋ": "n", "Ō": "O", "Ŏ": "O", "Ő": "O", "ō": "o", "ŏ": "o", "ő": "o", "Ŕ": "R", "Ŗ": "R", "Ř": "R", "ŕ": "r", "ŗ": "r", "ř": "r", "Ś": "S", "Ŝ": "S", "Ş": "S", "Š": "S", "ś": "s", "ŝ": "s", "ş": "s", "š": "s", "Ţ": "T", "Ť": "T", "Ŧ": "T", "ţ": "t", "ť": "t", "ŧ": "t", "Ũ": "U", "Ū": "U", "Ŭ": "U", "Ů": "U", "Ű": "U", "Ų": "U", "ũ": "u", "ū": "u", "ŭ": "u", "ů": "u", "ű": "u", "ų": "u", "Ŵ": "W", "ŵ": "w", "Ŷ": "Y", "ŷ": "y", "Ÿ": "Y", "Ź": "Z", "Ż": "Z", "Ž": "Z", "ź": "z", "ż": "z", "ž": "z", "IJ": "IJ", "ij": "ij", "Œ": "Oe", "œ": "oe", "ʼn": "'n", "ſ": "s" }; var deburrLetter = basePropertyOf(deburredLetters); var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; var rsComboMarksRange$1 = "\\u0300-\\u036f", reComboHalfMarksRange$1 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$1 = "\\u20d0-\\u20ff", rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1; var rsCombo$1 = "[" + rsComboRange$1 + "]"; var reComboMark = RegExp(rsCombo$1, "g"); function deburr(string) { string = toString(string); return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ""); } var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; function asciiWords(string) { return string.match(reAsciiWord) || []; } var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; function hasUnicodeWord(string) { return reHasUnicodeWord.test(string); } var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsDingbatRange = "\\u2700-\\u27bf", rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff", rsMathOpRange = "\\xac\\xb1\\xd7\\xf7", rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", rsPunctuationRange = "\\u2000-\\u206f", rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde", rsVarRange = "\\ufe0e\\ufe0f", rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; var rsApos$1 = "['’]", rsBreak = "[" + rsBreakRange + "]", rsCombo = "[" + rsComboRange + "]", rsDigits = "\\d+", rsDingbat = "[" + rsDingbatRange + "]", rsLower = "[" + rsLowerRange + "]", rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsUpper = "[" + rsUpperRange + "]", rsZWJ = "\\u200d"; var rsMiscLower = "(?:" + rsLower + "|" + rsMisc + ")", rsMiscUpper = "(?:" + rsUpper + "|" + rsMisc + ")", rsOptContrLower = "(?:" + rsApos$1 + "(?:d|ll|m|re|s|t|ve))?", rsOptContrUpper = "(?:" + rsApos$1 + "(?:D|LL|M|RE|S|T|VE))?", reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsOrdLower = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", rsOrdUpper = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsEmoji = "(?:" + [rsDingbat, rsRegional, rsSurrPair].join("|") + ")" + rsSeq; var reUnicodeWord = RegExp([ rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")", rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [rsBreak, rsUpper + rsMiscLower, "$"].join("|") + ")", rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower, rsUpper + "+" + rsOptContrUpper, rsOrdUpper, rsOrdLower, rsDigits, rsEmoji ].join("|"), "g"); function unicodeWords(string) { return string.match(reUnicodeWord) || []; } function words(string, pattern, guard) { string = toString(string); pattern = pattern; if (pattern === void 0) { return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); } return string.match(pattern) || []; } var rsApos = "['’]"; var reApos = RegExp(rsApos, "g"); function createCompounder(callback) { return function(string) { return arrayReduce(words(deburr(string).replace(reApos, "")), callback, ""); }; } var camelCase = createCompounder(function(result, word, index) { word = word.toLowerCase(); return result + (index ? capitalize(word) : word); }); function stackClear() { this.__data__ = new ListCache(); this.size = 0; } function stackDelete(key) { var data = this.__data__, result = data["delete"](key); this.size = data.size; return result; } function stackGet(key) { return this.__data__.get(key); } function stackHas(key) { return this.__data__.has(key); } var LARGE_ARRAY_SIZE = 200; function stackSet(key, value) { var data = this.__data__; if (data instanceof ListCache) { var pairs = data.__data__; if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) { pairs.push([key, value]); this.size = ++data.size; return this; } data = this.__data__ = new MapCache(pairs); } data.set(key, value); this.size = data.size; return this; } function Stack(entries) { var data = this.__data__ = new ListCache(entries); this.size = data.size; } Stack.prototype.clear = stackClear; Stack.prototype["delete"] = stackDelete; Stack.prototype.get = stackGet; Stack.prototype.has = stackHas; Stack.prototype.set = stackSet; function arrayFilter(array, predicate) { var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = []; while (++index < length) { var value = array[index]; if (predicate(value, index, array)) { result[resIndex++] = value; } } return result; } function stubArray() { return []; } var objectProto$2 = Object.prototype; var propertyIsEnumerable = objectProto$2.propertyIsEnumerable; var nativeGetSymbols = Object.getOwnPropertySymbols; var getSymbols = !nativeGetSymbols ? stubArray : function(object) { if (object == null) { return []; } object = Object(object); return arrayFilter(nativeGetSymbols(object), function(symbol) { return propertyIsEnumerable.call(object, symbol); }); }; function baseGetAllKeys(object, keysFunc, symbolsFunc) { var result = keysFunc(object); return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); } function getAllKeys(object) { return baseGetAllKeys(object, keys, getSymbols); } var DataView$1 = getNative(root, "DataView"); var Promise$1 = getNative(root, "Promise"); var Set$1 = getNative(root, "Set"); var mapTag$1 = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag$1 = "[object Set]", weakMapTag = "[object WeakMap]"; var dataViewTag$1 = "[object DataView]"; var dataViewCtorString = toSource(DataView$1), mapCtorString = toSource(Map), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap); var getTag = baseGetTag; if (DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag$1 || Map && getTag(new Map()) != mapTag$1 || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set$1 && getTag(new Set$1()) != setTag$1 || WeakMap && getTag(new WeakMap()) != weakMapTag) { getTag = function(value) { var result = baseGetTag(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : ""; if (ctorString) { switch (ctorString) { case dataViewCtorString: return dataViewTag$1; case mapCtorString: return mapTag$1; case promiseCtorString: return promiseTag; case setCtorString: return setTag$1; case weakMapCtorString: return weakMapTag; } } return result; }; } var Uint8Array$1 = root.Uint8Array; var HASH_UNDEFINED = "__lodash_hash_undefined__"; function setCacheAdd(value) { this.__data__.set(value, HASH_UNDEFINED); return this; } function setCacheHas(value) { return this.__data__.has(value); } function SetCache(values) { var index = -1, length = values == null ? 0 : values.length; this.__data__ = new MapCache(); while (++index < length) { this.add(values[index]); } } SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; SetCache.prototype.has = setCacheHas; function arraySome(array, predicate) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (predicate(array[index], index, array)) { return true; } } return false; } function cacheHas(cache, key) { return cache.has(key); } var COMPARE_PARTIAL_FLAG$5 = 1, COMPARE_UNORDERED_FLAG$3 = 2; function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5, arrLength = array.length, othLength = other.length; if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } var arrStacked = stack.get(array); var othStacked = stack.get(other); if (arrStacked && othStacked) { return arrStacked == other && othStacked == array; } var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new SetCache() : void 0; stack.set(array, other); stack.set(other, array); while (++index < arrLength) { var arrValue = array[index], othValue = other[index]; if (customizer) { var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); } if (compared !== void 0) { if (compared) { continue; } result = false; break; } if (seen) { if (!arraySome(other, function(othValue2, othIndex) { if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) { return seen.push(othIndex); } })) { result = false; break; } } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { result = false; break; } } stack["delete"](array); stack["delete"](other); return result; } function mapToArray(map) { var index = -1, result = Array(map.size); map.forEach(function(value, key) { result[++index] = [key, value]; }); return result; } function setToArray(set) { var index = -1, result = Array(set.size); set.forEach(function(value) { result[++index] = value; }); return result; } var COMPARE_PARTIAL_FLAG$4 = 1, COMPARE_UNORDERED_FLAG$2 = 2; var boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", mapTag = "[object Map]", numberTag = "[object Number]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]"; var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]"; var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0; function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { switch (tag) { case dataViewTag: if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { return false; } object = object.buffer; other = other.buffer; case arrayBufferTag: if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array$1(object), new Uint8Array$1(other))) { return false; } return true; case boolTag: case dateTag: case numberTag: return eq(+object, +other); case errorTag: return object.name == other.name && object.message == other.message; case regexpTag: case stringTag: return object == other + ""; case mapTag: var convert = mapToArray; case setTag: var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4; convert || (convert = setToArray); if (object.size != other.size && !isPartial) { return false; } var stacked = stack.get(object); if (stacked) { return stacked == other; } bitmask |= COMPARE_UNORDERED_FLAG$2; stack.set(object, other); var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); stack["delete"](object); return result; case symbolTag: if (symbolValueOf) { return symbolValueOf.call(object) == symbolValueOf.call(other); } } return false; } var COMPARE_PARTIAL_FLAG$3 = 1; var objectProto$1 = Object.prototype; var hasOwnProperty$1 = objectProto$1.hasOwnProperty; function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length; if (objLength != othLength && !isPartial) { return false; } var index = objLength; while (index--) { var key = objProps[index]; if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) { return false; } } var objStacked = stack.get(object); var othStacked = stack.get(other); if (objStacked && othStacked) { return objStacked == other && othStacked == object; } var result = true; stack.set(object, other); stack.set(other, object); var skipCtor = isPartial; while (++index < objLength) { key = objProps[index]; var objValue = object[key], othValue = other[key]; if (customizer) { var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); } if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) { result = false; break; } skipCtor || (skipCtor = key == "constructor"); } if (result && !skipCtor) { var objCtor = object.constructor, othCtor = other.constructor; if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) { result = false; } } stack["delete"](object); stack["delete"](other); return result; } var COMPARE_PARTIAL_FLAG$2 = 1; var argsTag = "[object Arguments]", arrayTag = "[object Array]", objectTag = "[object Object]"; var objectProto = Object.prototype; var hasOwnProperty = objectProto.hasOwnProperty; function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other); objTag = objTag == argsTag ? objectTag : objTag; othTag = othTag == argsTag ? objectTag : othTag; var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; if (isSameTag && isBuffer(object)) { if (!isBuffer(other)) { return false; } objIsArr = true; objIsObj = false; } if (isSameTag && !objIsObj) { stack || (stack = new Stack()); return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); } if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) { var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__"); if (objIsWrapped || othIsWrapped) { var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other; stack || (stack = new Stack()); return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); } } if (!isSameTag) { return false; } stack || (stack = new Stack()); return equalObjects(object, other, bitmask, customizer, equalFunc, stack); } function baseIsEqual(value, other, bitmask, customizer, stack) { if (value === other) { return true; } if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) { return value !== value && other !== other; } return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); } var COMPARE_PARTIAL_FLAG$1 = 1, COMPARE_UNORDERED_FLAG$1 = 2; function baseIsMatch(object, source, matchData, customizer) { var index = matchData.length, length = index; if (object == null) { return !length; } object = Object(object); while (index--) { var data = matchData[index]; if (data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) { return false; } } while (++index < length) { data = matchData[index]; var key = data[0], objValue = object[key], srcValue = data[1]; if (data[2]) { if (objValue === void 0 && !(key in object)) { return false; } } else { var stack = new Stack(); var result; if (!(result === void 0 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) { return false; } } } return true; } function isStrictComparable(value) { return value === value && !isObject(value); } function getMatchData(object) { var result = keys(object), length = result.length; while (length--) { var key = result[length], value = object[key]; result[length] = [key, value, isStrictComparable(value)]; } return result; } function matchesStrictComparable(key, srcValue) { return function(object) { if (object == null) { return false; } return object[key] === srcValue && (srcValue !== void 0 || key in Object(object)); }; } function baseMatches(source) { var matchData = getMatchData(source); if (matchData.length == 1 && matchData[0][2]) { return matchesStrictComparable(matchData[0][0], matchData[0][1]); } return function(object) { return object === source || baseIsMatch(object, source, matchData); }; } function baseHasIn(object, key) { return object != null && key in Object(object); } function hasPath(object, path, hasFunc) { path = castPath(path, object); var index = -1, length = path.length, result = false; while (++index < length) { var key = toKey(path[index]); if (!(result = object != null && hasFunc(object, key))) { break; } object = object[key]; } if (result || ++index != length) { return result; } length = object == null ? 0 : object.length; return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object)); } function hasIn(object, path) { return object != null && hasPath(object, path, baseHasIn); } var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; function baseMatchesProperty(path, srcValue) { if (isKey(path) && isStrictComparable(srcValue)) { return matchesStrictComparable(toKey(path), srcValue); } return function(object) { var objValue = get(object, path); return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); }; } function baseProperty(key) { return function(object) { return object == null ? void 0 : object[key]; }; } function basePropertyDeep(path) { return function(object) { return baseGet(object, path); }; } function property(path) { return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); } function baseIteratee(value) { if (typeof value == "function") { return value; } if (value == null) { return identity; } if (typeof value == "object") { return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value); } return property(value); } function createBaseFor(fromRight) { return function(object, iteratee, keysFunc) { var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length; while (length--) { var key = props[++index]; if (iteratee(iterable[key], key, iterable) === false) { break; } } return object; }; } var baseFor = createBaseFor(); function baseForOwn(object, iteratee) { return object && baseFor(object, iteratee, keys); } function mapKeys(object, iteratee) { var result = {}; iteratee = baseIteratee(iteratee); baseForOwn(object, function(value, key, object2) { baseAssignValue(result, iteratee(value, key, object2), value); }); return result; } var nativeFloor = Math.floor, nativeRandom$1 = Math.random; function baseRandom(lower, upper) { return lower + nativeFloor(nativeRandom$1() * (upper - lower + 1)); } var freeParseFloat = parseFloat; var nativeMin = Math.min, nativeRandom = Math.random; function random(lower, upper, floating) { if (floating && typeof floating != "boolean" && isIterateeCall(lower, upper, floating)) { upper = floating = void 0; } if (floating === void 0) { if (typeof upper == "boolean") { floating = upper; upper = void 0; } else if (typeof lower == "boolean") { floating = lower; lower = void 0; } } if (lower === void 0 && upper === void 0) { lower = 0; upper = 1; } else { lower = toFinite(lower); if (upper === void 0) { upper = lower; lower = 0; } else { upper = toFinite(upper); } } if (lower > upper) { var temp = lower; lower = upper; upper = temp; } if (floating || lower % 1 || upper % 1) { var rand = nativeRandom(); return nativeMin(lower + rand * (upper - lower + freeParseFloat("1e-" + ((rand + "").length - 1))), upper); } return baseRandom(lower, upper); } const useSearch = (request) => { if (!request.url.includes("/api.bilibili.comx/web-interface/search")) return; request.url = request.url.replace(/\.com(?!\/)/, ".com/"); }; const search = [useSearch]; // @license GNU LGPL-3.0 const ajaxHooker = (() => { const version = "1.4.7"; const hookInst = { hookFns: [], filters: [] }; const win = window.unsafeWindow || document.defaultView || window; let winAh = win.__ajaxHooker; const resProto = win.Response.prototype; const xhrResponses = ["response", "responseText", "responseXML"]; const fetchResponses = ["arrayBuffer", "blob", "formData", "json", "text"]; const xhrExtraProps = ["responseType", "timeout", "withCredentials"]; const fetchExtraProps = [ "cache", "credentials", "integrity", "keepalive", "mode", "priority", "redirect", "referrer", "referrerPolicy", "signal" ]; const xhrAsyncEvents = ["readystatechange", "load", "loadend"]; const getType = {}.toString.call.bind({}.toString); const getDescriptor = Object.getOwnPropertyDescriptor.bind(Object); const emptyFn = () => { }; const errorFn = (e) => console.error(e); function isThenable(obj) { return obj && ["object", "function"].includes(typeof obj) && typeof obj.then === "function"; } function catchError(fn, ...args) { try { const result = fn(...args); if (isThenable(result)) return result.then(null, errorFn); return result; } catch (err) { console.error(err); } } function defineProp(obj, prop, getter, setter) { Object.defineProperty(obj, prop, { configurable: true, enumerable: true, get: getter, set: setter }); } function readonly(obj, prop, value = obj[prop]) { defineProp(obj, prop, () => value, emptyFn); } function writable(obj, prop, value = obj[prop]) { Object.defineProperty(obj, prop, { configurable: true, enumerable: true, writable: true, value }); } function parseHeaders(obj) { const headers = {}; switch (getType(obj)) { case "[object String]": for (const line of obj.trim().split(/[\r\n]+/)) { const [header, value] = line.split(new RegExp("(?<=^[^:]+)\\s*:\\s*")); if (!value) continue; const lheader = header.toLowerCase(); headers[lheader] = lheader in headers ? `${headers[lheader]}, ${value}` : value; } break; case "[object Headers]": for (const [key, val] of obj) { headers[key] = val; } break; case "[object Object]": return { ...obj }; } return headers; } function stopImmediatePropagation() { this.ajaxHooker_isStopped = true; } class SyncThenable { then(fn) { fn && fn(); return new SyncThenable(); } } class AHRequest { constructor(request) { this.request = request; this.requestClone = { ...this.request }; } _recoverRequestKey(key) { if (key in this.requestClone) this.request[key] = this.requestClone[key]; else delete this.request[key]; } shouldFilter(filters) { const { type, url, method, async } = this.request; return filters.length && !filters.find((obj) => { switch (true) { case (obj.type && obj.type !== type): case (getType(obj.url) === "[object String]" && !url.includes(obj.url)): case (getType(obj.url) === "[object RegExp]" && !obj.url.test(url)): case (obj.method && obj.method.toUpperCase() !== method.toUpperCase()): case ("async" in obj && obj.async !== async): return false; } return true; }); } waitForRequestKeys() { if (!this.request.async) { win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => { if (this.shouldFilter(filters)) return; hookFns.forEach((fn) => { if (getType(fn) === "[object Function]") catchError(fn, this.request); }); for (const key in this.request) { if (isThenable(this.request[key])) this._recoverRequestKey(key); } }); return new SyncThenable(); } const promises = []; const ignoreKeys = /* @__PURE__ */ new Set(["type", "async", "response"]); win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => { if (this.shouldFilter(filters)) return; promises.push( Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(() => { const requestKeys = []; for (const key in this.request) !ignoreKeys.has(key) && requestKeys.push(key); return Promise.all( requestKeys.map( (key) => Promise.resolve(this.request[key]).then( (val) => this.request[key] = val, () => this._recoverRequestKey(key) ) ) ); }) ); }); return Promise.all(promises); } waitForResponseKeys(response) { const responseKeys = this.request.type === "xhr" ? xhrResponses : fetchResponses; if (!this.request.async) { if (getType(this.request.response) === "[object Function]") { catchError(this.request.response, response); responseKeys.forEach((key) => { if ("get" in getDescriptor(response, key) || isThenable(response[key])) { delete response[key]; } }); } return new SyncThenable(); } return Promise.resolve(catchError(this.request.response, response)).then( () => Promise.all( responseKeys.map((key) => { const descriptor = getDescriptor(response, key); if (descriptor && "value" in descriptor) { return Promise.resolve(descriptor.value).then( (val) => response[key] = val, () => delete response[key] ); } else { delete response[key]; } }) ) ); } } const proxyHandler = { get(target, prop) { const descriptor = getDescriptor(target, prop); if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.get) { return target[prop]; } const ah = target.__ajaxHooker; if (ah && ah.proxyProps) { if (prop in ah.proxyProps) { const pDescriptor = ah.proxyProps[prop]; if ("get" in pDescriptor) return pDescriptor.get(); if (typeof pDescriptor.value === "function") return pDescriptor.value.bind(ah); return pDescriptor.value; } if (typeof target[prop] === "function") return target[prop].bind(target); } return target[prop]; }, set(target, prop, value) { const descriptor = getDescriptor(target, prop); if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.set) { return true; } const ah = target.__ajaxHooker; if (ah && ah.proxyProps && prop in ah.proxyProps) { const pDescriptor = ah.proxyProps[prop]; pDescriptor.set ? pDescriptor.set(value) : pDescriptor.value = value; } else { target[prop] = value; } return true; } }; class XhrHooker { constructor(xhr) { Object.assign(this, { originalXhr: xhr, proxyXhr: new Proxy(xhr, proxyHandler), resThenable: new SyncThenable(), proxyProps: {}, proxyEvents: {} }); xhr.addEventListener("readystatechange", (e) => { if (this.proxyXhr.readyState === 4 && this.request && typeof this.request.response === "function") { const response = { finalUrl: this.proxyXhr.responseURL, status: this.proxyXhr.status, responseHeaders: parseHeaders(this.proxyXhr.getAllResponseHeaders()) }; const tempValues = {}; for (const key of xhrResponses) { try { tempValues[key] = this.originalXhr[key]; } catch (err) { } defineProp( response, key, () => { return response[key] = tempValues[key]; }, (val) => { delete response[key]; response[key] = val; } ); } this.resThenable = new AHRequest(this.request).waitForResponseKeys(response).then(() => { for (const key of xhrResponses) { this.proxyProps[key] = { get: () => { if (!(key in response)) response[key] = tempValues[key]; return response[key]; } }; } }); } this.dispatchEvent(e); }); xhr.addEventListener("load", (e) => this.dispatchEvent(e)); xhr.addEventListener("loadend", (e) => this.dispatchEvent(e)); for (const evt of xhrAsyncEvents) { const onEvt = `on${evt}`; this.proxyProps[onEvt] = { get: () => this.proxyEvents[onEvt] || null, set: (val) => this.addEvent(onEvt, val) }; } for (const method of ["setRequestHeader", "addEventListener", "removeEventListener", "open", "send"]) { this.proxyProps[method] = { value: this[method] }; } } toJSON() { } // Converting circular structure to JSON addEvent(type, event) { if (type.startsWith("on")) { this.proxyEvents[type] = typeof event === "function" ? event : null; } else { if (typeof event === "object" && event !== null) event = event.handleEvent; if (typeof event !== "function") return; this.proxyEvents[type] = this.proxyEvents[type] || /* @__PURE__ */ new Set(); this.proxyEvents[type].add(event); } } removeEvent(type, event) { if (type.startsWith("on")) { this.proxyEvents[type] = null; } else { if (typeof event === "object" && event !== null) event = event.handleEvent; this.proxyEvents[type] && this.proxyEvents[type].delete(event); } } dispatchEvent(e) { e.stopImmediatePropagation = stopImmediatePropagation; defineProp(e, "target", () => this.proxyXhr); defineProp(e, "currentTarget", () => this.proxyXhr); defineProp(e, "srcElement", () => this.proxyXhr); this.proxyEvents[e.type] && this.proxyEvents[e.type].forEach((fn) => { this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e)); }); if (e.ajaxHooker_isStopped) return; const onEvent = this.proxyEvents[`on${e.type}`]; onEvent && this.resThenable.then(onEvent.bind(this.proxyXhr, e)); } setRequestHeader(header, value) { this.originalXhr.setRequestHeader(header, value); if (!this.request) return; const headers = this.request.headers; headers[header] = header in headers ? `${headers[header]}, ${value}` : value; } addEventListener(...args) { if (xhrAsyncEvents.includes(args[0])) { this.addEvent(args[0], args[1]); } else { this.originalXhr.addEventListener(...args); } } removeEventListener(...args) { if (xhrAsyncEvents.includes(args[0])) { this.removeEvent(args[0], args[1]); } else { this.originalXhr.removeEventListener(...args); } } open(method, url, async = true, ...args) { this.request = { type: "xhr", url: url.toString(), method: method.toUpperCase(), abort: false, headers: {}, data: null, response: null, async: !!async }; this.openArgs = args; this.resThenable = new SyncThenable(); ["responseURL", "readyState", "status", "statusText", ...xhrResponses].forEach((key) => { delete this.proxyProps[key]; }); return this.originalXhr.open(method, url, async, ...args); } send(data) { const xhr = this.originalXhr; const request = this.request; if (!request) return xhr.send(data); request.data = data; new AHRequest(request).waitForRequestKeys().then(() => { if (request.abort) { if (typeof request.response === "function") { Object.assign(this.proxyProps, { responseURL: { value: request.url }, readyState: { value: 4 }, status: { value: 200 }, statusText: { value: "OK" } }); xhrAsyncEvents.forEach((evt) => xhr.dispatchEvent(new Event(evt))); } } else { xhr.open(request.method, request.url, request.async, ...this.openArgs); for (const header in request.headers) { xhr.setRequestHeader(header, request.headers[header]); } for (const prop of xhrExtraProps) { if (prop in request) xhr[prop] = request[prop]; } xhr.send(request.data); } }); } } function fakeXHR() { const xhr = new winAh.realXHR(); if ("__ajaxHooker" in xhr) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!"); xhr.__ajaxHooker = new XhrHooker(xhr); return xhr.__ajaxHooker.proxyXhr; } fakeXHR.prototype = win.XMLHttpRequest.prototype; Object.keys(win.XMLHttpRequest).forEach((key) => fakeXHR[key] = win.XMLHttpRequest[key]); function fakeFetch(url, options = {}) { if (!url) return winAh.realFetch.call(win, url, options); return new Promise(async (resolve, reject) => { const init = {}; if (getType(url) === "[object Request]") { init.method = url.method; init.headers = url.headers; if (url.body) init.body = await url.arrayBuffer(); for (const prop of fetchExtraProps) init[prop] = url[prop]; url = url.url; } url = url.toString(); Object.assign(init, options); init.method = init.method || "GET"; init.headers = init.headers || {}; const request = { type: "fetch", url, method: init.method.toUpperCase(), abort: false, headers: parseHeaders(init.headers), data: init.body, response: null, async: true }; const req = new AHRequest(request); await req.waitForRequestKeys(); if (request.abort) { if (typeof request.response === "function") { const response = { finalUrl: request.url, status: 200, responseHeaders: {} }; await req.waitForResponseKeys(response); const key = fetchResponses.find((k) => k in response); let val = response[key]; if (key === "json" && typeof val === "object") { val = catchError(JSON.stringify.bind(JSON), val); } const res = new Response(val, { status: 200, statusText: "OK" }); defineProp(res, "type", () => "basic"); defineProp(res, "url", () => request.url); resolve(res); } else { reject(new DOMException("aborted", "AbortError")); } return; } init.method = request.method; init.headers = request.headers; init.body = request.data; for (const prop of fetchExtraProps) { if (prop in request) init[prop] = request[prop]; } winAh.realFetch.call(win, request.url, init).then((res) => { if (typeof request.response === "function") { const response = { finalUrl: res.url, status: res.status, responseHeaders: parseHeaders(res.headers) }; fetchResponses.forEach( (key) => res[key] = function() { if (key in response) return Promise.resolve(response[key]); return resProto[key].call(this).then((val) => { response[key] = val; return req.waitForResponseKeys(response).then(() => key in response ? response[key] : val); }); } ); } resolve(res); }, reject); }); } function fakeFetchClone() { const descriptors = Object.getOwnPropertyDescriptors(this); const res = winAh.realFetchClone.call(this); Object.defineProperties(res, descriptors); return res; } winAh = win.__ajaxHooker = winAh || { version, fakeXHR, fakeFetch, fakeFetchClone, realXHR: win.XMLHttpRequest, realFetch: win.fetch, realFetchClone: resProto.clone, hookInsts: /* @__PURE__ */ new Set() }; if (winAh.version !== version) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!"); win.XMLHttpRequest = winAh.fakeXHR; win.fetch = winAh.fakeFetch; resProto.clone = winAh.fakeFetchClone; winAh.hookInsts.add(hookInst); class AHFunction extends Function { call(thisArg, ...args) { if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) { thisArg = thisArg.__ajaxHooker.originalXhr; } return Reflect.apply(this, thisArg, args); } apply(thisArg, args) { if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) { thisArg = thisArg.__ajaxHooker.originalXhr; } return Reflect.apply(this, thisArg, args || []); } } function hookSecsdk(csrf) { Object.setPrototypeOf(csrf.nativeXMLHttpRequestSetRequestHeader, AHFunction.prototype); Object.setPrototypeOf(csrf.nativeXMLHttpRequestOpen, AHFunction.prototype); Object.setPrototypeOf(csrf.nativeXMLHttpRequestSend, AHFunction.prototype); } if (win.secsdk) { if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen) hookSecsdk(win.secsdk.csrf); } else { defineProp(win, "secsdk", emptyFn, (secsdk) => { delete win.secsdk; win.secsdk = secsdk; defineProp(secsdk, "csrf", emptyFn, (csrf) => { delete secsdk.csrf; secsdk.csrf = csrf; if (csrf.nativeXMLHttpRequestOpen) hookSecsdk(csrf); }); }); } return { hook: (fn) => hookInst.hookFns.push(fn), filter: (arr) => { if (Array.isArray(arr)) hookInst.filters = arr; }, protect: () => { readonly(win, "XMLHttpRequest", winAh.fakeXHR); readonly(win, "fetch", winAh.fakeFetch); readonly(resProto, "clone", winAh.fakeFetchClone); }, unhook: () => { winAh.hookInsts.delete(hookInst); if (!winAh.hookInsts.size) { writable(win, "XMLHttpRequest", winAh.realXHR); writable(win, "fetch", winAh.realFetch); writable(resProto, "clone", winAh.realFetchClone); delete win.__ajaxHooker; } } }; })(); const _RequestHooker = class _RequestHooker { constructor() { __publicField(this, "hooks", /* @__PURE__ */ new Set()); __publicField(this, "isHooked", false); } /** * 获取单例实例 */ static getInstance() { if (!_RequestHooker.instance) { _RequestHooker.instance = new _RequestHooker(); } return _RequestHooker.instance; } /** * 添加请求钩子函数 * @param fns 一个或多个请求处理函数 */ add(...fns) { fns.forEach((fn) => { this.hooks.add(fn); }); this.ensureHooked(); } /** * 移除请求钩子函数 * @param fn 要移除的函数 */ remove(fn) { this.hooks.delete(fn); } /** * 清空所有钩子函数 */ clear() { this.hooks.clear(); } /** * ajaxHooker.hook 只执行一次就行 */ ensureHooked() { if (this.isHooked) return; this.isHooked = true; ajaxHooker.hook((request) => { this.hooks.forEach((hook) => { hook(request); }); }); } }; __publicField(_RequestHooker, "instance", null); let RequestHooker = _RequestHooker; function onRequest(...args) { RequestHooker.getInstance().add(...args); } function clearRequestHooks() { RequestHooker.getInstance().clear(); } function useWsIntercept() { let wsOriginalSend = null; function modifyUidPacket(data) { const jsonStart = 16; const jsonBytes = new Uint8Array(data, jsonStart); const jsonString = new TextDecoder().decode(jsonBytes); const jsonObj = JSON.parse(jsonString); jsonObj.uid = 0; const newJsonBytes = new TextEncoder().encode(JSON.stringify(jsonObj)); const newPacket = new ArrayBuffer(16 + newJsonBytes.length); const newView = new DataView(newPacket); const originalView = new DataView(data); for (let i = 0; i < 16; i++) { newView.setUint8(i, originalView.getUint8(i)); } newView.setUint32(0, newJsonBytes.length + 16, false); new Uint8Array(newPacket, 16).set(newJsonBytes); return newPacket; } function start2() { if (wsOriginalSend) return; wsOriginalSend = WebSocket.prototype.send; WebSocket.prototype.send = function(data) { if (data instanceof ArrayBuffer) { const view = new DataView(data); if (view.getUint32(8, false) === 7) { return wsOriginalSend.call(this, modifyUidPacket(data)); } } return wsOriginalSend.call(this, data); }; } function stop2() { if (!wsOriginalSend) return; WebSocket.prototype.send = wsOriginalSend; wsOriginalSend = null; } return { start: start2, stop: stop2 }; } const { start, stop } = useWsIntercept(); function useUserStore() { const isLogin = reactivity.ref(false); reactivity.watch(isLogin, (newVal) => { if (!newVal) return; clearRequestHooks(); stop(); }); return { isLogin }; } const userStore = useUserStore(); function toResult(data, code = 0, message = "success", ttl = 1) { return { code, message, ttl, data }; } const mockUserInfo$1 = { isLogin: true, email_verified: 1, face: "https://i0.hdslb.com/bfs/face/0c84b9f4ad546d3f20324809d45fc439a2a8ddab.jpg", face_nft: 0, face_nft_type: 0, level_info: { current_level: 6, current_min: 28800, current_exp: 29050, next_exp: "--" }, mid: 3493281916783362, mobile_verified: 1, money: 9999.99, moral: 70, official: { role: 0, title: "", desc: "", type: -1 }, officialVerify: { type: -1, desc: "" }, pendant: { pid: 0, name: "", image: "", expire: 0, image_enhance: "", image_enhance_frame: "", n_pid: 0 }, scores: 0, uname: "bilibili", vipDueDate: 16747488e5, vipStatus: 0, vipType: 1, vip_pay_type: 0, vip_theme_type: 0, vip_label: { path: "", text: "", label_theme: "", text_color: "", bg_style: 0, bg_color: "", border_color: "", use_img_label: true, img_label_uri_hans: "", img_label_uri_hant: "", img_label_uri_hans_static: "", img_label_uri_hant_static: "" }, vip_avatar_subscript: 0, vip_nickname_color: "", vip: { type: 1, status: 0, due_date: 16747488e5, vip_pay_type: 0, theme_type: 0, label: { path: "", text: "", label_theme: "", text_color: "", bg_style: 0, bg_color: "", border_color: "", use_img_label: true, img_label_uri_hans: "", img_label_uri_hant: "", img_label_uri_hans_static: "", img_label_uri_hant_static: "" }, avatar_subscript: 0, nickname_color: "", role: 0, avatar_subscript_url: "", tv_vip_status: 0, tv_vip_pay_type: 0, tv_due_date: 0, avatar_icon: { icon_resource: {} } }, wallet: { mid: 3493281916783362, bcoin_balance: 0, coupon_balance: 0, coupon_due_time: 0 }, has_shop: false, shop_url: "", answer_status: 0, is_senior_member: 1, wbi_img: { img_url: "", sub_url: "" }, is_jury: false, name_render: null }; const mockUserInfoResult = toResult(mockUserInfo$1); const useNav = (request) => { if (!request.url.includes("/x/web-interface/nav")) return; if (request.type === "xhr") { request.response = (res) => { try { const userInfo = JSON.parse(res.responseText); if (userInfo.data.isLogin) { userStore.isLogin.value = true; return; } } catch (_error) { } res.responseText = JSON.stringify(mockUserInfoResult); }; } if (request.type === "fetch") { request.response = (res) => { res.json = mockUserInfoResult; }; } }; const useReply = (request) => { if (!request.url.includes("/x/v2/reply/wbi/main") && !request.url.includes("/x/v2/reply/reply")) return; request.credentials = "omit"; }; const shared = [useNav, useReply]; const mockUserInfo = { profile: { mid: 3493281916783362, name: "bilibili", sex: "保密", face: "https://i0.hdslb.com/bfs/face/0c84b9f4ad546d3f20324809d45fc439a2a8ddab.jpg", sign: "", rank: 1e4, level: 6, jointime: 0, moral: 70, silence: 0, email_status: 0, tel_status: 1, identification: 0, vip: { type: 0, status: 0, due_date: 0, vip_pay_type: 0, theme_type: 0, label: { path: "", text: "", label_theme: "", text_color: "", bg_style: 0, bg_color: "", border_color: "", use_img_label: true, img_label_uri_hans: "", img_label_uri_hant: "", img_label_uri_hans_static: "https://i0.hdslb.com/bfs/vip/d7b702ef65a976b20ed854cbd04cb9e27341bb79.png", img_label_uri_hant_static: "https://i0.hdslb.com/bfs/activity-plat/static/20220614/e369244d0b14644f5e1a06431e22a4d5/KJunwh19T5.png", label_id: 0, label_goto: null }, avatar_subscript: 0, nickname_color: "", role: 0, avatar_subscript_url: "", tv_vip_status: 0, tv_vip_pay_type: 0, tv_due_date: 0, avatar_icon: { icon_resource: {} }, ott_info: { vip_type: 0, pay_type: 0, pay_channel_id: "", status: 0, overdue_time: 0 }, super_vip: { is_super_vip: false } }, pendant: { pid: 0, name: "", image: "", expire: 0, image_enhance: "", image_enhance_frame: "", n_pid: 0 }, nameplate: { nid: 0, name: "", image: "", image_small: "", level: "", condition: "" }, official: { role: 0, title: "", desc: "", type: -1 }, birthday: 315504e3, is_tourist: 0, is_fake_account: 0, pin_prompting: 0, is_deleted: 0, in_reg_audit: 0, is_rip_user: false, profession: { id: 0, name: "", show_name: "", is_show: 0, category_one: "", realname: "", title: "", department: "", certificate_no: "", certificate_show: false }, face_nft: 0, face_nft_new: 0, is_senior_member: 0, honours: { mid: 3493281916783362, colour: { dark: "#CE8620", normal: "#F0900B" }, tags: null, is_latest_100honour: 0 }, digital_id: "", digital_type: -2, attestation: { type: 0, common_info: { title: "", prefix: "", prefix_title: "" }, splice_info: { title: "" }, icon: "", desc: "" }, expert_info: { title: "", state: 0, type: 0, desc: "" }, name_render: null, country_code: "86", handle: "" }, level_exp: { current_level: 6, current_min: 28800, current_exp: 29050, next_exp: "--" }, coins: 9999.99, following: 0, follower: 0 }; const SPACE = { USER_INFO: toResult(mockUserInfo) }; const useMyInfo = (request) => { if (!request.url.includes("x/space/v2/myinfo")) return; request.response = (res) => { res.json = SPACE.USER_INFO; }; }; const space = [useMyInfo]; const historyList = { cursor: { max: 1, view_at: 0, business: "archive", ps: 20 }, tab: [ { type: "archive", name: "视频" }, { type: "live", name: "直播" }, { type: "article", name: "专栏" } ], list: [] }; const historyListResult = toResult(historyList); const useHistory = (request) => { if (!request.url.includes("/x/web-interface/history/cursor")) return; request.response = (res) => { res.json = historyListResult; }; }; const history = [useHistory]; const useWebKey = (key_url) => { return key_url.slice(key_url.lastIndexOf("/") + 1, key_url.lastIndexOf(".")); }; const web_key_urls = { img_key_url: localStorage.getItem("wbi_img_url") ?? "", sub_key_url: localStorage.getItem("wbi_sub_url") ?? "" }; const img_key = useWebKey(web_key_urls.img_key_url); const sub_key = useWebKey(web_key_urls.img_key_url); const c = new Int32Array(4); const _h = class _h { constructor() { __publicField(this, "_dataLength", 0); __publicField(this, "_bufferLength", 0); __publicField(this, "_state", new Int32Array(4)); __publicField(this, "_buffer", new ArrayBuffer(68)); __publicField(this, "_buffer8"); __publicField(this, "_buffer32"); this._buffer8 = new Uint8Array(this._buffer, 0, 68), this._buffer32 = new Uint32Array(this._buffer, 0, 17), this.start(); } static hashStr(i, a = false) { return this.onePassHasher.start().appendStr(i).end(a); } static hashAsciiStr(i, a = false) { return this.onePassHasher.start().appendAsciiStr(i).end(a); } static _hex(i) { const a = _h.hexChars, t = _h.hexOut; let e, s, r, n; for (n = 0; n < 4; n += 1) for (s = n * 8, e = i[n], r = 0; r < 8; r += 2) t[s + 1 + r] = a.charAt(e & 15), e >>>= 4, t[s + 0 + r] = a.charAt(e & 15), e >>>= 4; return t.join(""); } static _md5cycle(i, a) { let t = i[0], e = i[1], s = i[2], r = i[3]; t += (e & s | ~e & r) + a[0] - 680876936 | 0, t = (t << 7 | t >>> 25) + e | 0, r += (t & e | ~t & s) + a[1] - 389564586 | 0, r = (r << 12 | r >>> 20) + t | 0, s += (r & t | ~r & e) + a[2] + 606105819 | 0, s = (s << 17 | s >>> 15) + r | 0, e += (s & r | ~s & t) + a[3] - 1044525330 | 0, e = (e << 22 | e >>> 10) + s | 0, t += (e & s | ~e & r) + a[4] - 176418897 | 0, t = (t << 7 | t >>> 25) + e | 0, r += (t & e | ~t & s) + a[5] + 1200080426 | 0, r = (r << 12 | r >>> 20) + t | 0, s += (r & t | ~r & e) + a[6] - 1473231341 | 0, s = (s << 17 | s >>> 15) + r | 0, e += (s & r | ~s & t) + a[7] - 45705983 | 0, e = (e << 22 | e >>> 10) + s | 0, t += (e & s | ~e & r) + a[8] + 1770035416 | 0, t = (t << 7 | t >>> 25) + e | 0, r += (t & e | ~t & s) + a[9] - 1958414417 | 0, r = (r << 12 | r >>> 20) + t | 0, s += (r & t | ~r & e) + a[10] - 42063 | 0, s = (s << 17 | s >>> 15) + r | 0, e += (s & r | ~s & t) + a[11] - 1990404162 | 0, e = (e << 22 | e >>> 10) + s | 0, t += (e & s | ~e & r) + a[12] + 1804603682 | 0, t = (t << 7 | t >>> 25) + e | 0, r += (t & e | ~t & s) + a[13] - 40341101 | 0, r = (r << 12 | r >>> 20) + t | 0, s += (r & t | ~r & e) + a[14] - 1502002290 | 0, s = (s << 17 | s >>> 15) + r | 0, e += (s & r | ~s & t) + a[15] + 1236535329 | 0, e = (e << 22 | e >>> 10) + s | 0, t += (e & r | s & ~r) + a[1] - 165796510 | 0, t = (t << 5 | t >>> 27) + e | 0, r += (t & s | e & ~s) + a[6] - 1069501632 | 0, r = (r << 9 | r >>> 23) + t | 0, s += (r & e | t & ~e) + a[11] + 643717713 | 0, s = (s << 14 | s >>> 18) + r | 0, e += (s & t | r & ~t) + a[0] - 373897302 | 0, e = (e << 20 | e >>> 12) + s | 0, t += (e & r | s & ~r) + a[5] - 701558691 | 0, t = (t << 5 | t >>> 27) + e | 0, r += (t & s | e & ~s) + a[10] + 38016083 | 0, r = (r << 9 | r >>> 23) + t | 0, s += (r & e | t & ~e) + a[15] - 660478335 | 0, s = (s << 14 | s >>> 18) + r | 0, e += (s & t | r & ~t) + a[4] - 405537848 | 0, e = (e << 20 | e >>> 12) + s | 0, t += (e & r | s & ~r) + a[9] + 568446438 | 0, t = (t << 5 | t >>> 27) + e | 0, r += (t & s | e & ~s) + a[14] - 1019803690 | 0, r = (r << 9 | r >>> 23) + t | 0, s += (r & e | t & ~e) + a[3] - 187363961 | 0, s = (s << 14 | s >>> 18) + r | 0, e += (s & t | r & ~t) + a[8] + 1163531501 | 0, e = (e << 20 | e >>> 12) + s | 0, t += (e & r | s & ~r) + a[13] - 1444681467 | 0, t = (t << 5 | t >>> 27) + e | 0, r += (t & s | e & ~s) + a[2] - 51403784 | 0, r = (r << 9 | r >>> 23) + t | 0, s += (r & e | t & ~e) + a[7] + 1735328473 | 0, s = (s << 14 | s >>> 18) + r | 0, e += (s & t | r & ~t) + a[12] - 1926607734 | 0, e = (e << 20 | e >>> 12) + s | 0, t += (e ^ s ^ r) + a[5] - 378558 | 0, t = (t << 4 | t >>> 28) + e | 0, r += (t ^ e ^ s) + a[8] - 2022574463 | 0, r = (r << 11 | r >>> 21) + t | 0, s += (r ^ t ^ e) + a[11] + 1839030562 | 0, s = (s << 16 | s >>> 16) + r | 0, e += (s ^ r ^ t) + a[14] - 35309556 | 0, e = (e << 23 | e >>> 9) + s | 0, t += (e ^ s ^ r) + a[1] - 1530992060 | 0, t = (t << 4 | t >>> 28) + e | 0, r += (t ^ e ^ s) + a[4] + 1272893353 | 0, r = (r << 11 | r >>> 21) + t | 0, s += (r ^ t ^ e) + a[7] - 155497632 | 0, s = (s << 16 | s >>> 16) + r | 0, e += (s ^ r ^ t) + a[10] - 1094730640 | 0, e = (e << 23 | e >>> 9) + s | 0, t += (e ^ s ^ r) + a[13] + 681279174 | 0, t = (t << 4 | t >>> 28) + e | 0, r += (t ^ e ^ s) + a[0] - 358537222 | 0, r = (r << 11 | r >>> 21) + t | 0, s += (r ^ t ^ e) + a[3] - 722521979 | 0, s = (s << 16 | s >>> 16) + r | 0, e += (s ^ r ^ t) + a[6] + 76029189 | 0, e = (e << 23 | e >>> 9) + s | 0, t += (e ^ s ^ r) + a[9] - 640364487 | 0, t = (t << 4 | t >>> 28) + e | 0, r += (t ^ e ^ s) + a[12] - 421815835 | 0, r = (r << 11 | r >>> 21) + t | 0, s += (r ^ t ^ e) + a[15] + 530742520 | 0, s = (s << 16 | s >>> 16) + r | 0, e += (s ^ r ^ t) + a[2] - 995338651 | 0, e = (e << 23 | e >>> 9) + s | 0, t += (s ^ (e | ~r)) + a[0] - 198630844 | 0, t = (t << 6 | t >>> 26) + e | 0, r += (e ^ (t | ~s)) + a[7] + 1126891415 | 0, r = (r << 10 | r >>> 22) + t | 0, s += (t ^ (r | ~e)) + a[14] - 1416354905 | 0, s = (s << 15 | s >>> 17) + r | 0, e += (r ^ (s | ~t)) + a[5] - 57434055 | 0, e = (e << 21 | e >>> 11) + s | 0, t += (s ^ (e | ~r)) + a[12] + 1700485571 | 0, t = (t << 6 | t >>> 26) + e | 0, r += (e ^ (t | ~s)) + a[3] - 1894986606 | 0, r = (r << 10 | r >>> 22) + t | 0, s += (t ^ (r | ~e)) + a[10] - 1051523 | 0, s = (s << 15 | s >>> 17) + r | 0, e += (r ^ (s | ~t)) + a[1] - 2054922799 | 0, e = (e << 21 | e >>> 11) + s | 0, t += (s ^ (e | ~r)) + a[8] + 1873313359 | 0, t = (t << 6 | t >>> 26) + e | 0, r += (e ^ (t | ~s)) + a[15] - 30611744 | 0, r = (r << 10 | r >>> 22) + t | 0, s += (t ^ (r | ~e)) + a[6] - 1560198380 | 0, s = (s << 15 | s >>> 17) + r | 0, e += (r ^ (s | ~t)) + a[13] + 1309151649 | 0, e = (e << 21 | e >>> 11) + s | 0, t += (s ^ (e | ~r)) + a[4] - 145523070 | 0, t = (t << 6 | t >>> 26) + e | 0, r += (e ^ (t | ~s)) + a[11] - 1120210379 | 0, r = (r << 10 | r >>> 22) + t | 0, s += (t ^ (r | ~e)) + a[2] + 718787259 | 0, s = (s << 15 | s >>> 17) + r | 0, e += (r ^ (s | ~t)) + a[9] - 343485551 | 0, e = (e << 21 | e >>> 11) + s | 0, i[0] = t + i[0] | 0, i[1] = e + i[1] | 0, i[2] = s + i[2] | 0, i[3] = r + i[3] | 0; } /** * Initialise buffer to be hashed */ start() { return this._dataLength = 0, this._bufferLength = 0, this._state.set(_h.stateIdentity), this; } // Char to code point to to array conversion: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt // #Example.3A_Fixing_charCodeAt_to_handle_non-Basic-Multilingual-Plane_characters_if_their_presence_earlier_in_the_string_is_unknown /** * Append a UTF-8 string to the hash buffer * @param str String to append */ appendStr(i) { const a = this._buffer8, t = this._buffer32; let e = this._bufferLength, s, r; for (r = 0; r < i.length; r += 1) { if (s = i.charCodeAt(r), s < 128) a[e++] = s; else if (s < 2048) a[e++] = (s >>> 6) + 192, a[e++] = s & 63 | 128; else if (s < 55296 || s > 56319) a[e++] = (s >>> 12) + 224, a[e++] = s >>> 6 & 63 | 128, a[e++] = s & 63 | 128; else { if (s = (s - 55296) * 1024 + (i.charCodeAt(++r) - 56320) + 65536, s > 1114111) throw new Error( "Unicode standard supports code points up to U+10FFFF" ); a[e++] = (s >>> 18) + 240, a[e++] = s >>> 12 & 63 | 128, a[e++] = s >>> 6 & 63 | 128, a[e++] = s & 63 | 128; } e >= 64 && (this._dataLength += 64, _h._md5cycle(this._state, t), e -= 64, t[0] = t[16]); } return this._bufferLength = e, this; } /** * Append an ASCII string to the hash buffer * @param str String to append */ appendAsciiStr(i) { const a = this._buffer8, t = this._buffer32; let e = this._bufferLength, s, r = 0; for (; ; ) { for (s = Math.min(i.length - r, 64 - e); s--; ) a[e++] = i.charCodeAt(r++); if (e < 64) break; this._dataLength += 64, _h._md5cycle(this._state, t), e = 0; } return this._bufferLength = e, this; } /** * Append a byte array to the hash buffer * @param input array to append */ appendByteArray(i) { const a = this._buffer8, t = this._buffer32; let e = this._bufferLength, s, r = 0; for (; ; ) { for (s = Math.min(i.length - r, 64 - e); s--; ) a[e++] = i[r++]; if (e < 64) break; this._dataLength += 64, _h._md5cycle(this._state, t), e = 0; } return this._bufferLength = e, this; } /** * Get the state of the hash buffer */ getState() { const i = this._state; return { buffer: String.fromCharCode.apply(null, Array.from(this._buffer8)), buflen: this._bufferLength, length: this._dataLength, state: [i[0], i[1], i[2], i[3]] }; } /** * Override the current state of the hash buffer * @param state New hash buffer state */ setState(i) { const a = i.buffer, t = i.state, e = this._state; let s; for (this._dataLength = i.length, this._bufferLength = i.buflen, e[0] = t[0], e[1] = t[1], e[2] = t[2], e[3] = t[3], s = 0; s < a.length; s += 1) this._buffer8[s] = a.charCodeAt(s); } /** * Hash the current state of the hash buffer and return the result * @param raw Whether to return the value as an `Int32Array` */ end(i = false) { const a = this._bufferLength, t = this._buffer8, e = this._buffer32, s = (a >> 2) + 1; this._dataLength += a; const r = this._dataLength * 8; if (t[a] = 128, t[a + 1] = t[a + 2] = t[a + 3] = 0, e.set(_h.buffer32Identity.subarray(s), s), a > 55 && (_h._md5cycle(this._state, e), e.set(_h.buffer32Identity)), r <= 4294967295) e[14] = r; else { const n = r.toString(16).match(/(.*?)(.{0,8})$/); if (n === null) return i ? c : ""; const o = parseInt(n[2], 16), _ = parseInt(n[1], 16) || 0; e[14] = o, e[15] = _; } return _h._md5cycle(this._state, e), i ? this._state : _h._hex(this._state); } }; // Private Static Variables __publicField(_h, "stateIdentity", new Int32Array([ 1732584193, -271733879, -1732584194, 271733878 ])); __publicField(_h, "buffer32Identity", new Int32Array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ])); __publicField(_h, "hexChars", "0123456789abcdef"); __publicField(_h, "hexOut", []); // Permanent instance is to use for one-call hashing __publicField(_h, "onePassHasher", new _h()); let h = _h; if (h.hashStr("hello") !== "5d41402abc4b2a76b9719d911017c592") throw new Error("Md5 self test failed."); const mixinKeyEncTab = [ 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, 36, 20, 34, 44, 52 ]; function getMixinKey(orig) { return mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32); } function encWbi(params, img_key2, sub_key2) { const mixin_key = getMixinKey(img_key2 + sub_key2); const curr_time = Math.round(Date.now() / 1e3); const chr_filter = /[!'()*]/g; Object.assign(params, { wts: curr_time }); const query = Object.keys(params).sort().map((key) => { const value = params[key].toString().replace(chr_filter, ""); return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`; }).join("&"); const wbi_sign = h.hashStr(query + mixin_key); return `${query}&w_rid=${wbi_sign}`; } const relationToUploader = { relation: { mid: 0, attribute: 0, mtime: 0, tag: null, special: 0 }, be_relation: { mid: 0, attribute: 0, mtime: 0, tag: null, special: 0 } }; const relationResult = toResult(relationToUploader); const DmWebView = { nested: { bilibili: { nested: { community: { nested: { service: { nested: { dm: { nested: { v1: { nested: { DmWebViewReply: { fields: { state: { type: "int32", id: 1 }, text: { type: "string", id: 2 }, textSide: { type: "string", id: 3 }, dmSge: { type: "DmSegConfig", id: 4 }, flag: { type: "DanmakuFlagConfig", id: 5 }, specialDms: { rule: "repeated", type: "string", id: 6 }, checkBox: { type: "bool", id: 7 }, count: { type: "int64", id: 8 }, commandDms: { rule: "repeated", type: "CommandDm", id: 9 }, dmSetting: { type: "DanmuWebPlayerConfig", id: 10 }, reportFilter: { rule: "repeated", type: "string", id: 11 }, expressions: { rule: "repeated", type: "Expressions", id: 12 }, postPanel: { rule: "repeated", type: "PostPanel", id: 13 }, activityMetas: { rule: "repeated", type: "string", id: 14 }, postPanelV2: { rule: "repeated", type: "PostPanelV2", id: 15 }, subViews: { rule: "repeated", type: "DmSubView", id: 16 }, qoe: { type: "QoeInfo", id: 17 }, maskWalls: { rule: "repeated", type: "DmMaskWall", id: 18 }, dmRestrict: { type: "DMRestrict", id: 19 }, subtitle: { type: "VideoSubtitle", id: 20 } } }, DMRestrict: { fields: { periods: { rule: "repeated", type: "DMRestrictPeriod", id: 1 } } }, DMRestrictPeriod: { fields: { start: { type: "int64", id: 1 }, end: { type: "int64", id: 2 } } }, DmMaskWall: { fields: { start: { type: "int64", id: 1 }, end: { type: "int64", id: 2 }, content: { type: "string", id: 3 }, contentType: { type: "DmMaskWallContentType", id: 4 }, bizType: { type: "DmMaskWallBizType", id: 5 }, contents: { rule: "repeated", type: "DmMaskWallContent", id: 6 } } }, DmMaskWallBizType: { values: { DmMaskWallBizTypeUnknown: 0, DmMaskWallBizTypeOGV: 1, DmMaskWallBizTypeBizPic: 2, DmMaskWallBizTypeMute: 3, DmMaskWallBizTypeRecord: 4 } }, DmMaskWallContent: { fields: { type: { type: "DmMaskWallContentType", id: 1 }, content: { type: "string", id: 2 } } }, DmMaskWallContentType: { values: { DmMaskWallContentTypeUnknown: 0, DmMaskWallContentTypeText: 1, DmMaskWallContentTypePic: 2 } }, QoeInfo: { fields: { info: { type: "string", id: 1 } } }, PostPanel: { fields: { start: { type: "int64", id: 1 }, end: { type: "int64", id: 2 }, priority: { type: "int64", id: 3 }, bizId: { type: "int64", id: 4 }, bizType: { type: "PostPanelBizType", id: 5 }, clickButton: { type: "ClickButton", id: 6 }, textInput: { type: "TextInput", id: 7 }, checkBox: { type: "CheckBox", id: 8 }, toast: { type: "Toast", id: 9 } } }, PostPanelV2: { fields: { start: { type: "int64", id: 1 }, end: { type: "int64", id: 2 }, bizType: { type: "PostPanelBizType", id: 3 }, clickButton: { type: "ClickButtonV2", id: 4 }, textInput: { type: "TextInputV2", id: 5 }, checkBox: { type: "CheckBoxV2", id: 6 }, toast: { type: "ToastV2", id: 7 }, bubble: { type: "BubbleV2", id: 8 }, label: { type: "LabelV2", id: 9 }, postStatus: { type: "PostStatus", id: 10 } } }, ClickButton: { fields: { portraitText: { rule: "repeated", type: "string", id: 1 }, landscapeText: { rule: "repeated", type: "string", id: 2 }, portraitTextFocus: { rule: "repeated", type: "string", id: 3 }, landscapeTextFocus: { rule: "repeated", type: "string", id: 4 }, renderType: { type: "RenderType", id: 5 }, show: { type: "bool", id: 6 } } }, ClickButtonV2: { fields: { portraitText: { rule: "repeated", type: "string", id: 1 }, landscapeText: { rule: "repeated", type: "string", id: 2 }, portraitTextFocus: { rule: "repeated", type: "string", id: 3 }, landscapeTextFocus: { rule: "repeated", type: "string", id: 4 }, renderType: { type: "RenderType", id: 5 }, textInputPost: { type: "bool", id: 6 }, exposureOnce: { type: "bool", id: 7 }, exposureType: { type: "ExposureType", id: 8 } } }, PostPanelBizType: { values: { PostPanelBizTypeNone: 0, PostPanelBizTypeEncourage: 1, PostPanelBizTypeFragClose: 4, PostPanelBizTypeColorDM: 2 } }, TextInput: { fields: { portraitPlaceholder: { rule: "repeated", type: "string", id: 1 }, landscapePlaceholder: { rule: "repeated", type: "string", id: 2 }, renderType: { type: "RenderType", id: 3 }, placeholderPost: { type: "bool", id: 4 }, show: { type: "bool", id: 5 }, postStatus: { type: "PostStatus", id: 7 } } }, TextInputV2: { fields: { portraitPlaceholder: { rule: "repeated", type: "string", id: 1 }, landscapePlaceholder: { rule: "repeated", type: "string", id: 2 }, renderType: { type: "RenderType", id: 3 }, placeholderPost: { type: "bool", id: 4 }, textInputLimit: { type: "int32", id: 6 } } }, PostStatus: { values: { PostStatusNormal: 0, PostStatusClosed: 1 } }, RenderType: { values: { RenderTypeNone: 0, RenderTypeSingle: 1, RenderTypeRotation: 2 } }, CheckBox: { fields: { text: { type: "string", id: 1 }, type: { type: "CheckboxType", id: 2 }, defaultValue: { type: "bool", id: 3 }, show: { type: "bool", id: 4 } } }, CheckBoxV2: { fields: { text: { type: "string", id: 1 }, type: { type: "CheckboxType", id: 2 }, defaultValue: { type: "bool", id: 3 } } }, CheckboxType: { values: { CheckboxTypeNone: 0, CheckboxTypeEncourage: 1 } }, Toast: { fields: { text: { type: "string", id: 1 }, duration: { type: "int32", id: 2 }, show: { type: "bool", id: 3 }, button: { type: "Button", id: 4 } } }, ToastV2: { fields: { text: { type: "string", id: 1 }, duration: { type: "int32", id: 2 }, toastButtonV2: { type: "ToastButtonV2", id: 3 } } }, BubbleV2: { fields: { text: { type: "string", id: 1 }, url: { type: "string", id: 2 }, bubbleType: { type: "BubbleType", id: 3 }, exposureOnce: { type: "bool", id: 4 }, exposureType: { type: "ExposureType", id: 5 } } }, BubbleType: { values: { BubbleTypeNone: 0, BubbleTypeClickButton: 1, BubbleTypeDmSettingPanel: 2 } }, LabelV2: { fields: { title: { type: "string", id: 1 }, content: { rule: "repeated", type: "string", id: 2 }, exposureOnce: { type: "bool", id: 3 }, exposureType: { type: "ExposureType", id: 4 } } }, ExposureType: { values: { ExposureTypeNone: 0, ExposureTypeDMSend: 1 } }, ToastButtonV2: { fields: { text: { type: "string", id: 1 }, action: { type: "ToastFunctionType", id: 2 } } }, Button: { fields: { text: { type: "string", id: 1 }, action: { type: "ToastFunctionType", id: 2 } } }, ToastFunctionType: { values: { ToastFunctionTypeNone: 0, ToastFunctionTypePostPanel: 1 } }, ToastBizType: { values: { ToastBizTypeNone: 0, ToastBizTypeEncourage: 1 } }, CommandDm: { fields: { oid: { type: "int64", id: 2 }, mid: { type: "int64", id: 3 }, command: { type: "string", id: 4 }, text: { type: "string", id: 5 }, stime: { type: "int32", id: 6 }, ctime: { type: "string", id: 7 }, mtime: { type: "string", id: 8 }, extra: { type: "string", id: 9 }, dmid: { type: "string", id: 10 } } }, DmSegConfig: { fields: { pageSize: { type: "int64", id: 1 }, total: { type: "int64", id: 2 } } }, DanmakuFlagConfig: { fields: { recFlag: { type: "int32", id: 1 }, recText: { type: "string", id: 2 }, recSwitch: { type: "int32", id: 3 } } }, DmSegMobileReply: { fields: { elems: { rule: "repeated", type: "DanmakuElem", id: 1 }, colorfulSrc: { rule: "repeated", type: "DmColorful", id: 5 } } }, DanmakuElem: { fields: { stime: { type: "int32", id: 2 }, mode: { type: "int32", id: 3 }, size: { type: "int32", id: 4 }, color: { type: "uint32", id: 5 }, uhash: { type: "string", id: 6 }, text: { type: "string", id: 7 }, date: { type: "int64", id: 8 }, weight: { type: "int32", id: 9 }, action: { type: "string", id: 10 }, pool: { type: "int32", id: 11 }, dmid: { type: "string", id: 12 }, attr: { type: "int32", id: 13 }, animation: { type: "string", id: 22 }, colorful: { type: "DmColorfulType", id: 24 }, oid: { type: "int64", id: 26 }, dmFrom: { type: "DmFromType", id: 27 } } }, DmFromType: { values: { DmFromUnknown: 0, DmFromNormal: 1, DmFromCmd: 2, DmFromLive: 3 } }, DanmuWebPlayerConfig: { fields: { dmSwitch: { type: "bool", id: 1 }, aiSwitch: { type: "bool", id: 2 }, aiLevel: { type: "int32", id: 3 }, typeTop: { type: "bool", id: 4 }, typeScroll: { type: "bool", id: 5 }, typeBottom: { type: "bool", id: 6 }, typeColor: { type: "bool", id: 7 }, typeSpecial: { type: "bool", id: 8 }, preventshade: { type: "bool", id: 9 }, dmask: { type: "bool", id: 10 }, opacity: { type: "float", id: 11 }, speedplus: { type: "float", id: 13 }, fontsize: { type: "float", id: 14 }, fullscreensync: { type: "bool", id: 15 }, speedsync: { type: "bool", id: 16 }, fontfamily: { type: "string", id: 17 }, bold: { type: "bool", id: 18 }, fontborder: { type: "int32", id: 19 }, seniorModeSwitch: { type: "int32", id: 21 }, typeTopBottom: { type: "bool", id: 24 }, dmarea: { type: "int32", id: 25 }, dmdensity: { type: "int32", id: 26 } } }, Expressions: { fields: { data: { rule: "repeated", type: "Expression", id: 1 } } }, Expression: { fields: { keyword: { rule: "repeated", type: "string", id: 1 }, url: { type: "string", id: 2 }, period: { rule: "repeated", type: "Period", id: 3 } } }, Period: { fields: { start: { type: "int64", id: 1 }, end: { type: "int64", id: 2 } } }, AnyBody: { fields: { body: { type: "google.protobuf.Any", id: 1 } } }, DmColorful: { fields: { type: { type: "DmColorfulType", id: 1 }, src: { type: "string", id: 2 } } }, DmColorfulType: { values: { NoneType: 0, VipGradualColor: 60001 } }, DmSubView: { fields: { type: { type: "int32", id: 1 }, oid: { type: "int64", id: 2 }, pid: { type: "int64", id: 3 }, postPanel_2: { rule: "repeated", type: "PostPanelV2", id: 4 } } }, VideoSubtitle: { fields: { lan: { type: "string", id: 1 }, lanDoc: { type: "string", id: 2 }, subtitles: { rule: "repeated", type: "SubtitleItem", id: 3 }, subtitlePosition: { type: "SubtitlePosition", id: 4 }, fontSizeType: { type: "FontSizeType", id: 5 } } }, SubtitleType: { values: { CC: 0, AI: 1 } }, SubtitleAiType: { values: { Normal: 0, Translate: 1 } }, SubtitleAiStatus: { values: { None: 0, Exposure: 1, Assist: 2 } }, SubtitleRole: { values: { Default: 0, Main: 1, Secondary: 2 } }, SubtitleItem: { fields: { id: { type: "int64", id: 1 }, idStr: { type: "string", id: 2 }, lan: { type: "string", id: 3 }, lanDoc: { type: "string", id: 4 }, subtitleUrl: { type: "string", id: 5 }, author: { type: "UserInfo", id: 6 }, type: { type: "SubtitleType", id: 7 }, lanDocBrief: { type: "string", id: 8 }, aiType: { type: "SubtitleAiType", id: 9 }, aiStatus: { type: "SubtitleAiStatus", id: 10 }, role: { type: "SubtitleRole", id: 11 }, subtitleHeight: { type: "SubtitleHeight", id: 12 } } }, SubtitlePosition: { fields: { xMin: { type: "double", id: 1 }, yMin: { type: "double", id: 2 }, xMax: { type: "double", id: 3 }, yMax: { type: "double", id: 4 }, purpose: { type: "PurposeType", id: 5 } } }, PurposeType: { values: { PurposeCover: 0, PurposeOGV: 1 } }, FontSizeType: { values: { FontSizeDefault: 0, FontSizeOGV: 1 } }, SubtitleHeight: { fields: { value: { type: "double", id: 1 } } }, UserInfo: { fields: { mid: { type: "int64", id: 1 }, name: { type: "string", id: 2 }, sex: { type: "string", id: 3 }, face: { type: "string", id: 4 }, sign: { type: "string", id: 5 }, rank: { type: "int32", id: 6 } } } } } } } } } } } } }, google: { nested: { protobuf: { nested: { Any: { fields: { type_url: { type: "string", id: 1 }, value: { type: "bytes", id: 2 } } } } } } } } }; function useSubtitleCrypt() { const keyCandidates = [ ['nP](wOFRvU.+<fjS{jn-!$D|Dz&",zT`', "=CFxYRn{.y|uVyO$uh&sikph?N.ilF/`"], ['Bn"q~|albg@]Go~ACgyDvKnd+)_D}^&J?', "Cu~L!xs~f^&r@'vh=q]q{eeng*sEg^kp#J"] ]; function xorDecrypt(cipherText, key) { let plainText = ""; for (let index = 0; index < cipherText.length; index++) { const cipherCharCode = cipherText.charCodeAt(index); const keyCharCode = key.charCodeAt(index % key.length); plainText += String.fromCharCode(cipherCharCode ^ keyCharCode); } return plainText; } function xorEncrypt(plainText, key) { let result = ""; for (let i = 0; i < plainText.length; i++) { result += String.fromCharCode(plainText.charCodeAt(i) ^ key.charCodeAt(i % key.length)); } return result; } function decryptSubtitle2(encodedPath) { for (const keyPair of keyCandidates) { const expectedPrefix = keyPair[0]; const keySeed = keyPair[1]; const fullKey = keySeed + "bilibili"; const decryptedText = xorDecrypt(decodeURIComponent(encodedPath), fullKey); if (decryptedText.startsWith(expectedPrefix)) return decryptedText.split(expectedPrefix)[1]; } return null; } function encryptSubtitle2(plainText) { const keyPair = keyCandidates[0]; const expectedPrefix = keyPair[0]; const keySeed = keyPair[1]; const fullKey = keySeed + "bilibili"; return encodeURIComponent(xorEncrypt(expectedPrefix + plainText, fullKey)); } return { /** 解密字幕 */ decryptSubtitle: decryptSubtitle2, /** 加密字幕 */ encryptSubtitle: encryptSubtitle2 }; } const { encryptSubtitle } = useSubtitleCrypt(); function getEncryptSubtitle(url) { const domain = "//subtitle.bilibili.com"; const fullUrl = url.startsWith("http") || url.startsWith("https") ? url : "http:" + url; const parsed = new URL(fullUrl); const path = parsed.pathname; const authKey = parsed.searchParams.get("auth_key"); return `${domain}/${encryptSubtitle(path)}?auth_key=${authKey}`; } class Lifecycle { constructor() { __publicField(this, "lifecycleMap", { loading: [], interactive: [], complete: [] }); __publicField(this, "initialized", false); } initListener() { if (this.initialized) return; this.initialized = true; document.addEventListener("readystatechange", () => { const state = document.readyState; const callbacks = this.lifecycleMap[state]; if (callbacks == null ? void 0 : callbacks.length) { callbacks.forEach((fn) => { try { fn(); } catch (err) { console.error("[lifecycle]", err); } }); this.lifecycleMap[state] = []; } }); } /** * 注册生命周期函数 * @param state document的readystate * @param fn 对应生命周期的hook函数 */ register(state, fn) { this.initListener(); if (document.readyState === state || // 已经到此阶段 state === "interactive" && document.readyState === "complete") { fn(); } else { this.lifecycleMap[state].push(fn); } } } const lifecycle = new Lifecycle(); const onDocInteractive = (fn) => lifecycle.register("interactive", fn); async function fetchSubtitle(aid, cid) { const url = `https://api.bilibili.com/x/v2/dm/view?aid=${aid}&oid=${cid}&type=1`; return await fetch(url).then((result) => { return result.json(); }).then((result) => { return result.data.subtitle; }).catch(() => null); } function useSubtitle() { const subtitleCache = { current: new Promise((resolve) => { onDocInteractive(() => { const { aid, cid } = window.vd ?? {}; aid && cid ? resolve(fetchSubtitle(aid, cid)) : resolve(null); }); }) }; function setSubtitle(aid, cid) { if (aid && cid) { subtitleCache.current = fetchSubtitle(aid, cid); } else { subtitleCache.current = Promise.resolve(null); } } function camelizeSubtitle(subtitle) { const camelizedSubtitle = mapKeys(subtitle, (_v, k) => camelCase(k)); const camelizedSubtitles = subtitle.subtitles.map((subtitle2) => { return { ...mapKeys(subtitle2, (_v, k) => camelCase(k)) }; }); camelizedSubtitle.subtitles = camelizedSubtitles; return camelizedSubtitle; } return { subtitleCache, setSubtitle, camelizeSubtitle }; } const usePlayer = (request) => { if (!request.url.includes("/x/player/wbi/v2")) return; request.response = async (res) => { const playerResponse = JSON.parse(res.responseText); playerResponse.data.login_mid = Math.floor(Math.random() * 1e5); playerResponse.data.need_login_subtitle = false; playerResponse.data.level_info.current_level = 6; res.responseText = JSON.stringify(playerResponse); }; }; const usePlayurl = (request) => { if (!request.url.includes("api.bilibili.com/x/player/wbi/playurl")) return; const qsParams = Object.fromEntries(new URLSearchParams(request.url.split(/\?|&w_rid/)[1]).entries()); Reflect.set(qsParams, "qn", 80); Reflect.set(qsParams, "try_look", 1); const query = encWbi(qsParams, img_key, sub_key); request.url = `//api.bilibili.com/x/player/wbi/playurl?${query}`; request.response = (res) => { Object.defineProperty(window, "__playinfo__", { get() { return JSON.parse(res.responseText ?? "{}"); }, configurable: true }); }; }; const useRelation = (request) => { if (!request.url.includes("/x/web-interface/relation")) return; request.response = (res) => { res.responseText = JSON.stringify(relationResult); }; }; const useDmView = () => { let isFirstRequest = true; const { subtitleCache, setSubtitle, camelizeSubtitle } = useSubtitle(); return (request) => { if (!request.url.includes("/x/v2/dm/web/view")) return; const payload = Object.fromEntries(new URL("https:" + request.url).searchParams.entries()); if (!isFirstRequest) setSubtitle(payload.pid, payload.oid); isFirstRequest = false; request.response = async (res) => { const root2 = protobuf.Root.fromJSON(DmWebView); const DmWebViewReply = root2.lookupType("bilibili.community.service.dm.v1.DmWebViewReply"); const message = DmWebViewReply.decode(new Uint8Array(res.response)); const dmMetaData = DmWebViewReply.toObject(message, { defaults: false }); const subtitle = await subtitleCache.current; const camelizedSubtitle = subtitle ? camelizeSubtitle(subtitle) : null; if (camelizedSubtitle) { const camelizedSubtitles = camelizedSubtitle.subtitles.map((subtitle2) => { return { ...subtitle2, // 字幕 URI 加密 subtitleUrl: getEncryptSubtitle(subtitle2.subtitleUrl) }; }); camelizedSubtitle.subtitles = camelizedSubtitles; } dmMetaData.subtitle = camelizedSubtitle; const encodedMessage = DmWebViewReply.create(dmMetaData); const encodedBuffer = DmWebViewReply.encode(encodedMessage).finish(); res.response = encodedBuffer; }; }; }; const video = [usePlayer, usePlayurl, useRelation, useDmView()]; const www = [...history, ...video]; const domainConfig = { /** 不应该被任何钩子拦截的页面 */ blackList: ["passport"], /** 共享 request hook */ sharedHook: [...shared], /** 各二级域名对应的 request hook */ children: [ { name: "www", hook: [...www], action: [ () => { Object.defineProperty(window, "__playinfo__", { get: () => null, configurable: true }); } ] }, // 搜索页 { name: "search", hook: [...search] }, // 用户空间 { name: "space", hook: [...space] }, // 直播页 { name: "live", hook: [], action: [start] } ] }; document.cookie = `DedeUserID=${random(2 ** 53)}`; const subdomain = location.host.split(".").shift(); if (subdomain && !domainConfig.blackList.includes(subdomain)) { domainConfig.sharedHook.forEach((hook) => { onRequest(hook); }); const domainItem = domainConfig.children.find((item) => item.name === subdomain); if (domainItem) { domainItem.hook.forEach((hook) => { onRequest(hook); }); (_a = domainItem.action) == null ? void 0 : _a.forEach((action) => { action(); }); } } } }); require_main_001(); })(VueReactivity, protobuf);