Last active
July 8, 2022 10:23
-
-
Save tkit1994/cace80dfd3487af8ff6e43061b54e5db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name LeetcodeCopy | |
| // @version 1.0.1 | |
| // @description Add a copy button in leetcode.cn's editor to copy code in vim mode | |
| // @author HaoCheng | |
| // @namespace com.github.tkit1994 | |
| // @license MIT | |
| // @homepage https://github.com/tkit1994/leetcode-copy | |
| // @updateURL https://gist.github.com/tkit1994/cace80dfd3487af8ff6e43061b54e5db/raw/leetcode-copy.user.js | |
| // @downloadURL https://gist.github.com/tkit1994/cace80dfd3487af8ff6e43061b54e5db/raw/leetcode-copy.user.js | |
| // @supportURL https://github.com/tkit1994/leetcode-copy | |
| // @match https://leetcode.cn/problems/* | |
| // @run-at document-body | |
| // @grant GM_setClipboard | |
| // ==/UserScript== | |
| (function() { | |
| "use strict"; | |
| ; | |
| var axios$2 = { exports: {} }; | |
| var bind$2 = function bind2(fn, thisArg) { | |
| return function wrap() { | |
| var args = new Array(arguments.length); | |
| for (var i = 0; i < args.length; i++) { | |
| args[i] = arguments[i]; | |
| } | |
| return fn.apply(thisArg, args); | |
| }; | |
| }; | |
| var bind$1 = bind$2; | |
| var toString = Object.prototype.toString; | |
| var kindOf = function(cache) { | |
| return function(thing) { | |
| var str = toString.call(thing); | |
| return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase()); | |
| }; | |
| }(/* @__PURE__ */ Object.create(null)); | |
| function kindOfTest(type) { | |
| type = type.toLowerCase(); | |
| return function isKindOf(thing) { | |
| return kindOf(thing) === type; | |
| }; | |
| } | |
| function isArray(val) { | |
| return Array.isArray(val); | |
| } | |
| function isUndefined(val) { | |
| return typeof val === "undefined"; | |
| } | |
| function isBuffer(val) { | |
| return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val); | |
| } | |
| var isArrayBuffer = kindOfTest("ArrayBuffer"); | |
| function isArrayBufferView(val) { | |
| var result; | |
| if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) { | |
| result = ArrayBuffer.isView(val); | |
| } else { | |
| result = val && val.buffer && isArrayBuffer(val.buffer); | |
| } | |
| return result; | |
| } | |
| function isString(val) { | |
| return typeof val === "string"; | |
| } | |
| function isNumber(val) { | |
| return typeof val === "number"; | |
| } | |
| function isObject(val) { | |
| return val !== null && typeof val === "object"; | |
| } | |
| function isPlainObject(val) { | |
| if (kindOf(val) !== "object") { | |
| return false; | |
| } | |
| var prototype2 = Object.getPrototypeOf(val); | |
| return prototype2 === null || prototype2 === Object.prototype; | |
| } | |
| var isDate = kindOfTest("Date"); | |
| var isFile = kindOfTest("File"); | |
| var isBlob = kindOfTest("Blob"); | |
| var isFileList = kindOfTest("FileList"); | |
| function isFunction(val) { | |
| return toString.call(val) === "[object Function]"; | |
| } | |
| function isStream(val) { | |
| return isObject(val) && isFunction(val.pipe); | |
| } | |
| function isFormData(thing) { | |
| var pattern = "[object FormData]"; | |
| return thing && (typeof FormData === "function" && thing instanceof FormData || toString.call(thing) === pattern || isFunction(thing.toString) && thing.toString() === pattern); | |
| } | |
| var isURLSearchParams = kindOfTest("URLSearchParams"); | |
| function trim(str) { | |
| return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ""); | |
| } | |
| function isStandardBrowserEnv() { | |
| if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) { | |
| return false; | |
| } | |
| return typeof window !== "undefined" && typeof document !== "undefined"; | |
| } | |
| function forEach(obj, fn) { | |
| if (obj === null || typeof obj === "undefined") { | |
| return; | |
| } | |
| if (typeof obj !== "object") { | |
| obj = [obj]; | |
| } | |
| if (isArray(obj)) { | |
| for (var i = 0, l = obj.length; i < l; i++) { | |
| fn.call(null, obj[i], i, obj); | |
| } | |
| } else { | |
| for (var key in obj) { | |
| if (Object.prototype.hasOwnProperty.call(obj, key)) { | |
| fn.call(null, obj[key], key, obj); | |
| } | |
| } | |
| } | |
| } | |
| function merge() { | |
| var result = {}; | |
| function assignValue(val, key) { | |
| if (isPlainObject(result[key]) && isPlainObject(val)) { | |
| result[key] = merge(result[key], val); | |
| } else if (isPlainObject(val)) { | |
| result[key] = merge({}, val); | |
| } else if (isArray(val)) { | |
| result[key] = val.slice(); | |
| } else { | |
| result[key] = val; | |
| } | |
| } | |
| for (var i = 0, l = arguments.length; i < l; i++) { | |
| forEach(arguments[i], assignValue); | |
| } | |
| return result; | |
| } | |
| function extend(a, b, thisArg) { | |
| forEach(b, function assignValue(val, key) { | |
| if (thisArg && typeof val === "function") { | |
| a[key] = bind$1(val, thisArg); | |
| } else { | |
| a[key] = val; | |
| } | |
| }); | |
| return a; | |
| } | |
| function stripBOM(content) { | |
| if (content.charCodeAt(0) === 65279) { | |
| content = content.slice(1); | |
| } | |
| return content; | |
| } | |
| function inherits(constructor, superConstructor, props, descriptors2) { | |
| constructor.prototype = Object.create(superConstructor.prototype, descriptors2); | |
| constructor.prototype.constructor = constructor; | |
| props && Object.assign(constructor.prototype, props); | |
| } | |
| function toFlatObject(sourceObj, destObj, filter) { | |
| var props; | |
| var i; | |
| var prop; | |
| var merged = {}; | |
| destObj = destObj || {}; | |
| do { | |
| props = Object.getOwnPropertyNames(sourceObj); | |
| i = props.length; | |
| while (i-- > 0) { | |
| prop = props[i]; | |
| if (!merged[prop]) { | |
| destObj[prop] = sourceObj[prop]; | |
| merged[prop] = true; | |
| } | |
| } | |
| sourceObj = Object.getPrototypeOf(sourceObj); | |
| } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype); | |
| return destObj; | |
| } | |
| function endsWith(str, searchString, position) { | |
| str = String(str); | |
| if (position === void 0 || position > str.length) { | |
| position = str.length; | |
| } | |
| position -= searchString.length; | |
| var lastIndex = str.indexOf(searchString, position); | |
| return lastIndex !== -1 && lastIndex === position; | |
| } | |
| function toArray(thing) { | |
| if (!thing) | |
| return null; | |
| var i = thing.length; | |
| if (isUndefined(i)) | |
| return null; | |
| var arr = new Array(i); | |
| while (i-- > 0) { | |
| arr[i] = thing[i]; | |
| } | |
| return arr; | |
| } | |
| var isTypedArray = function(TypedArray) { | |
| return function(thing) { | |
| return TypedArray && thing instanceof TypedArray; | |
| }; | |
| }(typeof Uint8Array !== "undefined" && Object.getPrototypeOf(Uint8Array)); | |
| var utils$h = { | |
| isArray, | |
| isArrayBuffer, | |
| isBuffer, | |
| isFormData, | |
| isArrayBufferView, | |
| isString, | |
| isNumber, | |
| isObject, | |
| isPlainObject, | |
| isUndefined, | |
| isDate, | |
| isFile, | |
| isBlob, | |
| isFunction, | |
| isStream, | |
| isURLSearchParams, | |
| isStandardBrowserEnv, | |
| forEach, | |
| merge, | |
| extend, | |
| trim, | |
| stripBOM, | |
| inherits, | |
| toFlatObject, | |
| kindOf, | |
| kindOfTest, | |
| endsWith, | |
| toArray, | |
| isTypedArray, | |
| isFileList | |
| }; | |
| var utils$g = utils$h; | |
| function encode(val) { | |
| return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]"); | |
| } | |
| var buildURL$2 = function buildURL2(url, params, paramsSerializer) { | |
| if (!params) { | |
| return url; | |
| } | |
| var serializedParams; | |
| if (paramsSerializer) { | |
| serializedParams = paramsSerializer(params); | |
| } else if (utils$g.isURLSearchParams(params)) { | |
| serializedParams = params.toString(); | |
| } else { | |
| var parts = []; | |
| utils$g.forEach(params, function serialize(val, key) { | |
| if (val === null || typeof val === "undefined") { | |
| return; | |
| } | |
| if (utils$g.isArray(val)) { | |
| key = key + "[]"; | |
| } else { | |
| val = [val]; | |
| } | |
| utils$g.forEach(val, function parseValue(v) { | |
| if (utils$g.isDate(v)) { | |
| v = v.toISOString(); | |
| } else if (utils$g.isObject(v)) { | |
| v = JSON.stringify(v); | |
| } | |
| parts.push(encode(key) + "=" + encode(v)); | |
| }); | |
| }); | |
| serializedParams = parts.join("&"); | |
| } | |
| if (serializedParams) { | |
| var hashmarkIndex = url.indexOf("#"); | |
| if (hashmarkIndex !== -1) { | |
| url = url.slice(0, hashmarkIndex); | |
| } | |
| url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams; | |
| } | |
| return url; | |
| }; | |
| var utils$f = utils$h; | |
| function InterceptorManager$1() { | |
| this.handlers = []; | |
| } | |
| InterceptorManager$1.prototype.use = function use(fulfilled, rejected, options) { | |
| this.handlers.push({ | |
| fulfilled, | |
| rejected, | |
| synchronous: options ? options.synchronous : false, | |
| runWhen: options ? options.runWhen : null | |
| }); | |
| return this.handlers.length - 1; | |
| }; | |
| InterceptorManager$1.prototype.eject = function eject(id) { | |
| if (this.handlers[id]) { | |
| this.handlers[id] = null; | |
| } | |
| }; | |
| InterceptorManager$1.prototype.forEach = function forEach2(fn) { | |
| utils$f.forEach(this.handlers, function forEachHandler(h) { | |
| if (h !== null) { | |
| fn(h); | |
| } | |
| }); | |
| }; | |
| var InterceptorManager_1 = InterceptorManager$1; | |
| var utils$e = utils$h; | |
| var normalizeHeaderName$1 = function normalizeHeaderName2(headers, normalizedName) { | |
| utils$e.forEach(headers, function processHeader(value, name) { | |
| if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { | |
| headers[normalizedName] = value; | |
| delete headers[name]; | |
| } | |
| }); | |
| }; | |
| var utils$d = utils$h; | |
| function AxiosError$5(message, code, config, request, response) { | |
| Error.call(this); | |
| this.message = message; | |
| this.name = "AxiosError"; | |
| code && (this.code = code); | |
| config && (this.config = config); | |
| request && (this.request = request); | |
| response && (this.response = response); | |
| } | |
| utils$d.inherits(AxiosError$5, Error, { | |
| toJSON: function toJSON() { | |
| return { | |
| message: this.message, | |
| name: this.name, | |
| description: this.description, | |
| number: this.number, | |
| fileName: this.fileName, | |
| lineNumber: this.lineNumber, | |
| columnNumber: this.columnNumber, | |
| stack: this.stack, | |
| config: this.config, | |
| code: this.code, | |
| status: this.response && this.response.status ? this.response.status : null | |
| }; | |
| } | |
| }); | |
| var prototype = AxiosError$5.prototype; | |
| var descriptors = {}; | |
| [ | |
| "ERR_BAD_OPTION_VALUE", | |
| "ERR_BAD_OPTION", | |
| "ECONNABORTED", | |
| "ETIMEDOUT", | |
| "ERR_NETWORK", | |
| "ERR_FR_TOO_MANY_REDIRECTS", | |
| "ERR_DEPRECATED", | |
| "ERR_BAD_RESPONSE", | |
| "ERR_BAD_REQUEST", | |
| "ERR_CANCELED" | |
| ].forEach(function(code) { | |
| descriptors[code] = { value: code }; | |
| }); | |
| Object.defineProperties(AxiosError$5, descriptors); | |
| Object.defineProperty(prototype, "isAxiosError", { value: true }); | |
| AxiosError$5.from = function(error, code, config, request, response, customProps) { | |
| var axiosError = Object.create(prototype); | |
| utils$d.toFlatObject(error, axiosError, function filter(obj) { | |
| return obj !== Error.prototype; | |
| }); | |
| AxiosError$5.call(axiosError, error.message, code, config, request, response); | |
| axiosError.name = error.name; | |
| customProps && Object.assign(axiosError, customProps); | |
| return axiosError; | |
| }; | |
| var AxiosError_1 = AxiosError$5; | |
| var transitional = { | |
| silentJSONParsing: true, | |
| forcedJSONParsing: true, | |
| clarifyTimeoutError: false | |
| }; | |
| var utils$c = utils$h; | |
| function toFormData$1(obj, formData) { | |
| formData = formData || new FormData(); | |
| var stack = []; | |
| function convertValue(value) { | |
| if (value === null) | |
| return ""; | |
| if (utils$c.isDate(value)) { | |
| return value.toISOString(); | |
| } | |
| if (utils$c.isArrayBuffer(value) || utils$c.isTypedArray(value)) { | |
| return typeof Blob === "function" ? new Blob([value]) : Buffer.from(value); | |
| } | |
| return value; | |
| } | |
| function build(data2, parentKey) { | |
| if (utils$c.isPlainObject(data2) || utils$c.isArray(data2)) { | |
| if (stack.indexOf(data2) !== -1) { | |
| throw Error("Circular reference detected in " + parentKey); | |
| } | |
| stack.push(data2); | |
| utils$c.forEach(data2, function each(value, key) { | |
| if (utils$c.isUndefined(value)) | |
| return; | |
| var fullKey = parentKey ? parentKey + "." + key : key; | |
| var arr; | |
| if (value && !parentKey && typeof value === "object") { | |
| if (utils$c.endsWith(key, "{}")) { | |
| value = JSON.stringify(value); | |
| } else if (utils$c.endsWith(key, "[]") && (arr = utils$c.toArray(value))) { | |
| arr.forEach(function(el) { | |
| !utils$c.isUndefined(el) && formData.append(fullKey, convertValue(el)); | |
| }); | |
| return; | |
| } | |
| } | |
| build(value, fullKey); | |
| }); | |
| stack.pop(); | |
| } else { | |
| formData.append(parentKey, convertValue(data2)); | |
| } | |
| } | |
| build(obj); | |
| return formData; | |
| } | |
| var toFormData_1 = toFormData$1; | |
| var AxiosError$4 = AxiosError_1; | |
| var settle$1 = function settle2(resolve, reject, response) { | |
| var validateStatus = response.config.validateStatus; | |
| if (!response.status || !validateStatus || validateStatus(response.status)) { | |
| resolve(response); | |
| } else { | |
| reject(new AxiosError$4("Request failed with status code " + response.status, [AxiosError$4.ERR_BAD_REQUEST, AxiosError$4.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response)); | |
| } | |
| }; | |
| var utils$b = utils$h; | |
| var cookies$1 = utils$b.isStandardBrowserEnv() ? function standardBrowserEnv() { | |
| return { | |
| write: function write(name, value, expires, path, domain, secure) { | |
| var cookie = []; | |
| cookie.push(name + "=" + encodeURIComponent(value)); | |
| if (utils$b.isNumber(expires)) { | |
| cookie.push("expires=" + new Date(expires).toGMTString()); | |
| } | |
| if (utils$b.isString(path)) { | |
| cookie.push("path=" + path); | |
| } | |
| if (utils$b.isString(domain)) { | |
| cookie.push("domain=" + domain); | |
| } | |
| if (secure === true) { | |
| cookie.push("secure"); | |
| } | |
| document.cookie = cookie.join("; "); | |
| }, | |
| read: function read(name) { | |
| var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)")); | |
| return match ? decodeURIComponent(match[3]) : null; | |
| }, | |
| remove: function remove(name) { | |
| this.write(name, "", Date.now() - 864e5); | |
| } | |
| }; | |
| }() : function nonStandardBrowserEnv() { | |
| return { | |
| write: function write() { | |
| }, | |
| read: function read() { | |
| return null; | |
| }, | |
| remove: function remove() { | |
| } | |
| }; | |
| }(); | |
| var isAbsoluteURL$1 = function isAbsoluteURL2(url) { | |
| return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); | |
| }; | |
| var combineURLs$1 = function combineURLs2(baseURL, relativeURL) { | |
| return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL; | |
| }; | |
| var isAbsoluteURL = isAbsoluteURL$1; | |
| var combineURLs = combineURLs$1; | |
| var buildFullPath$2 = function buildFullPath2(baseURL, requestedURL) { | |
| if (baseURL && !isAbsoluteURL(requestedURL)) { | |
| return combineURLs(baseURL, requestedURL); | |
| } | |
| return requestedURL; | |
| }; | |
| var utils$a = utils$h; | |
| var ignoreDuplicateOf = [ | |
| "age", | |
| "authorization", | |
| "content-length", | |
| "content-type", | |
| "etag", | |
| "expires", | |
| "from", | |
| "host", | |
| "if-modified-since", | |
| "if-unmodified-since", | |
| "last-modified", | |
| "location", | |
| "max-forwards", | |
| "proxy-authorization", | |
| "referer", | |
| "retry-after", | |
| "user-agent" | |
| ]; | |
| var parseHeaders$1 = function parseHeaders2(headers) { | |
| var parsed = {}; | |
| var key; | |
| var val; | |
| var i; | |
| if (!headers) { | |
| return parsed; | |
| } | |
| utils$a.forEach(headers.split("\n"), function parser(line) { | |
| i = line.indexOf(":"); | |
| key = utils$a.trim(line.substr(0, i)).toLowerCase(); | |
| val = utils$a.trim(line.substr(i + 1)); | |
| if (key) { | |
| if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { | |
| return; | |
| } | |
| if (key === "set-cookie") { | |
| parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); | |
| } else { | |
| parsed[key] = parsed[key] ? parsed[key] + ", " + val : val; | |
| } | |
| } | |
| }); | |
| return parsed; | |
| }; | |
| var utils$9 = utils$h; | |
| var isURLSameOrigin$1 = utils$9.isStandardBrowserEnv() ? function standardBrowserEnv() { | |
| var msie = /(msie|trident)/i.test(navigator.userAgent); | |
| var urlParsingNode = document.createElement("a"); | |
| var originURL; | |
| function resolveURL(url) { | |
| var href = url; | |
| if (msie) { | |
| urlParsingNode.setAttribute("href", href); | |
| href = urlParsingNode.href; | |
| } | |
| urlParsingNode.setAttribute("href", href); | |
| return { | |
| href: urlParsingNode.href, | |
| protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "", | |
| host: urlParsingNode.host, | |
| search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "", | |
| hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "", | |
| hostname: urlParsingNode.hostname, | |
| port: urlParsingNode.port, | |
| pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname | |
| }; | |
| } | |
| originURL = resolveURL(window.location.href); | |
| return function isURLSameOrigin2(requestURL) { | |
| var parsed = utils$9.isString(requestURL) ? resolveURL(requestURL) : requestURL; | |
| return parsed.protocol === originURL.protocol && parsed.host === originURL.host; | |
| }; | |
| }() : function nonStandardBrowserEnv() { | |
| return function isURLSameOrigin2() { | |
| return true; | |
| }; | |
| }(); | |
| var AxiosError$3 = AxiosError_1; | |
| var utils$8 = utils$h; | |
| function CanceledError$3(message) { | |
| AxiosError$3.call(this, message == null ? "canceled" : message, AxiosError$3.ERR_CANCELED); | |
| this.name = "CanceledError"; | |
| } | |
| utils$8.inherits(CanceledError$3, AxiosError$3, { | |
| __CANCEL__: true | |
| }); | |
| var CanceledError_1 = CanceledError$3; | |
| var parseProtocol$1 = function parseProtocol2(url) { | |
| var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url); | |
| return match && match[1] || ""; | |
| }; | |
| var utils$7 = utils$h; | |
| var settle = settle$1; | |
| var cookies = cookies$1; | |
| var buildURL$1 = buildURL$2; | |
| var buildFullPath$1 = buildFullPath$2; | |
| var parseHeaders = parseHeaders$1; | |
| var isURLSameOrigin = isURLSameOrigin$1; | |
| var transitionalDefaults$1 = transitional; | |
| var AxiosError$2 = AxiosError_1; | |
| var CanceledError$2 = CanceledError_1; | |
| var parseProtocol = parseProtocol$1; | |
| var xhr = function xhrAdapter(config) { | |
| return new Promise(function dispatchXhrRequest(resolve, reject) { | |
| var requestData = config.data; | |
| var requestHeaders = config.headers; | |
| var responseType = config.responseType; | |
| var onCanceled; | |
| function done() { | |
| if (config.cancelToken) { | |
| config.cancelToken.unsubscribe(onCanceled); | |
| } | |
| if (config.signal) { | |
| config.signal.removeEventListener("abort", onCanceled); | |
| } | |
| } | |
| if (utils$7.isFormData(requestData) && utils$7.isStandardBrowserEnv()) { | |
| delete requestHeaders["Content-Type"]; | |
| } | |
| var request = new XMLHttpRequest(); | |
| if (config.auth) { | |
| var username = config.auth.username || ""; | |
| var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ""; | |
| requestHeaders.Authorization = "Basic " + btoa(username + ":" + password); | |
| } | |
| var fullPath = buildFullPath$1(config.baseURL, config.url); | |
| request.open(config.method.toUpperCase(), buildURL$1(fullPath, config.params, config.paramsSerializer), true); | |
| request.timeout = config.timeout; | |
| function onloadend() { | |
| if (!request) { | |
| return; | |
| } | |
| var responseHeaders = "getAllResponseHeaders" in request ? parseHeaders(request.getAllResponseHeaders()) : null; | |
| var responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response; | |
| var response = { | |
| data: responseData, | |
| status: request.status, | |
| statusText: request.statusText, | |
| headers: responseHeaders, | |
| config, | |
| request | |
| }; | |
| settle(function _resolve(value) { | |
| resolve(value); | |
| done(); | |
| }, function _reject(err) { | |
| reject(err); | |
| done(); | |
| }, response); | |
| request = null; | |
| } | |
| if ("onloadend" in request) { | |
| request.onloadend = onloadend; | |
| } else { | |
| request.onreadystatechange = function handleLoad() { | |
| if (!request || request.readyState !== 4) { | |
| return; | |
| } | |
| if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) { | |
| return; | |
| } | |
| setTimeout(onloadend); | |
| }; | |
| } | |
| request.onabort = function handleAbort() { | |
| if (!request) { | |
| return; | |
| } | |
| reject(new AxiosError$2("Request aborted", AxiosError$2.ECONNABORTED, config, request)); | |
| request = null; | |
| }; | |
| request.onerror = function handleError() { | |
| reject(new AxiosError$2("Network Error", AxiosError$2.ERR_NETWORK, config, request, request)); | |
| request = null; | |
| }; | |
| request.ontimeout = function handleTimeout() { | |
| var timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded"; | |
| var transitional2 = config.transitional || transitionalDefaults$1; | |
| if (config.timeoutErrorMessage) { | |
| timeoutErrorMessage = config.timeoutErrorMessage; | |
| } | |
| reject(new AxiosError$2(timeoutErrorMessage, transitional2.clarifyTimeoutError ? AxiosError$2.ETIMEDOUT : AxiosError$2.ECONNABORTED, config, request)); | |
| request = null; | |
| }; | |
| if (utils$7.isStandardBrowserEnv()) { | |
| var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : void 0; | |
| if (xsrfValue) { | |
| requestHeaders[config.xsrfHeaderName] = xsrfValue; | |
| } | |
| } | |
| if ("setRequestHeader" in request) { | |
| utils$7.forEach(requestHeaders, function setRequestHeader(val, key) { | |
| if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") { | |
| delete requestHeaders[key]; | |
| } else { | |
| request.setRequestHeader(key, val); | |
| } | |
| }); | |
| } | |
| if (!utils$7.isUndefined(config.withCredentials)) { | |
| request.withCredentials = !!config.withCredentials; | |
| } | |
| if (responseType && responseType !== "json") { | |
| request.responseType = config.responseType; | |
| } | |
| if (typeof config.onDownloadProgress === "function") { | |
| request.addEventListener("progress", config.onDownloadProgress); | |
| } | |
| if (typeof config.onUploadProgress === "function" && request.upload) { | |
| request.upload.addEventListener("progress", config.onUploadProgress); | |
| } | |
| if (config.cancelToken || config.signal) { | |
| onCanceled = function(cancel) { | |
| if (!request) { | |
| return; | |
| } | |
| reject(!cancel || cancel && cancel.type ? new CanceledError$2() : cancel); | |
| request.abort(); | |
| request = null; | |
| }; | |
| config.cancelToken && config.cancelToken.subscribe(onCanceled); | |
| if (config.signal) { | |
| config.signal.aborted ? onCanceled() : config.signal.addEventListener("abort", onCanceled); | |
| } | |
| } | |
| if (!requestData) { | |
| requestData = null; | |
| } | |
| var protocol = parseProtocol(fullPath); | |
| if (protocol && ["http", "https", "file"].indexOf(protocol) === -1) { | |
| reject(new AxiosError$2("Unsupported protocol " + protocol + ":", AxiosError$2.ERR_BAD_REQUEST, config)); | |
| return; | |
| } | |
| request.send(requestData); | |
| }); | |
| }; | |
| var _null = null; | |
| var utils$6 = utils$h; | |
| var normalizeHeaderName = normalizeHeaderName$1; | |
| var AxiosError$1 = AxiosError_1; | |
| var transitionalDefaults = transitional; | |
| var toFormData = toFormData_1; | |
| var DEFAULT_CONTENT_TYPE = { | |
| "Content-Type": "application/x-www-form-urlencoded" | |
| }; | |
| function setContentTypeIfUnset(headers, value) { | |
| if (!utils$6.isUndefined(headers) && utils$6.isUndefined(headers["Content-Type"])) { | |
| headers["Content-Type"] = value; | |
| } | |
| } | |
| function getDefaultAdapter() { | |
| var adapter; | |
| if (typeof XMLHttpRequest !== "undefined") { | |
| adapter = xhr; | |
| } else if (typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]") { | |
| adapter = xhr; | |
| } | |
| return adapter; | |
| } | |
| function stringifySafely(rawValue, parser, encoder) { | |
| if (utils$6.isString(rawValue)) { | |
| try { | |
| (parser || JSON.parse)(rawValue); | |
| return utils$6.trim(rawValue); | |
| } catch (e) { | |
| if (e.name !== "SyntaxError") { | |
| throw e; | |
| } | |
| } | |
| } | |
| return (encoder || JSON.stringify)(rawValue); | |
| } | |
| var defaults$3 = { | |
| transitional: transitionalDefaults, | |
| adapter: getDefaultAdapter(), | |
| transformRequest: [function transformRequest(data2, headers) { | |
| normalizeHeaderName(headers, "Accept"); | |
| normalizeHeaderName(headers, "Content-Type"); | |
| if (utils$6.isFormData(data2) || utils$6.isArrayBuffer(data2) || utils$6.isBuffer(data2) || utils$6.isStream(data2) || utils$6.isFile(data2) || utils$6.isBlob(data2)) { | |
| return data2; | |
| } | |
| if (utils$6.isArrayBufferView(data2)) { | |
| return data2.buffer; | |
| } | |
| if (utils$6.isURLSearchParams(data2)) { | |
| setContentTypeIfUnset(headers, "application/x-www-form-urlencoded;charset=utf-8"); | |
| return data2.toString(); | |
| } | |
| var isObjectPayload = utils$6.isObject(data2); | |
| var contentType = headers && headers["Content-Type"]; | |
| var isFileList2; | |
| if ((isFileList2 = utils$6.isFileList(data2)) || isObjectPayload && contentType === "multipart/form-data") { | |
| var _FormData = this.env && this.env.FormData; | |
| return toFormData(isFileList2 ? { "files[]": data2 } : data2, _FormData && new _FormData()); | |
| } else if (isObjectPayload || contentType === "application/json") { | |
| setContentTypeIfUnset(headers, "application/json"); | |
| return stringifySafely(data2); | |
| } | |
| return data2; | |
| }], | |
| transformResponse: [function transformResponse(data2) { | |
| var transitional2 = this.transitional || defaults$3.transitional; | |
| var silentJSONParsing = transitional2 && transitional2.silentJSONParsing; | |
| var forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing; | |
| var strictJSONParsing = !silentJSONParsing && this.responseType === "json"; | |
| if (strictJSONParsing || forcedJSONParsing && utils$6.isString(data2) && data2.length) { | |
| try { | |
| return JSON.parse(data2); | |
| } catch (e) { | |
| if (strictJSONParsing) { | |
| if (e.name === "SyntaxError") { | |
| throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response); | |
| } | |
| throw e; | |
| } | |
| } | |
| } | |
| return data2; | |
| }], | |
| timeout: 0, | |
| xsrfCookieName: "XSRF-TOKEN", | |
| xsrfHeaderName: "X-XSRF-TOKEN", | |
| maxContentLength: -1, | |
| maxBodyLength: -1, | |
| env: { | |
| FormData: _null | |
| }, | |
| validateStatus: function validateStatus(status) { | |
| return status >= 200 && status < 300; | |
| }, | |
| headers: { | |
| common: { | |
| "Accept": "application/json, text/plain, */*" | |
| } | |
| } | |
| }; | |
| utils$6.forEach(["delete", "get", "head"], function forEachMethodNoData(method) { | |
| defaults$3.headers[method] = {}; | |
| }); | |
| utils$6.forEach(["post", "put", "patch"], function forEachMethodWithData(method) { | |
| defaults$3.headers[method] = utils$6.merge(DEFAULT_CONTENT_TYPE); | |
| }); | |
| var defaults_1 = defaults$3; | |
| var utils$5 = utils$h; | |
| var defaults$2 = defaults_1; | |
| var transformData$1 = function transformData2(data2, headers, fns) { | |
| var context = this || defaults$2; | |
| utils$5.forEach(fns, function transform(fn) { | |
| data2 = fn.call(context, data2, headers); | |
| }); | |
| return data2; | |
| }; | |
| var isCancel$1 = function isCancel2(value) { | |
| return !!(value && value.__CANCEL__); | |
| }; | |
| var utils$4 = utils$h; | |
| var transformData = transformData$1; | |
| var isCancel = isCancel$1; | |
| var defaults$1 = defaults_1; | |
| var CanceledError$1 = CanceledError_1; | |
| function throwIfCancellationRequested(config) { | |
| if (config.cancelToken) { | |
| config.cancelToken.throwIfRequested(); | |
| } | |
| if (config.signal && config.signal.aborted) { | |
| throw new CanceledError$1(); | |
| } | |
| } | |
| var dispatchRequest$1 = function dispatchRequest2(config) { | |
| throwIfCancellationRequested(config); | |
| config.headers = config.headers || {}; | |
| config.data = transformData.call(config, config.data, config.headers, config.transformRequest); | |
| config.headers = utils$4.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers); | |
| utils$4.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) { | |
| delete config.headers[method]; | |
| }); | |
| var adapter = config.adapter || defaults$1.adapter; | |
| return adapter(config).then(function onAdapterResolution(response) { | |
| throwIfCancellationRequested(config); | |
| response.data = transformData.call(config, response.data, response.headers, config.transformResponse); | |
| return response; | |
| }, function onAdapterRejection(reason) { | |
| if (!isCancel(reason)) { | |
| throwIfCancellationRequested(config); | |
| if (reason && reason.response) { | |
| reason.response.data = transformData.call(config, reason.response.data, reason.response.headers, config.transformResponse); | |
| } | |
| } | |
| return Promise.reject(reason); | |
| }); | |
| }; | |
| var utils$3 = utils$h; | |
| var mergeConfig$2 = function mergeConfig2(config1, config2) { | |
| config2 = config2 || {}; | |
| var config = {}; | |
| function getMergedValue(target, source) { | |
| if (utils$3.isPlainObject(target) && utils$3.isPlainObject(source)) { | |
| return utils$3.merge(target, source); | |
| } else if (utils$3.isPlainObject(source)) { | |
| return utils$3.merge({}, source); | |
| } else if (utils$3.isArray(source)) { | |
| return source.slice(); | |
| } | |
| return source; | |
| } | |
| function mergeDeepProperties(prop) { | |
| if (!utils$3.isUndefined(config2[prop])) { | |
| return getMergedValue(config1[prop], config2[prop]); | |
| } else if (!utils$3.isUndefined(config1[prop])) { | |
| return getMergedValue(void 0, config1[prop]); | |
| } | |
| } | |
| function valueFromConfig2(prop) { | |
| if (!utils$3.isUndefined(config2[prop])) { | |
| return getMergedValue(void 0, config2[prop]); | |
| } | |
| } | |
| function defaultToConfig2(prop) { | |
| if (!utils$3.isUndefined(config2[prop])) { | |
| return getMergedValue(void 0, config2[prop]); | |
| } else if (!utils$3.isUndefined(config1[prop])) { | |
| return getMergedValue(void 0, config1[prop]); | |
| } | |
| } | |
| function mergeDirectKeys(prop) { | |
| if (prop in config2) { | |
| return getMergedValue(config1[prop], config2[prop]); | |
| } else if (prop in config1) { | |
| return getMergedValue(void 0, config1[prop]); | |
| } | |
| } | |
| var mergeMap = { | |
| "url": valueFromConfig2, | |
| "method": valueFromConfig2, | |
| "data": valueFromConfig2, | |
| "baseURL": defaultToConfig2, | |
| "transformRequest": defaultToConfig2, | |
| "transformResponse": defaultToConfig2, | |
| "paramsSerializer": defaultToConfig2, | |
| "timeout": defaultToConfig2, | |
| "timeoutMessage": defaultToConfig2, | |
| "withCredentials": defaultToConfig2, | |
| "adapter": defaultToConfig2, | |
| "responseType": defaultToConfig2, | |
| "xsrfCookieName": defaultToConfig2, | |
| "xsrfHeaderName": defaultToConfig2, | |
| "onUploadProgress": defaultToConfig2, | |
| "onDownloadProgress": defaultToConfig2, | |
| "decompress": defaultToConfig2, | |
| "maxContentLength": defaultToConfig2, | |
| "maxBodyLength": defaultToConfig2, | |
| "beforeRedirect": defaultToConfig2, | |
| "transport": defaultToConfig2, | |
| "httpAgent": defaultToConfig2, | |
| "httpsAgent": defaultToConfig2, | |
| "cancelToken": defaultToConfig2, | |
| "socketPath": defaultToConfig2, | |
| "responseEncoding": defaultToConfig2, | |
| "validateStatus": mergeDirectKeys | |
| }; | |
| utils$3.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) { | |
| var merge2 = mergeMap[prop] || mergeDeepProperties; | |
| var configValue = merge2(prop); | |
| utils$3.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue); | |
| }); | |
| return config; | |
| }; | |
| var data = { | |
| "version": "0.27.2" | |
| }; | |
| var VERSION = data.version; | |
| var AxiosError = AxiosError_1; | |
| var validators$1 = {}; | |
| ["object", "boolean", "number", "function", "string", "symbol"].forEach(function(type, i) { | |
| validators$1[type] = function validator2(thing) { | |
| return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type; | |
| }; | |
| }); | |
| var deprecatedWarnings = {}; | |
| validators$1.transitional = function transitional2(validator2, version, message) { | |
| function formatMessage(opt, desc) { | |
| return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : ""); | |
| } | |
| return function(value, opt, opts) { | |
| if (validator2 === false) { | |
| throw new AxiosError(formatMessage(opt, " has been removed" + (version ? " in " + version : "")), AxiosError.ERR_DEPRECATED); | |
| } | |
| if (version && !deprecatedWarnings[opt]) { | |
| deprecatedWarnings[opt] = true; | |
| console.warn(formatMessage(opt, " has been deprecated since v" + version + " and will be removed in the near future")); | |
| } | |
| return validator2 ? validator2(value, opt, opts) : true; | |
| }; | |
| }; | |
| function assertOptions(options, schema, allowUnknown) { | |
| if (typeof options !== "object") { | |
| throw new AxiosError("options must be an object", AxiosError.ERR_BAD_OPTION_VALUE); | |
| } | |
| var keys = Object.keys(options); | |
| var i = keys.length; | |
| while (i-- > 0) { | |
| var opt = keys[i]; | |
| var validator2 = schema[opt]; | |
| if (validator2) { | |
| var value = options[opt]; | |
| var result = value === void 0 || validator2(value, opt, options); | |
| if (result !== true) { | |
| throw new AxiosError("option " + opt + " must be " + result, AxiosError.ERR_BAD_OPTION_VALUE); | |
| } | |
| continue; | |
| } | |
| if (allowUnknown !== true) { | |
| throw new AxiosError("Unknown option " + opt, AxiosError.ERR_BAD_OPTION); | |
| } | |
| } | |
| } | |
| var validator$1 = { | |
| assertOptions, | |
| validators: validators$1 | |
| }; | |
| var utils$2 = utils$h; | |
| var buildURL = buildURL$2; | |
| var InterceptorManager = InterceptorManager_1; | |
| var dispatchRequest = dispatchRequest$1; | |
| var mergeConfig$1 = mergeConfig$2; | |
| var buildFullPath = buildFullPath$2; | |
| var validator = validator$1; | |
| var validators = validator.validators; | |
| function Axios$1(instanceConfig) { | |
| this.defaults = instanceConfig; | |
| this.interceptors = { | |
| request: new InterceptorManager(), | |
| response: new InterceptorManager() | |
| }; | |
| } | |
| Axios$1.prototype.request = function request(configOrUrl, config) { | |
| if (typeof configOrUrl === "string") { | |
| config = config || {}; | |
| config.url = configOrUrl; | |
| } else { | |
| config = configOrUrl || {}; | |
| } | |
| config = mergeConfig$1(this.defaults, config); | |
| if (config.method) { | |
| config.method = config.method.toLowerCase(); | |
| } else if (this.defaults.method) { | |
| config.method = this.defaults.method.toLowerCase(); | |
| } else { | |
| config.method = "get"; | |
| } | |
| var transitional2 = config.transitional; | |
| if (transitional2 !== void 0) { | |
| validator.assertOptions(transitional2, { | |
| silentJSONParsing: validators.transitional(validators.boolean), | |
| forcedJSONParsing: validators.transitional(validators.boolean), | |
| clarifyTimeoutError: validators.transitional(validators.boolean) | |
| }, false); | |
| } | |
| var requestInterceptorChain = []; | |
| var synchronousRequestInterceptors = true; | |
| this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { | |
| if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) { | |
| return; | |
| } | |
| synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; | |
| requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); | |
| }); | |
| var responseInterceptorChain = []; | |
| this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { | |
| responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); | |
| }); | |
| var promise; | |
| if (!synchronousRequestInterceptors) { | |
| var chain = [dispatchRequest, void 0]; | |
| Array.prototype.unshift.apply(chain, requestInterceptorChain); | |
| chain = chain.concat(responseInterceptorChain); | |
| promise = Promise.resolve(config); | |
| while (chain.length) { | |
| promise = promise.then(chain.shift(), chain.shift()); | |
| } | |
| return promise; | |
| } | |
| var newConfig = config; | |
| while (requestInterceptorChain.length) { | |
| var onFulfilled = requestInterceptorChain.shift(); | |
| var onRejected = requestInterceptorChain.shift(); | |
| try { | |
| newConfig = onFulfilled(newConfig); | |
| } catch (error) { | |
| onRejected(error); | |
| break; | |
| } | |
| } | |
| try { | |
| promise = dispatchRequest(newConfig); | |
| } catch (error) { | |
| return Promise.reject(error); | |
| } | |
| while (responseInterceptorChain.length) { | |
| promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()); | |
| } | |
| return promise; | |
| }; | |
| Axios$1.prototype.getUri = function getUri(config) { | |
| config = mergeConfig$1(this.defaults, config); | |
| var fullPath = buildFullPath(config.baseURL, config.url); | |
| return buildURL(fullPath, config.params, config.paramsSerializer); | |
| }; | |
| utils$2.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) { | |
| Axios$1.prototype[method] = function(url, config) { | |
| return this.request(mergeConfig$1(config || {}, { | |
| method, | |
| url, | |
| data: (config || {}).data | |
| })); | |
| }; | |
| }); | |
| utils$2.forEach(["post", "put", "patch"], function forEachMethodWithData(method) { | |
| function generateHTTPMethod(isForm) { | |
| return function httpMethod(url, data2, config) { | |
| return this.request(mergeConfig$1(config || {}, { | |
| method, | |
| headers: isForm ? { | |
| "Content-Type": "multipart/form-data" | |
| } : {}, | |
| url, | |
| data: data2 | |
| })); | |
| }; | |
| } | |
| Axios$1.prototype[method] = generateHTTPMethod(); | |
| Axios$1.prototype[method + "Form"] = generateHTTPMethod(true); | |
| }); | |
| var Axios_1 = Axios$1; | |
| var CanceledError = CanceledError_1; | |
| function CancelToken(executor) { | |
| if (typeof executor !== "function") { | |
| throw new TypeError("executor must be a function."); | |
| } | |
| var resolvePromise; | |
| this.promise = new Promise(function promiseExecutor(resolve) { | |
| resolvePromise = resolve; | |
| }); | |
| var token = this; | |
| this.promise.then(function(cancel) { | |
| if (!token._listeners) | |
| return; | |
| var i; | |
| var l = token._listeners.length; | |
| for (i = 0; i < l; i++) { | |
| token._listeners[i](cancel); | |
| } | |
| token._listeners = null; | |
| }); | |
| this.promise.then = function(onfulfilled) { | |
| var _resolve; | |
| var promise = new Promise(function(resolve) { | |
| token.subscribe(resolve); | |
| _resolve = resolve; | |
| }).then(onfulfilled); | |
| promise.cancel = function reject() { | |
| token.unsubscribe(_resolve); | |
| }; | |
| return promise; | |
| }; | |
| executor(function cancel(message) { | |
| if (token.reason) { | |
| return; | |
| } | |
| token.reason = new CanceledError(message); | |
| resolvePromise(token.reason); | |
| }); | |
| } | |
| CancelToken.prototype.throwIfRequested = function throwIfRequested() { | |
| if (this.reason) { | |
| throw this.reason; | |
| } | |
| }; | |
| CancelToken.prototype.subscribe = function subscribe(listener) { | |
| if (this.reason) { | |
| listener(this.reason); | |
| return; | |
| } | |
| if (this._listeners) { | |
| this._listeners.push(listener); | |
| } else { | |
| this._listeners = [listener]; | |
| } | |
| }; | |
| CancelToken.prototype.unsubscribe = function unsubscribe(listener) { | |
| if (!this._listeners) { | |
| return; | |
| } | |
| var index = this._listeners.indexOf(listener); | |
| if (index !== -1) { | |
| this._listeners.splice(index, 1); | |
| } | |
| }; | |
| CancelToken.source = function source() { | |
| var cancel; | |
| var token = new CancelToken(function executor(c) { | |
| cancel = c; | |
| }); | |
| return { | |
| token, | |
| cancel | |
| }; | |
| }; | |
| var CancelToken_1 = CancelToken; | |
| var spread = function spread2(callback) { | |
| return function wrap(arr) { | |
| return callback.apply(null, arr); | |
| }; | |
| }; | |
| var utils$1 = utils$h; | |
| var isAxiosError = function isAxiosError2(payload) { | |
| return utils$1.isObject(payload) && payload.isAxiosError === true; | |
| }; | |
| var utils = utils$h; | |
| var bind = bind$2; | |
| var Axios = Axios_1; | |
| var mergeConfig = mergeConfig$2; | |
| var defaults = defaults_1; | |
| function createInstance(defaultConfig) { | |
| var context = new Axios(defaultConfig); | |
| var instance = bind(Axios.prototype.request, context); | |
| utils.extend(instance, Axios.prototype, context); | |
| utils.extend(instance, context); | |
| instance.create = function create(instanceConfig) { | |
| return createInstance(mergeConfig(defaultConfig, instanceConfig)); | |
| }; | |
| return instance; | |
| } | |
| var axios$1 = createInstance(defaults); | |
| axios$1.Axios = Axios; | |
| axios$1.CanceledError = CanceledError_1; | |
| axios$1.CancelToken = CancelToken_1; | |
| axios$1.isCancel = isCancel$1; | |
| axios$1.VERSION = data.version; | |
| axios$1.toFormData = toFormData_1; | |
| axios$1.AxiosError = AxiosError_1; | |
| axios$1.Cancel = axios$1.CanceledError; | |
| axios$1.all = function all(promises) { | |
| return Promise.all(promises); | |
| }; | |
| axios$1.spread = spread; | |
| axios$1.isAxiosError = isAxiosError; | |
| axios$2.exports = axios$1; | |
| axios$2.exports.default = axios$1; | |
| var axios = axios$2.exports; | |
| async function getActiveSessionID() { | |
| let data2 = JSON.stringify({ | |
| operationName: "userStatusGlobal", | |
| variables: {}, | |
| query: "query userStatusGlobal {\n userStatus {\n isSignedIn\n isAdmin\n isStaff\n isSuperuser\n isTranslator\n isVerified\n isPhoneVerified\n isWechatVerified\n checkedInToday\n username\n realName\n userSlug\n groups\n avatar\n optedIn\n requestRegion\n region\n socketToken\n activeSessionId\n permissions\n completedFeatureGuides\n useTranslation\n accountStatus {\n isFrozen\n inactiveAfter\n __typename\n }\n __typename\n }\n}\n" | |
| }); | |
| let resp = await axios.post("https://leetcode.cn/graphql/noj-go", data2, { | |
| withCredentials: true, | |
| headers: { | |
| "content-type": "application/json" | |
| } | |
| }); | |
| return resp.data["data"]["userStatus"]["activeSessionId"]; | |
| } | |
| async function getQuestionID() { | |
| let div = document.querySelector("div.active__2qli"); | |
| let id = div.getAttribute("data-question-id"); | |
| return id; | |
| } | |
| async function ButtonClickAction() { | |
| let sessionID = await getActiveSessionID(); | |
| let questionID = await getQuestionID(); | |
| let lang_key = `${sessionID}_${questionID}_lang`; | |
| let lang = JSON.parse(localStorage.getItem(lang_key)) || "cpp"; | |
| let code_key = `${sessionID}_${questionID}_${lang}_code`; | |
| let code = JSON.parse(localStorage.getItem(code_key)); | |
| navigator.clipboard.writeText(code); | |
| } | |
| function addBtn() { | |
| let zNode = document.createElement("div"); | |
| zNode.innerHTML = '<button id="myButton" type="button">CopyCode</button>'; | |
| zNode.setAttribute("id", "myContainer"); | |
| let tmp = document.querySelector("div.second-section-container__2cAh"); | |
| tmp.appendChild(zNode); | |
| document.getElementById("myButton").addEventListener("click", ButtonClickAction, false); | |
| } | |
| window.addEventListener("load", function() { | |
| addBtn(); | |
| }, false); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment