跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
中医百科
搜索
搜索
登录
个人工具
登录
深色模式
查看“MediaWiki:Gadget-Wikiplus.js”的源代码
系统消息
讨论
English
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
清除缓存
常规
链入页面
相关更改
特殊页面
页面信息
页面值
←
MediaWiki:Gadget-Wikiplus.js
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
此页面为本wiki上的软件提供界面文本,并受到保护以防止滥用。 如欲修改所有wiki的翻译,请访问
translatewiki.net
上的MediaWiki本地化项目。
您无权编辑此JavaScript页面,因为编辑此页面可能会影响所有访问者。
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
/** * SPDX-License-Identifier: CC-BY-SA-4.0 OR Apache-2.0 * _addText: '{{Gadget Header|title=Wikiplus|license=CC-BY-SA-4.0|license2=Apache-2.0}}' * * Wikiplus * * @base {@link https://github.com/Wikiplus/Wikiplus} * @source {@link https://git.qiuwen.net.cn/InterfaceAdmin/Wikiplus} * @source {@link https://git.qiuwen.net.cn/InterfaceAdmin/QiuwenGadgets/src/branch/master/src/Wikiplus/} * @author Eridanus Sora (妹空酱) * @license CC-BY-SA-4.0 {@link https://www.qiuwenbaike.cn/wiki/H:CC-BY-SA-4.0} OR Apache-2.0 {@link http://www.apache.org/licenses/LICENSE-2.0} */ /** * Copyright 2014-2024 Eridanus Sora (妹空酱) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 */ /** * +------------------------------------------------------------+ * | === WARNING: GLOBAL GADGET FILE === | * +------------------------------------------------------------+ * | All changes should be made in the repository, | * | otherwise they will be lost. | * +------------------------------------------------------------+ * | Changes to this page may affect many users. | * | Please discuss changes by opening an issue before editing. | * +------------------------------------------------------------+ */ /* <nowiki> */ (() => { "use strict"; var __getOwnPropNames = Object.getOwnPropertyNames; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/is-callable.js var require_is_callable = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/is-callable.js"(exports, module2) { "use strict"; var documentAll = typeof document == "object" && document.all; module2.exports = typeof documentAll == "undefined" && documentAll !== void 0 ? function(argument) { return typeof argument == "function" || argument === documentAll; } : function(argument) { return typeof argument == "function"; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/fails.js var require_fails = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/fails.js"(exports, module2) { "use strict"; module2.exports = function(exec) { try { return !!exec(); } catch (error) { return true; } }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/descriptors.js var require_descriptors = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/descriptors.js"(exports, module2) { "use strict"; var fails = require_fails(); module2.exports = !fails(function() { return Object.defineProperty({}, 1, { get: function() { return 7; } })[1] !== 7; }); } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/global-this.js var require_global_this = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/global-this.js"(exports, module2) { "use strict"; var check = function(it) { return it && it.Math === Math && it; }; module2.exports = // eslint-disable-next-line es/no-global-this -- safe check(typeof globalThis == "object" && globalThis) || check(typeof window == "object" && window) || // eslint-disable-next-line no-restricted-globals -- safe check(typeof self == "object" && self) || check(typeof global == "object" && global) || check(typeof exports == "object" && exports) || // eslint-disable-next-line no-new-func -- fallback /* @__PURE__ */ function() { return this; }() || Function("return this")(); } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/is-object.js var require_is_object = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/is-object.js"(exports, module2) { "use strict"; var isCallable = require_is_callable(); module2.exports = function(it) { return typeof it == "object" ? it !== null : isCallable(it); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/document-create-element.js var require_document_create_element = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/document-create-element.js"(exports, module2) { "use strict"; var globalThis2 = require_global_this(); var isObject = require_is_object(); var document2 = globalThis2.document; var EXISTS = isObject(document2) && isObject(document2.createElement); module2.exports = function(it) { return EXISTS ? document2.createElement(it) : {}; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/ie8-dom-define.js var require_ie8_dom_define = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/ie8-dom-define.js"(exports, module2) { "use strict"; var DESCRIPTORS = require_descriptors(); var fails = require_fails(); var createElement = require_document_create_element(); module2.exports = !DESCRIPTORS && !fails(function() { return Object.defineProperty(createElement("div"), "a", { get: function() { return 7; } }).a !== 7; }); } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/v8-prototype-define-bug.js var require_v8_prototype_define_bug = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/v8-prototype-define-bug.js"(exports, module2) { "use strict"; var DESCRIPTORS = require_descriptors(); var fails = require_fails(); module2.exports = DESCRIPTORS && fails(function() { return Object.defineProperty(function() { }, "prototype", { value: 42, writable: false }).prototype !== 42; }); } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/an-object.js var require_an_object = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/an-object.js"(exports, module2) { "use strict"; var isObject = require_is_object(); var $String = String; var $TypeError = TypeError; module2.exports = function(argument) { if (isObject(argument)) return argument; throw new $TypeError($String(argument) + " is not an object"); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/function-bind-native.js var require_function_bind_native = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/function-bind-native.js"(exports, module2) { "use strict"; var fails = require_fails(); module2.exports = !fails(function() { var test = function() { }.bind(); return typeof test != "function" || test.hasOwnProperty("prototype"); }); } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/function-call.js var require_function_call = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/function-call.js"(exports, module2) { "use strict"; var NATIVE_BIND = require_function_bind_native(); var call = Function.prototype.call; module2.exports = NATIVE_BIND ? call.bind(call) : function() { return call.apply(call, arguments); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/get-built-in.js var require_get_built_in = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/get-built-in.js"(exports, module2) { "use strict"; var globalThis2 = require_global_this(); var isCallable = require_is_callable(); var aFunction = function(argument) { return isCallable(argument) ? argument : void 0; }; module2.exports = function(namespace, method) { return arguments.length < 2 ? aFunction(globalThis2[namespace]) : globalThis2[namespace] && globalThis2[namespace][method]; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/function-uncurry-this.js var require_function_uncurry_this = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/function-uncurry-this.js"(exports, module2) { "use strict"; var NATIVE_BIND = require_function_bind_native(); var FunctionPrototype = Function.prototype; var call = FunctionPrototype.call; var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call); module2.exports = NATIVE_BIND ? uncurryThisWithBind : function(fn) { return function() { return call.apply(fn, arguments); }; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/object-is-prototype-of.js var require_object_is_prototype_of = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/object-is-prototype-of.js"(exports, module2) { "use strict"; var uncurryThis = require_function_uncurry_this(); module2.exports = uncurryThis({}.isPrototypeOf); } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/environment-user-agent.js var require_environment_user_agent = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/environment-user-agent.js"(exports, module2) { "use strict"; var globalThis2 = require_global_this(); var navigator2 = globalThis2.navigator; var userAgent = navigator2 && navigator2.userAgent; module2.exports = userAgent ? String(userAgent) : ""; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/environment-v8-version.js var require_environment_v8_version = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/environment-v8-version.js"(exports, module2) { "use strict"; var globalThis2 = require_global_this(); var userAgent = require_environment_user_agent(); var process = globalThis2.process; var Deno = globalThis2.Deno; var versions = process && process.versions || Deno && Deno.version; var v8 = versions && versions.v8; var match; var version; if (v8) { match = v8.split("."); version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); } if (!version && userAgent) { match = userAgent.match(/Edge\/(\d+)/); if (!match || match[1] >= 74) { match = userAgent.match(/Chrome\/(\d+)/); if (match) version = +match[1]; } } module2.exports = version; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/symbol-constructor-detection.js var require_symbol_constructor_detection = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/symbol-constructor-detection.js"(exports, module2) { "use strict"; var V8_VERSION = require_environment_v8_version(); var fails = require_fails(); var globalThis2 = require_global_this(); var $String = globalThis2.String; module2.exports = !!Object.getOwnPropertySymbols && !fails(function() { var symbol = Symbol("symbol detection"); return !$String(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances !Symbol.sham && V8_VERSION && V8_VERSION < 41; }); } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/use-symbol-as-uid.js var require_use_symbol_as_uid = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/use-symbol-as-uid.js"(exports, module2) { "use strict"; var NATIVE_SYMBOL = require_symbol_constructor_detection(); module2.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == "symbol"; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/is-symbol.js var require_is_symbol = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/is-symbol.js"(exports, module2) { "use strict"; var getBuiltIn = require_get_built_in(); var isCallable = require_is_callable(); var isPrototypeOf = require_object_is_prototype_of(); var USE_SYMBOL_AS_UID = require_use_symbol_as_uid(); var $Object = Object; module2.exports = USE_SYMBOL_AS_UID ? function(it) { return typeof it == "symbol"; } : function(it) { var $Symbol = getBuiltIn("Symbol"); return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it)); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/try-to-string.js var require_try_to_string = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/try-to-string.js"(exports, module2) { "use strict"; var $String = String; module2.exports = function(argument) { try { return $String(argument); } catch (error) { return "Object"; } }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/a-callable.js var require_a_callable = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/a-callable.js"(exports, module2) { "use strict"; var isCallable = require_is_callable(); var tryToString = require_try_to_string(); var $TypeError = TypeError; module2.exports = function(argument) { if (isCallable(argument)) return argument; throw new $TypeError(tryToString(argument) + " is not a function"); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/is-null-or-undefined.js var require_is_null_or_undefined = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/is-null-or-undefined.js"(exports, module2) { "use strict"; module2.exports = function(it) { return it === null || it === void 0; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/get-method.js var require_get_method = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/get-method.js"(exports, module2) { "use strict"; var aCallable = require_a_callable(); var isNullOrUndefined = require_is_null_or_undefined(); module2.exports = function(V, P) { var func = V[P]; return isNullOrUndefined(func) ? void 0 : aCallable(func); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/ordinary-to-primitive.js var require_ordinary_to_primitive = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/ordinary-to-primitive.js"(exports, module2) { "use strict"; var call = require_function_call(); var isCallable = require_is_callable(); var isObject = require_is_object(); var $TypeError = TypeError; module2.exports = function(input, pref) { var fn, val; if (pref === "string" && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val; if (pref !== "string" && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; throw new $TypeError("Can't convert object to primitive value"); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/is-pure.js var require_is_pure = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/is-pure.js"(exports, module2) { "use strict"; module2.exports = false; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/define-global-property.js var require_define_global_property = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/define-global-property.js"(exports, module2) { "use strict"; var globalThis2 = require_global_this(); var defineProperty = Object.defineProperty; module2.exports = function(key, value) { try { defineProperty(globalThis2, key, { value, configurable: true, writable: true }); } catch (error) { globalThis2[key] = value; } return value; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/shared-store.js var require_shared_store = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/shared-store.js"(exports, module2) { "use strict"; var IS_PURE = require_is_pure(); var globalThis2 = require_global_this(); var defineGlobalProperty = require_define_global_property(); var SHARED = "__core-js_shared__"; var store = module2.exports = globalThis2[SHARED] || defineGlobalProperty(SHARED, {}); (store.versions || (store.versions = [])).push({ version: "3.38.0", mode: IS_PURE ? "pure" : "global", copyright: "© 2014-2024 Denis Pushkarev (zloirock.ru)", license: "https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE", source: "https://github.com/zloirock/core-js" }); } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/shared.js var require_shared = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/shared.js"(exports, module2) { "use strict"; var store = require_shared_store(); module2.exports = function(key, value) { return store[key] || (store[key] = value || {}); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/require-object-coercible.js var require_require_object_coercible = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/require-object-coercible.js"(exports, module2) { "use strict"; var isNullOrUndefined = require_is_null_or_undefined(); var $TypeError = TypeError; module2.exports = function(it) { if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it); return it; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/to-object.js var require_to_object = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/to-object.js"(exports, module2) { "use strict"; var requireObjectCoercible = require_require_object_coercible(); var $Object = Object; module2.exports = function(argument) { return $Object(requireObjectCoercible(argument)); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/has-own-property.js var require_has_own_property = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/has-own-property.js"(exports, module2) { "use strict"; var uncurryThis = require_function_uncurry_this(); var toObject = require_to_object(); var hasOwnProperty = uncurryThis({}.hasOwnProperty); module2.exports = Object.hasOwn || function hasOwn(it, key) { return hasOwnProperty(toObject(it), key); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/uid.js var require_uid = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/uid.js"(exports, module2) { "use strict"; var uncurryThis = require_function_uncurry_this(); var id = 0; var postfix = Math.random(); var toString = uncurryThis(1 .toString); module2.exports = function(key) { return "Symbol(" + (key === void 0 ? "" : key) + ")_" + toString(++id + postfix, 36); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/well-known-symbol.js var require_well_known_symbol = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/well-known-symbol.js"(exports, module2) { "use strict"; var globalThis2 = require_global_this(); var shared = require_shared(); var hasOwn = require_has_own_property(); var uid = require_uid(); var NATIVE_SYMBOL = require_symbol_constructor_detection(); var USE_SYMBOL_AS_UID = require_use_symbol_as_uid(); var Symbol2 = globalThis2.Symbol; var WellKnownSymbolsStore = shared("wks"); var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol2["for"] || Symbol2 : Symbol2 && Symbol2.withoutSetter || uid; module2.exports = function(name) { if (!hasOwn(WellKnownSymbolsStore, name)) { WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol2, name) ? Symbol2[name] : createWellKnownSymbol("Symbol." + name); } return WellKnownSymbolsStore[name]; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/to-primitive.js var require_to_primitive = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/to-primitive.js"(exports, module2) { "use strict"; var call = require_function_call(); var isObject = require_is_object(); var isSymbol = require_is_symbol(); var getMethod = require_get_method(); var ordinaryToPrimitive = require_ordinary_to_primitive(); var wellKnownSymbol = require_well_known_symbol(); var $TypeError = TypeError; var TO_PRIMITIVE = wellKnownSymbol("toPrimitive"); module2.exports = function(input, pref) { if (!isObject(input) || isSymbol(input)) return input; var exoticToPrim = getMethod(input, TO_PRIMITIVE); var result; if (exoticToPrim) { if (pref === void 0) pref = "default"; result = call(exoticToPrim, input, pref); if (!isObject(result) || isSymbol(result)) return result; throw new $TypeError("Can't convert object to primitive value"); } if (pref === void 0) pref = "number"; return ordinaryToPrimitive(input, pref); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/to-property-key.js var require_to_property_key = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/to-property-key.js"(exports, module2) { "use strict"; var toPrimitive = require_to_primitive(); var isSymbol = require_is_symbol(); module2.exports = function(argument) { var key = toPrimitive(argument, "string"); return isSymbol(key) ? key : key + ""; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/object-define-property.js var require_object_define_property = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/object-define-property.js"(exports) { "use strict"; var DESCRIPTORS = require_descriptors(); var IE8_DOM_DEFINE = require_ie8_dom_define(); var V8_PROTOTYPE_DEFINE_BUG = require_v8_prototype_define_bug(); var anObject = require_an_object(); var toPropertyKey = require_to_property_key(); var $TypeError = TypeError; var $defineProperty = Object.defineProperty; var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ENUMERABLE = "enumerable"; var CONFIGURABLE = "configurable"; var WRITABLE = "writable"; exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) { anObject(O); P = toPropertyKey(P); anObject(Attributes); if (typeof O === "function" && P === "prototype" && "value" in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { var current = $getOwnPropertyDescriptor(O, P); if (current && current[WRITABLE]) { O[P] = Attributes.value; Attributes = { configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE], enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], writable: false }; } } return $defineProperty(O, P, Attributes); } : $defineProperty : function defineProperty(O, P, Attributes) { anObject(O); P = toPropertyKey(P); anObject(Attributes); if (IE8_DOM_DEFINE) try { return $defineProperty(O, P, Attributes); } catch (error) { } if ("get" in Attributes || "set" in Attributes) throw new $TypeError("Accessors not supported"); if ("value" in Attributes) O[P] = Attributes.value; return O; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/function-name.js var require_function_name = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/function-name.js"(exports, module2) { "use strict"; var DESCRIPTORS = require_descriptors(); var hasOwn = require_has_own_property(); var FunctionPrototype = Function.prototype; var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor; var EXISTS = hasOwn(FunctionPrototype, "name"); var PROPER = EXISTS && function something() { }.name === "something"; var CONFIGURABLE = EXISTS && (!DESCRIPTORS || DESCRIPTORS && getDescriptor(FunctionPrototype, "name").configurable); module2.exports = { EXISTS, PROPER, CONFIGURABLE }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/inspect-source.js var require_inspect_source = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/inspect-source.js"(exports, module2) { "use strict"; var uncurryThis = require_function_uncurry_this(); var isCallable = require_is_callable(); var store = require_shared_store(); var functionToString = uncurryThis(Function.toString); if (!isCallable(store.inspectSource)) { store.inspectSource = function(it) { return functionToString(it); }; } module2.exports = store.inspectSource; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/weak-map-basic-detection.js var require_weak_map_basic_detection = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/weak-map-basic-detection.js"(exports, module2) { "use strict"; var globalThis2 = require_global_this(); var isCallable = require_is_callable(); var WeakMap = globalThis2.WeakMap; module2.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap)); } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/create-property-descriptor.js var require_create_property_descriptor = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/create-property-descriptor.js"(exports, module2) { "use strict"; module2.exports = function(bitmap, value) { return { enumerable: !(bitmap & 1), configurable: !(bitmap & 2), writable: !(bitmap & 4), value }; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/create-non-enumerable-property.js var require_create_non_enumerable_property = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/create-non-enumerable-property.js"(exports, module2) { "use strict"; var DESCRIPTORS = require_descriptors(); var definePropertyModule = require_object_define_property(); var createPropertyDescriptor = require_create_property_descriptor(); module2.exports = DESCRIPTORS ? function(object, key, value) { return definePropertyModule.f(object, key, createPropertyDescriptor(1, value)); } : function(object, key, value) { object[key] = value; return object; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/shared-key.js var require_shared_key = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/shared-key.js"(exports, module2) { "use strict"; var shared = require_shared(); var uid = require_uid(); var keys = shared("keys"); module2.exports = function(key) { return keys[key] || (keys[key] = uid(key)); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/hidden-keys.js var require_hidden_keys = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/hidden-keys.js"(exports, module2) { "use strict"; module2.exports = {}; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/internal-state.js var require_internal_state = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/internal-state.js"(exports, module2) { "use strict"; var NATIVE_WEAK_MAP = require_weak_map_basic_detection(); var globalThis2 = require_global_this(); var isObject = require_is_object(); var createNonEnumerableProperty = require_create_non_enumerable_property(); var hasOwn = require_has_own_property(); var shared = require_shared_store(); var sharedKey = require_shared_key(); var hiddenKeys = require_hidden_keys(); var OBJECT_ALREADY_INITIALIZED = "Object already initialized"; var TypeError2 = globalThis2.TypeError; var WeakMap = globalThis2.WeakMap; var set; var get; var has; var enforce = function(it) { return has(it) ? get(it) : set(it, {}); }; var getterFor = function(TYPE) { return function(it) { var state; if (!isObject(it) || (state = get(it)).type !== TYPE) { throw new TypeError2("Incompatible receiver, " + TYPE + " required"); } return state; }; }; if (NATIVE_WEAK_MAP || shared.state) { store = shared.state || (shared.state = new WeakMap()); store.get = store.get; store.has = store.has; store.set = store.set; set = function(it, metadata) { if (store.has(it)) throw new TypeError2(OBJECT_ALREADY_INITIALIZED); metadata.facade = it; store.set(it, metadata); return metadata; }; get = function(it) { return store.get(it) || {}; }; has = function(it) { return store.has(it); }; } else { STATE = sharedKey("state"); hiddenKeys[STATE] = true; set = function(it, metadata) { if (hasOwn(it, STATE)) throw new TypeError2(OBJECT_ALREADY_INITIALIZED); metadata.facade = it; createNonEnumerableProperty(it, STATE, metadata); return metadata; }; get = function(it) { return hasOwn(it, STATE) ? it[STATE] : {}; }; has = function(it) { return hasOwn(it, STATE); }; } var store; var STATE; module2.exports = { set, get, has, enforce, getterFor }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/make-built-in.js var require_make_built_in = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/make-built-in.js"(exports, module2) { "use strict"; var uncurryThis = require_function_uncurry_this(); var fails = require_fails(); var isCallable = require_is_callable(); var hasOwn = require_has_own_property(); var DESCRIPTORS = require_descriptors(); var CONFIGURABLE_FUNCTION_NAME = require_function_name().CONFIGURABLE; var inspectSource = require_inspect_source(); var InternalStateModule = require_internal_state(); var enforceInternalState = InternalStateModule.enforce; var getInternalState = InternalStateModule.get; var $String = String; var defineProperty = Object.defineProperty; var stringSlice = uncurryThis("".slice); var replace = uncurryThis("".replace); var join = uncurryThis([].join); var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function() { return defineProperty(function() { }, "length", { value: 8 }).length !== 8; }); var TEMPLATE = String(String).split("String"); var makeBuiltIn = module2.exports = function(value, name, options) { if (stringSlice($String(name), 0, 7) === "Symbol(") { name = "[" + replace($String(name), /^Symbol\(([^)]*)\).*$/, "$1") + "]"; } if (options && options.getter) name = "get " + name; if (options && options.setter) name = "set " + name; if (!hasOwn(value, "name") || CONFIGURABLE_FUNCTION_NAME && value.name !== name) { if (DESCRIPTORS) defineProperty(value, "name", { value: name, configurable: true }); else value.name = name; } if (CONFIGURABLE_LENGTH && options && hasOwn(options, "arity") && value.length !== options.arity) { defineProperty(value, "length", { value: options.arity }); } try { if (options && hasOwn(options, "constructor") && options.constructor) { if (DESCRIPTORS) defineProperty(value, "prototype", { writable: false }); } else if (value.prototype) value.prototype = void 0; } catch (error) { } var state = enforceInternalState(value); if (!hasOwn(state, "source")) { state.source = join(TEMPLATE, typeof name == "string" ? name : ""); } return value; }; Function.prototype.toString = makeBuiltIn(function toString() { return isCallable(this) && getInternalState(this).source || inspectSource(this); }, "toString"); } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/define-built-in.js var require_define_built_in = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/define-built-in.js"(exports, module2) { "use strict"; var isCallable = require_is_callable(); var definePropertyModule = require_object_define_property(); var makeBuiltIn = require_make_built_in(); var defineGlobalProperty = require_define_global_property(); module2.exports = function(O, key, value, options) { if (!options) options = {}; var simple = options.enumerable; var name = options.name !== void 0 ? options.name : key; if (isCallable(value)) makeBuiltIn(value, name, options); if (options.global) { if (simple) O[key] = value; else defineGlobalProperty(key, value); } else { try { if (!options.unsafe) delete O[key]; else if (O[key]) simple = true; } catch (error) { } if (simple) O[key] = value; else definePropertyModule.f(O, key, { value, enumerable: false, configurable: !options.nonConfigurable, writable: !options.nonWritable }); } return O; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/to-string-tag-support.js var require_to_string_tag_support = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/to-string-tag-support.js"(exports, module2) { "use strict"; var wellKnownSymbol = require_well_known_symbol(); var TO_STRING_TAG = wellKnownSymbol("toStringTag"); var test = {}; test[TO_STRING_TAG] = "z"; module2.exports = String(test) === "[object z]"; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/classof-raw.js var require_classof_raw = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/classof-raw.js"(exports, module2) { "use strict"; var uncurryThis = require_function_uncurry_this(); var toString = uncurryThis({}.toString); var stringSlice = uncurryThis("".slice); module2.exports = function(it) { return stringSlice(toString(it), 8, -1); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/classof.js var require_classof = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/classof.js"(exports, module2) { "use strict"; var TO_STRING_TAG_SUPPORT = require_to_string_tag_support(); var isCallable = require_is_callable(); var classofRaw = require_classof_raw(); var wellKnownSymbol = require_well_known_symbol(); var TO_STRING_TAG = wellKnownSymbol("toStringTag"); var $Object = Object; var CORRECT_ARGUMENTS = classofRaw(/* @__PURE__ */ function() { return arguments; }()) === "Arguments"; var tryGet = function(it, key) { try { return it[key]; } catch (error) { } }; module2.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function(it) { var O, tag, result; return it === void 0 ? "Undefined" : it === null ? "Null" : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == "string" ? tag : CORRECT_ARGUMENTS ? classofRaw(O) : (result = classofRaw(O)) === "Object" && isCallable(O.callee) ? "Arguments" : result; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/to-string.js var require_to_string = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/to-string.js"(exports, module2) { "use strict"; var classof = require_classof(); var $String = String; module2.exports = function(argument) { if (classof(argument) === "Symbol") throw new TypeError("Cannot convert a Symbol value to a string"); return $String(argument); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/validate-arguments-length.js var require_validate_arguments_length = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/validate-arguments-length.js"(exports, module2) { "use strict"; var $TypeError = TypeError; module2.exports = function(passed, required) { if (passed < required) throw new $TypeError("Not enough arguments"); return passed; }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/modules/web.url-search-params.delete.js var require_web_url_search_params_delete = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/modules/web.url-search-params.delete.js"() { "use strict"; var defineBuiltIn = require_define_built_in(); var uncurryThis = require_function_uncurry_this(); var toString = require_to_string(); var validateArgumentsLength = require_validate_arguments_length(); var $URLSearchParams = URLSearchParams; var URLSearchParamsPrototype = $URLSearchParams.prototype; var append = uncurryThis(URLSearchParamsPrototype.append); var $delete = uncurryThis(URLSearchParamsPrototype["delete"]); var forEach = uncurryThis(URLSearchParamsPrototype.forEach); var push = uncurryThis([].push); var params = new $URLSearchParams("a=1&a=2&b=3"); params["delete"]("a", 1); params["delete"]("b", void 0); if (params + "" !== "a=2") { defineBuiltIn(URLSearchParamsPrototype, "delete", function(name) { var length = arguments.length; var $value = length < 2 ? void 0 : arguments[1]; if (length && $value === void 0) return $delete(this, name); var entries = []; forEach(this, function(v, k) { push(entries, { key: k, value: v }); }); validateArgumentsLength(length, 1); var key = toString(name); var value = toString($value); var index = 0; var dindex = 0; var found = false; var entriesLength = entries.length; var entry; while (index < entriesLength) { entry = entries[index++]; if (found || entry.key === key) { found = true; $delete(this, entry.key); } else dindex++; } while (dindex < entriesLength) { entry = entries[dindex++]; if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value); } }, { enumerable: true, unsafe: true }); } } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/modules/web.url-search-params.has.js var require_web_url_search_params_has = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/modules/web.url-search-params.has.js"() { "use strict"; var defineBuiltIn = require_define_built_in(); var uncurryThis = require_function_uncurry_this(); var toString = require_to_string(); var validateArgumentsLength = require_validate_arguments_length(); var $URLSearchParams = URLSearchParams; var URLSearchParamsPrototype = $URLSearchParams.prototype; var getAll = uncurryThis(URLSearchParamsPrototype.getAll); var $has = uncurryThis(URLSearchParamsPrototype.has); var params = new $URLSearchParams("a=1"); if (params.has("a", 2) || !params.has("a", void 0)) { defineBuiltIn(URLSearchParamsPrototype, "has", function has(name) { var length = arguments.length; var $value = length < 2 ? void 0 : arguments[1]; if (length && $value === void 0) return $has(this, name); var values = getAll(this, name); validateArgumentsLength(length, 1); var value = toString($value); var index = 0; while (index < values.length) { if (values[index++] === value) return true; } return false; }, { enumerable: true, unsafe: true }); } } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/define-built-in-accessor.js var require_define_built_in_accessor = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/internals/define-built-in-accessor.js"(exports, module2) { "use strict"; var makeBuiltIn = require_make_built_in(); var defineProperty = require_object_define_property(); module2.exports = function(target, name, descriptor) { if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true }); if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true }); return defineProperty.f(target, name, descriptor); }; } }); // node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/modules/web.url-search-params.size.js var require_web_url_search_params_size = __commonJS({ "node_modules/.pnpm/core-js@3.38.0/node_modules/core-js/modules/web.url-search-params.size.js"() { "use strict"; var DESCRIPTORS = require_descriptors(); var uncurryThis = require_function_uncurry_this(); var defineBuiltInAccessor = require_define_built_in_accessor(); var URLSearchParamsPrototype = URLSearchParams.prototype; var forEach = uncurryThis(URLSearchParamsPrototype.forEach); if (DESCRIPTORS && !("size" in URLSearchParamsPrototype)) { defineBuiltInAccessor(URLSearchParamsPrototype, "size", { get: function size() { var count = 0; forEach(this, function() { count++; }); return count; }, configurable: true, enumerable: true }); } } }); // dist/Wikiplus/Wikiplus.js require_web_url_search_params_delete(); require_web_url_search_params_has(); require_web_url_search_params_size(); function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var n = 0, F = function() { }; return { s: F, n: function() { return n >= r.length ? { done: true } : { done: false, value: r[n++] }; }, e: function(r2) { throw r2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function() { t = t.call(r); }, n: function() { var r2 = t.next(); return a = r2.done, r2; }, e: function(r2) { u = true, o = r2; }, f: function() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n2) { return void e(n2); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function() { var t = this, e = arguments; return new Promise(function(r, o) { var a = n.apply(t, e); function _next(n2) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n2); } function _throw(n2) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n2); } _next(void 0); }); }; } var __getOwnPropNames2 = Object.getOwnPropertyNames; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res; }; //! src/Wikiplus/modules/utils/constants.js var Constants; var constants_default; var init_constants = __esm({ "src/Wikiplus/modules/utils/constants.js"() { "use strict"; Constants = class { version = "4.0.12"; get isArticle() { return window.mw.config.get("wgIsArticle"); } get currentPageName() { return window.mw.config.get("wgPageName").replace(/ /g, "_"); } get articleId() { return window.mw.config.get("wgArticleId"); } get revisionId() { return window.mw.config.get("wgRevisionId"); } get latestRevisionId() { return window.mw.config.get("wgCurRevisionId"); } get articlePath() { return window.mw.config.get("wgArticlePath"); } get scriptPath() { return window.mw.config.get("wgScriptPath"); } get action() { return window.mw.config.get("wgAction"); } get skin() { return window.mw.config.get("skin"); } get userGroups() { return window.mw.config.get("wgUserGroups"); } get wikiId() { return window.mw.config.get("wgWikiID"); } userAgent = "Qiuwen/1.1 Wikiplus/".concat(this.version, " (").concat(this.wikiId, ")"); }; constants_default = new Constants(); } }); //! src/Wikiplus/modules/utils/requests.js var Requests; var requests_default; var init_requests = __esm({ "src/Wikiplus/modules/utils/requests.js"() { "use strict"; init_constants(); Requests = { base: "".concat(location.protocol, "//").concat(location.host).concat(constants_default.scriptPath, "/api.php"), get(query) { return _asyncToGenerator(function* () { const url = new URL(Requests.base); for (var _i = 0, _Object$keys = Object.keys(query); _i < _Object$keys.length; _i++) { const key = _Object$keys[_i]; url.searchParams.append(key, query[key]); } const response = yield fetch(url, { credentials: "same-origin", headers: { "Api-User-Agent": constants_default.userAgent } }); return yield response.json(); })(); }, post(payload) { return _asyncToGenerator(function* () { const url = new URL(Requests.base); const form = new FormData(); for (var _i2 = 0, _Object$entries = Object.entries(payload); _i2 < _Object$entries.length; _i2++) { const [key, value] = _Object$entries[_i2]; form.append(key, value); } const response = yield fetch(url, { method: "POST", body: form, credentials: "same-origin", headers: { "Api-User-Agent": constants_default.userAgent } }); return yield response.json(); })(); } }; requests_default = Requests; } }); //! src/Wikiplus/modules/utils/i18n.js var I18n; var i18n_default; var init_i18n = __esm({ "src/Wikiplus/modules/utils/i18n.js"() { "use strict"; I18n = class { language; i18nData = {}; sessionUpdateLog = []; constructor() { let language; try { language = JSON.parse(localStorage["Wikiplus_Settings"])["language"] || navigator.language.toLowerCase(); } catch { language = (navigator.language || navigator.browserLanguage).replace(/han[st]-?/i, "").toLowerCase(); } this.language = language; try { const i18nCache = JSON.parse(localStorage.getItem("Wikiplus_i18nCache")); for (var _i3 = 0, _Object$keys2 = Object.keys(i18nCache); _i3 < _Object$keys2.length; _i3++) { const key = _Object$keys2[_i3]; this.i18nData[key] = i18nCache[key]; } } catch { localStorage.setItem("Wikiplus_i18nCache", "{}"); } } translate(key, placeholders = []) { let result = ""; if (this.language in this.i18nData) { if (key in this.i18nData[this.language]) { result = this.i18nData[this.language][key]; } else { this.loadLanguage(this.language); if (key in this.i18nData["en-us"]) { result = this.i18nData["en-us"][key]; } else { result = key; } } } else { this.loadLanguage(this.language); } if (placeholders.length > 0) { var _iterator = _createForOfIteratorHelper(placeholders.entries()), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done; ) { const [index, placeholder] = _step.value; result = result.replace("$".concat(index + 1), placeholder); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } return result; } loadLanguage(language) { var _this = this; return _asyncToGenerator(function* () { if (_this.sessionUpdateLog.includes(language)) { return; } try { const response = yield (yield fetch("https://gitcdn.qiuwen.net.cn/InterfaceAdmin/Wikiplus/raw/branch/dev/languages/".concat(language, ".json"))).json(); const nowVersion = localStorage.getItem("Wikiplus_LanguageVersion") || "000"; _this.sessionUpdateLog.push(language); if (response.__version !== nowVersion || !(language in _this.i18nData)) { console.info("Update ".concat(language, " support to version ").concat(response.__version)); _this.i18nData[language] = response; localStorage.setItem("Wikiplus_i18nCache", JSON.stringify(_this.i18nData)); } } catch { } })(); } }; i18n_default = new I18n(); } }); //! src/Wikiplus/modules/utils/log.js var WikiplusError; var Log; var log_default; var init_log = __esm({ "src/Wikiplus/modules/utils/log.js"() { "use strict"; init_i18n(); WikiplusError = class extends Error { constructor(message, code) { super(message); this.code = code; } }; Log = { debug(message = "") { console.debug("[Wikiplus-DEBUG] ".concat(message)); }, info(message = "") { console.info("[Wikiplus-INFO] ".concat(message)); }, error(errorCode, payloads = []) { let template = i18n_default.translate(errorCode); if (payloads.length > 0) { var _iterator2 = _createForOfIteratorHelper(payloads.entries()), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) { const [i, v] = _step2.value; template = template.replace(new RegExp("\\".concat(i + 1), "ig"), v); } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } } console.error("[Wikiplus-ERROR] ".concat(template)); throw new WikiplusError("".concat(template), errorCode); } }; log_default = Log; } }); //! src/Wikiplus/modules/services/wiki.js var Wiki; var wiki_default; var init_wiki = __esm({ "src/Wikiplus/modules/services/wiki.js"() { "use strict"; init_requests(); init_log(); init_i18n(); init_constants(); Wiki = class { pageInfoCache = {}; /** * 获得 Edit Token * Get Edit Token * * @returns {Promise<string>} */ getEditToken() { return _asyncToGenerator(function* () { const response = yield requests_default.get({ action: "query", meta: "tokens", format: "json" }); if (response.query && response.query.tokens && response.query.tokens.csrftoken && response.query.tokens.csrftoken !== "+\\") { return response.query.tokens.csrftoken; } return log_default.error("fail_to_get_edittoken"); })(); } /** * 获得页面上一版本时间戳 * Get the timestamp of the last revision of page specified. * * @param {params.string} title 页面名 / Pagename * @param {params.revisionId} revisionId 修订版本号 / Revision ID * @returns {Promise<string>} */ getPageInfo({ title, revisionId }) { var _this2 = this; return _asyncToGenerator(function* () { try { const params = { action: "query", prop: "revisions|info", rvprop: "timestamp|ids", format: "json" }; if (revisionId) { params.revids = revisionId; } else if (title) { if (_this2.pageInfoCache[title]) { return { timestamp: _this2.pageInfoCache[title].timestamp, revisionId: _this2.pageInfoCache[title].revid }; } params.titles = title; } const response = yield requests_default.get(params); if (response.query && response.query.pages) { if (Object.keys(response.query.pages)[0] === "-1") { return {}; } const pageInfo = response.query.pages[Object.keys(response.query.pages)[0]].revisions[0]; if (title) { _this2.pageInfoCache[title] = pageInfo; } return { timestamp: pageInfo.timestamp, revisionId: pageInfo.revid }; } } catch { log_default.error("fail_to_get_edittoken"); } })(); } /** * 获得页面的 Wikitext * Get wikitext of the page. * * @param {string} title title * @param {Object} config * @param {string} config.revisionId 版本号 * @param {string} config.section 段落号 * @return {Promise<string>} wikitext内容 */ getWikiText({ section, revisionId }) { return _asyncToGenerator(function* () { try { const response = yield (yield fetch("".concat(location.protocol, "//").concat(location.host).concat(constants_default.scriptPath, "/index.php?oldid=").concat(revisionId, "§ion=").concat(section, "&action=raw"))).text(); return response; } catch { log_default.error("fail_to_get_wikitext"); } })(); } /** * 解析 Wikitext * * @param {string} wikitext wikitext * @param {string} title 页面标题 * @param {Object} config 设置 * @return {Promise<string>} 解析结果 HTML */ parseWikiText(wikitext, title = "", config = {}) { return _asyncToGenerator(function* () { try { const response = yield requests_default.post({ format: "json", action: "parse", text: wikitext, title, pst: "true" }); if (response.parse && response.parse.text) { return response.parse.text["*"]; } } catch { log_default.error("cant_parse_wikitext"); } })(); } /** * 编辑页面 * * @param root0 * @param root0.title * @param root0.content * @param root0.editToken * @param root0.timestamp * @param root0.config * @param root0.additionalConfig */ edit({ title, content, editToken, timestamp, config = {}, additionalConfig = {} } = {}) { return _asyncToGenerator(function* () { let response; try { response = yield requests_default.post({ action: "edit", format: "json", text: content, title, token: editToken, ...timestamp ? { basetimestamp: timestamp } : {}, ...config, ...additionalConfig }); } catch { log_default.error("network_edit_error"); } if (response.edit) { if (response.edit.result === "Success") { return true; } if (response.edit.code) { throw new Error("\n ".concat(i18n_default.translate("hit_abusefilter"), ":").concat(response.edit.info.replace("/Hit AbuseFilter: /ig", ""), '\n <br>\n <div style="font-size: smaller;">').concat(response.edit.warning, "</div>\n ")); } else { log_default.error("unknown_edit_error"); } } else if (response.error && response.error.code) { log_default.error(response.error.code); } else if (response.code) { log_default.error(response.code); } else { log_default.error("unknown_edit_error"); } })(); } /** * 获得指定页面最新修订编号 * Get latest revisionId of a page. * * @param {*} title */ getLatestRevisionIdForPage(title) { var _this3 = this; return _asyncToGenerator(function* () { const { revisionId } = yield _this3.getPageInfo({ title }); return revisionId; })(); } }; wiki_default = new Wiki(); } }); //! src/Wikiplus/modules/core/page.js var Page; var page_default; var init_page = __esm({ "src/Wikiplus/modules/core/page.js"() { "use strict"; init_wiki(); init_log(); Page = class { timestamp; editToken; title; revisionId; inited = false; isNewPage = false; sectionCache = {}; /** * @param {params.title} 页面标题 Page Name (optional) * @param {params.revisionId} 页面修订编号 Revision Id */ constructor({ title, revisionId }) { this.title = title; this.revisionId = revisionId; this.isNewPage = !revisionId; } /** * 初始化 获得页面EditToken和初始TimeStamp * Initialization. * * @param {string} editToken (optional) 如果提供了editToken,将不会再获取 */ init({ editToken = "" } = {}) { var _this4 = this; return _asyncToGenerator(function* () { const promiseArr = [_this4.getTimestamp()]; if (!editToken) { promiseArr.push(_this4.getEditToken()); } yield Promise.all(promiseArr); _this4.inited = true; log_default.info("Page initialization for ".concat(_this4.title, "#").concat(_this4.revisionId, " finished.")); })(); } /** * 获得 EditToken * Get EditToken */ getEditToken() { var _this5 = this; return _asyncToGenerator(function* () { yield mw.loader.using("mediawiki.user"); if (mw.user.tokens.get("csrfToken") && mw.user.tokens.get("csrfToken") !== "+\\") { _this5.editToken = mw.user.tokens.get("csrfToken"); return; } _this5.editToken = yield wiki_default.getEditToken(); })(); } /** * 获得编辑基准时间戳 * Get Base Timestamp */ getTimestamp() { var _this6 = this; return _asyncToGenerator(function* () { const { timestamp, revisionId } = yield wiki_default.getPageInfo({ revisionId: _this6.revisionId, title: _this6.title }); _this6.timestamp = timestamp; if (revisionId) { _this6.revisionId = revisionId; _this6.isNewPage = false; } })(); } /** * 获得 WikiText * * @param {Object} config * @param {string} config.section * @param {string} config.revisionId */ getWikiText({ section = "" } = {}) { var _this7 = this; return _asyncToGenerator(function* () { const sec = section === -1 ? "" : section; if (_this7.sectionCache[sec]) { return _this7.sectionCache[sec]; } const wikiText = yield wiki_default.getWikiText({ section: sec, revisionId: _this7.revisionId }); log_default.info("Wikitext of ".concat(_this7.title, "#").concat(section, " fetched.")); _this7.sectionCache[sec] = wikiText; return wikiText; })(); } /** * 解析 WikiText * * @param {string} wikitext */ parseWikiText(wikitext) { var _this8 = this; return _asyncToGenerator(function* () { return wiki_default.parseWikiText(wikitext, _this8.title); })(); } /** * 编辑页面 * * @param {*} config * @param payload */ edit(payload) { var _this9 = this; return _asyncToGenerator(function* () { if (!_this9.editToken) { log_default.error("fail_to_get_edittoken"); return; } if (!_this9.timestamp && !_this9.isNewPage) { log_default.error("fail_to_get_timestamp"); return; } return wiki_default.edit({ title: _this9.title, editToken: _this9.editToken, ..._this9.timestamp ? { timestamp: _this9.timestamp } : {}, ...payload, additionalConfig: { ..._this9.isNewPage ? { createonly: _this9.isNewPage } : {} } }); })(); } }; page_default = Page; } }); //! src/Wikiplus/modules/core/notification.js var Notification; var notification_default; var init_notification = __esm({ "src/Wikiplus/modules/core/notification.js"() { "use strict"; Notification = class { constructor() { this.init(); } init() { $("body").append('<div id="MoeNotification"></div>'); } display(text = "喵~", type = "success", callback = () => { }) { $("#MoeNotification").append($("<div>").addClass("MoeNotification-notice").addClass("MoeNotification-notice-".concat(type)).append("<span>".concat(text, "</span>"))); $("#MoeNotification").find(".MoeNotification-notice").last().fadeIn(300); this.bind(); this.clear(); callback($("#MoeNotification").find(".MoeNotification-notice").last()); } bind() { const self2 = this; $(".MoeNotification-notice").on("mouseover", function() { self2.slideLeft($(this)); }); } success(text, callback) { this.display(text, "success", callback); } warning(text, callback) { this.display(text, "warning", callback); } error(text, callback) { this.display(text, "error", callback); } clear() { if ($(".MoeNotification-notice").length >= 10) { $("#MoeNotification").children().first().fadeOut(150, function() { $(this).remove(); }); setTimeout(this.clear, 300); } } empty(f) { $(".MoeNotification-notice").each(function(i) { if (typeof f === "function") { const ele = $(this); setTimeout(() => { f(ele); }, 200 * i); } else { $(this).delay(i * 200).fadeOut("fast", function() { $(this).remove(); }); } }); } slideLeft(ele, speed) { ele.css("position", "relative"); ele.animate({ left: "-200%" }, speed || 150, function() { $(this).fadeOut("fast", function() { $(this).remove(); }); }); } }; notification_default = new Notification(); } }); //! src/Wikiplus/modules/utils/sleep.js var sleep; var sleep_default; var init_sleep = __esm({ "src/Wikiplus/modules/utils/sleep.js"() { "use strict"; sleep = (time) => { return new Promise((resolve) => { return setTimeout(resolve, time); }); }; sleep_default = sleep; } }); //! src/Wikiplus/modules/utils/helpers.js function parseQuery(url) { const reg = /(([^?&=]+)(?:=([^?&=]*))*)/g; const params = {}; let match; while (match = reg.exec(url)) { try { params[match[2]] = decodeURIComponent(match[3]); } catch { params[match[2]] = match[3]; } } return params; } var init_helpers = __esm({ "src/Wikiplus/modules/utils/helpers.js"() { "use strict"; } }); //! src/Wikiplus/modules/core/ui.js var UI; var ui_default; var init_ui = __esm({ "src/Wikiplus/modules/core/ui.js"() { "use strict"; init_constants(); init_notification(); init_i18n(); init_log(); init_sleep(); init_helpers(); UI = class { quickEditPanelVisible = false; scrollTop = 0; /** * 创建居中对话框 * * @param {string} title 窗口标题 * @param {string | JQuery<HTMLElement>} content 内容 * @param {*} width 宽度 * @param {*} callback 回调函数 */ createDialogBox(title = "Wikiplus", content = "", width = 600, callback = () => { }) { if ($(".Wikiplus-InterBox").length > 0) { $(".Wikiplus-InterBox").each(function() { $(this).remove(); }); } const clientWidth = window.innerWidth; const clientHeight = window.innerHeight; const dialogWidth = Math.min(clientWidth, width); const dialogBox = $("<div>").addClass("Wikiplus-InterBox").css({ "margin-left": clientWidth / 2 - dialogWidth / 2, top: $(document).scrollTop() + clientHeight * 0.2, display: "none" }).append($("<div>").addClass("Wikiplus-InterBox-Header").html(title)).append($("<div>").addClass("Wikiplus-InterBox-Content").append(content)).append($("<span>").text("×").addClass("Wikiplus-InterBox-Close")); $("body").append(dialogBox); $(".Wikiplus-InterBox").width(dialogWidth); $(".Wikiplus-InterBox-Close").on("click", function() { $(this).parent().fadeOut("fast", function() { window.addEventListener("close", window.onbeforeunload = void 0); $(this).remove(); }); }); const bindDragging = function(element) { element.mousedown((e) => { const baseX = e.clientX; const baseY = e.clientY; const baseOffsetX = element.parent().offset().left; const baseOffsetY = element.parent().offset().top; $(document).on("mousemove", (e2) => { element.parent().css({ "margin-left": baseOffsetX + e2.clientX - baseX, top: baseOffsetY + e2.clientY - baseY }); }); $(document).on("mouseup", () => { element.unbind("mousedown"); $(document).off("mousemove"); $(document).off("mouseup"); bindDragging(element); }); }); }; bindDragging($(".Wikiplus-InterBox-Header")); $(".Wikiplus-InterBox").fadeIn(500); callback(); return dialogBox; } /** * 在搜索框左侧「更多」菜单内添加按钮 * Add a button in "More" menu (left of the search bar) * * @param {string} text 按钮名 Button text * @param {string} id 按钮id Button id * @return {JQuery<HTMLElement>} button */ addFunctionButton(text, id) { let button; switch (constants_default.skin) { case "minerva": button = $("<li>").attr("id", id).addClass("toggle-list-item").append($("<a>").addClass("mw-ui-icon mw-ui-icon-before toggle-list-item__anchor").append($("<span>").attr("href", "javascript:void(0);").addClass("toggle-list-item__label").text(text))); break; case "moeskin": button = $("<li>").addClass("Wikiplus-More-Function-Button").attr("id", id).append($("<a>").attr("href", "javascript:void(0);").text(text)); break; default: button = $("<li>").addClass("mw-list-item").addClass("vector-tab-noicon").attr("id", id).append($("<a>").attr("href", "javascript:void(0);").text(text)); } if (constants_default.skin === "minerva" && $("#p-tb").length > 0) { $("#p-tb").append(button); return $("#".concat(id)); } else if (constants_default.skin === "moeskin") { $(".more-actions-list").first().append(button); return $("#".concat(id)); } else if ($("#p-cactions").length > 0) { $("#p-cactions ul").append(button); return $("#".concat(id)); } log_default.info(i18n_default.translate("cant_add_funcbtn")); } /** * 插入快速重定向按钮 * * @param {*} onClick */ insertSimpleRedirectButton(onClick = () => { }) { const button = this.addFunctionButton(i18n_default.translate("redirect_from"), "Wikiplus-SR-Intro"); if (button) { button.on("click", onClick); } } /** * 插入设置面板按钮 * * @param {*} onClick */ insertSettingsPanelButton(onClick = () => { }) { const button = this.addFunctionButton(i18n_default.translate("wikiplus_settings"), "Wikiplus-Settings-Intro"); if (button) { button.on("click", onClick); } } /** * 插入顶部快速编辑按钮 * Insert QuickEdit button besides page edit button. * * @param onClick */ insertTopQuickEditEntry(onClick) { const topBtn = $("<li>").attr("id", "Wikiplus-Edit-TopBtn").attr("class", "mw-list-item"); const topBtnLink = $("<a>").attr("href", "javascript:void(0)").text("".concat(i18n_default.translate("quickedit_topbtn"))); topBtn.append(topBtnLink); switch (constants_default.skin) { case "minerva": topBtn.css({ "align-items": "center", display: "flex" }); topBtn.find("span").addClass("page-actions-menu__list-item"); topBtn.find("a").addClass("mw-ui-icon mw-ui-icon-element mw-ui-icon-wikimedia-edit-base20 mw-ui-icon-with-label-desktop").css("vertical-align", "middle"); break; case "vector-2022": topBtn.addClass("vector-tab-noicon"); break; case "vector": topBtn.append($("<span>").append(topBtnLink)); break; default: } $(topBtn).on("click", () => { onClick({ sectionNumber: -1, targetPageName: constants_default.currentPageName }); }); if ($("#ca-edit").length > 0 && $("#Wikiplus-Edit-TopBtn").length === 0) { constants_default.skin === "minerva" ? $("#ca-edit").parent().after(topBtn) : $("#ca-edit").after(topBtn); } } /** * 插入段落快速编辑按钮 * Insert QuickEdit buttons for each section. * * @param onClick */ insertSectionQuickEditEntries(onClick = () => { }) { const sectionBtn = constants_default.skin === "minerva" ? $("<span>").append($("<a>").addClass("Wikiplus-Edit-SectionBtn mw-ui-icon mw-ui-icon-element mw-ui-icon-wikimedia-edit-base20 edit-page mw-ui-icon-flush-right").css("margin-left", "0.75em").attr("href", "javascript:void(0)").attr("title", i18n_default.translate("quickedit_sectionbtn"))) : $("<span>").append($("<span>").addClass("mw-editsection-divider").text(" | ")).append($("<a>").addClass("Wikiplus-Edit-SectionBtn").attr("href", "javascript:void(0)").text(i18n_default.translate("quickedit_sectionbtn"))); $(".mw-editsection").each(function(i) { try { const editURL = $(this).find("a[href*='action=edit']").first().attr("href"); const sectionNumber = editURL.match(/&[ve]*section\=([^&]+)/)[1].replace(/T-/gi, ""); const sectionTargetName = decodeURIComponent(editURL.match(/title=(.+?)&/)[1]); const cloneNode = $(this).prev().clone(); cloneNode.find(".mw-headline-number").remove(); const sectionName = cloneNode.text().trim(); const _sectionBtn = sectionBtn.clone(); _sectionBtn.find(".Wikiplus-Edit-SectionBtn").on("click", () => { onClick({ sectionNumber, sectionName, targetPageName: sectionTargetName }); }); constants_default.skin === "minerva" ? $(this).append(_sectionBtn) : $(this).find(".mw-editsection-bracket").last().before(_sectionBtn); } catch { log_default.error("fail_to_init_quickedit"); } }); } /** * 插入任意链接编辑入口 * * @param {*} onClick */ insertLinkEditEntries(onClick = () => { }) { $("#mw-content-text a.external").each(function(i) { const url = $(this).attr("href"); const params = parseQuery(url); if (params.action === "edit" && params.title !== void 0 && params.section !== "new") { $(this).after($("<a>").attr({ href: "javascript:void(0)", class: "Wikiplus-Edit-EveryWhereBtn" }).text("(".concat(i18n_default.translate("quickedit_sectionbtn"), ")")).on("click", () => { var _params$section; onClick({ targetPageName: params.title, sectionNumber: (_params$section = params.section) !== null && _params$section !== void 0 ? _params$section : -1 }); })); } }); } showQuickEditPanel({ title = "", content = "", summary = "", onBack = () => { }, onParse = () => { }, onEdit = () => { }, escExit = false }) { const self2 = this; this.scrollTop = $(document).scrollTop(); if (this.quickEditPanelVisible) { this.hideQuickEditPanel(); } this.quickEditPanelVisible = true; window.addEventListener("close", window.onbeforeunload = function() { return "".concat(i18n_default.translate("onclose_confirm")); }); const isNewPage = $(".noarticletext").length > 0; const backBtn = $("<span>").attr("id", "Wikiplus-Quickedit-Back").addClass("Wikiplus-Btn").text("".concat(i18n_default.translate("back"))); const jumpBtn = $("<span>").attr("id", "Wikiplus-Quickedit-Jump").addClass("Wikiplus-Btn").append($("<a>").attr("href", "#Wikiplus-Quickedit").text("".concat(i18n_default.translate("goto_editbox")))); const inputBox = $("<textarea>").attr("id", "Wikiplus-Quickedit"); const previewBox = $("<div>").attr("id", "Wikiplus-Quickedit-Preview-Output"); const summaryBox = $("<input>").attr("id", "Wikiplus-Quickedit-Summary-Input").attr("placeholder", "".concat(i18n_default.translate("summary_placehold"))); const editSubmitBtn = $("<button>").attr("id", "Wikiplus-Quickedit-Submit").text("".concat(i18n_default.translate(isNewPage ? "publish_page" : "publish_change"), "(Ctrl+S)")); const previewSubmitBtn = $("<button>").attr("id", "Wikiplus-Quickedit-Preview-Submit").text("".concat(i18n_default.translate("preview"))); const isMinorEdit = $("<div>").append($("<input>").attr({ type: "checkbox", id: "Wikiplus-Quickedit-MinorEdit" })).append($("<label>").attr("for", "Wikiplus-Quickedit-MinorEdit").text("".concat(i18n_default.translate("mark_minoredit"), "(Ctrl+Shift+S)"))).css({ margin: "5px 5px 5px -3px", display: "inline" }); const editBody = $("<div>").append(backBtn, jumpBtn, previewBox, inputBox, summaryBox, $("<br>"), isMinorEdit, editSubmitBtn, previewSubmitBtn); this.createDialogBox(title, editBody, 1e3, () => { $("#Wikiplus-Quickedit").val(content); $("#Wikiplus-Quickedit-Summary-Input").val(summary); }); $("#Wikiplus-Quickedit-Back").on("click", onBack); $("#Wikiplus-Quickedit-Preview-Submit").on("click", /* @__PURE__ */ _asyncToGenerator(function* () { const preloadBanner = $("<div>").addClass("Wikiplus-Banner").text("".concat(i18n_default.translate("loading_preview"))); const wikiText = $("#Wikiplus-Quickedit").val(); $(this).attr("disabled", "disabled"); $("#Wikiplus-Quickedit-Preview-Output").fadeOut(100, () => { $("#Wikiplus-Quickedit-Preview-Output").html("").append(preloadBanner); $("#Wikiplus-Quickedit-Preview-Output").fadeIn(100); }); $("html, body").animate({ scrollTop: self2.scrollTop }, 200); const result = yield onParse(wikiText); $("#Wikiplus-Quickedit-Preview-Output").fadeOut("100", () => { $("#Wikiplus-Quickedit-Preview-Output").html('<hr><div class="mw-body-content">'.concat(result, "</div><hr>")); $("#Wikiplus-Quickedit-Preview-Output").fadeIn("100"); $("#Wikiplus-Quickedit-Preview-Submit").prop("disabled", false); }); })); $("#Wikiplus-Quickedit-Submit").on("click", /* @__PURE__ */ _asyncToGenerator(function* () { const timer = Date.now(); const editBanner = $("<div>").addClass("Wikiplus-Banner").text("".concat(i18n_default.translate("submitting_edit"))); const payload = { summary: $("#Wikiplus-Quickedit-Summary-Input").val(), content: $("#Wikiplus-Quickedit").val(), isMinorEdit: $("#Wikiplus-Quickedit-MinorEdit").is(":checked") }; $("#Wikiplus-Quickedit-Submit,#Wikiplus-Quickedit,#Wikiplus-Quickedit-Preview-Submit").attr("disabled", "disabled"); $("html, body").animate({ scrollTop: self2.scrollTop }, 200); $("#Wikiplus-Quickedit-Preview-Output").fadeOut(100, () => { $("#Wikiplus-Quickedit-Preview-Output").html("").append(editBanner); $("#Wikiplus-Quickedit-Preview-Output").fadeIn(100); }); try { yield onEdit(payload); const useTime = Date.now() - timer; $("#Wikiplus-Quickedit-Preview-Output").find(".Wikiplus-Banner").css("background", "rgba(6, 239, 92, 0.44)"); $("#Wikiplus-Quickedit-Preview-Output").find(".Wikiplus-Banner").text("".concat(i18n_default.translate("edit_success", [useTime.toString()]))); window.addEventListener("close", window.onbeforeunload = void 0); setTimeout(() => { location.reload(); }, 500); } catch (error) { console.log(error); $(".Wikiplus-Banner").css("background", "rgba(218, 142, 167, 0.65)"); $(".Wikiplus-Banner").html(error.message); } finally { $("#Wikiplus-Quickedit-Submit,#Wikiplus-Quickedit,#Wikiplus-Quickedit-Preview-Submit").prop("disabled", false); } })); $("#Wikiplus-Quickedit,#Wikiplus-Quickedit-Summary-Input,#Wikiplus-Quickedit-MinorEdit").on("keydown", (e) => { if (e.ctrlKey && e.which === 83) { if (e.shiftKey) { $("#Wikiplus-Quickedit-MinorEdit").trigger("click"); } $("#Wikiplus-Quickedit-Submit").trigger("click"); e.preventDefault(); e.stopPropagation(); } }); if (escExit) { $(document).on("keydown", (e) => { if (e.which === 27) { $("#Wikiplus-Quickedit-Back").trigger("click"); } }); } } hideQuickEditPanel() { this.quickEditPanelVisible = false; $(".Wikiplus-InterBox").fadeOut("fast", function() { window.addEventListener("close", window.onbeforeunload = void 0); $(this).remove(); }); } /** * 显示快速重定向弹窗 * * @param root0 * @param root0.onEdit * @param root0.onSuccess */ showSimpleRedirectPanel({ onEdit = () => { }, onSuccess = () => { } } = {}) { var _this10 = this; const input = $("<input>").addClass("Wikiplus-InterBox-Input"); const applyBtn = $("<div>").addClass("Wikiplus-InterBox-Btn").attr("id", "Wikiplus-SR-Apply").text(i18n_default.translate("submit")); const cancelBtn = $("<div>").addClass("Wikiplus-InterBox-Btn").attr("id", "Wikiplus-SR-Cancel").text(i18n_default.translate("cancel")); const continueBtn = $("<div>").addClass("Wikiplus-InterBox-Btn").attr("id", "Wikiplus-SR-Continue").text(i18n_default.translate("continue")); const content = $("<div>").append(input).append($("<hr>")).append(applyBtn).append(cancelBtn); const dialog = this.createDialogBox(i18n_default.translate("redirect_desc"), content, 600); applyBtn.on("click", /* @__PURE__ */ _asyncToGenerator(function* () { const title = $(".Wikiplus-InterBox-Input").val(); $(".Wikiplus-InterBox-Content").html('<div class="Wikiplus-Banner">'.concat(i18n_default.translate("submitting_edit"), "</div>")); try { yield onEdit({ title, forceOverwrite: false }); $(".Wikiplus-Banner").text(i18n_default.translate("redirect_saved")); _this10.hideSimpleRedirectPanel(dialog); onSuccess({ title }); } catch (error) { $(".Wikiplus-Banner").css("background", "rgba(218, 142, 167, 0.65)"); $(".Wikiplus-Banner").text(error.message); if (error.code === "articleexists") { $(".Wikiplus-InterBox-Content").append($("<hr>")).append(continueBtn).append(cancelBtn); cancelBtn.on("click", () => { _this10.hideSimpleRedirectPanel(dialog); }); continueBtn.on("click", /* @__PURE__ */ _asyncToGenerator(function* () { $(".Wikiplus-InterBox-Content").html('<div class="Wikiplus-Banner">'.concat(i18n_default.translate("submitting_edit"), "</div>")); try { yield onEdit({ title, forceOverwrite: true }); $(".Wikiplus-Banner").text(i18n_default.translate("redirect_saved")); _this10.hideSimpleRedirectPanel(dialog); onSuccess({ title }); } catch (error2) { $(".Wikiplus-Banner").css("background", "rgba(218, 142, 167, 0.65)"); $(".Wikiplus-Banner").text(error2.message); } })); } } })); cancelBtn.on("click", () => { this.hideSimpleRedirectPanel(dialog); }); } /** * 隐藏快速重定向弹窗 * * @param {*} dialog */ hideSimpleRedirectPanel(dialog = $("body")) { dialog.find(".Wikiplus-InterBox-Close").trigger("click"); } showSettingsPanel({ onSubmit = () => { } } = {}) { var _this11 = this; const input = $("<textarea>").attr("id", "Wikiplus-Setting-Input").attr("rows", "10"); const applyBtn = $("<div>").addClass("Wikiplus-InterBox-Btn").attr("id", "Wikiplus-Setting-Apply").text(i18n_default.translate("submit")); const cancelBtn = $("<div>").addClass("Wikiplus-InterBox-Btn").attr("id", "Wikiplus-Setting-Cancel").text(i18n_default.translate("cancel")); const content = $("<div>").append(input).append($("<hr>")).append(applyBtn).append(cancelBtn); const dialog = this.createDialogBox(i18n_default.translate("wikiplus_settings_desc"), content, 600, () => { if (localStorage.Wikiplus_Settings) { $("#Wikiplus-Setting-Input").val(localStorage.Wikiplus_Settings); try { const settings = JSON.parse(localStorage.Wikiplus_Settings); $("#Wikiplus-Setting-Input").val(JSON.stringify(settings, null, 2)); } catch { } } else { $("#Wikiplus-Setting-Input").attr("placeholder", i18n_default.translate("wikiplus_settings_placeholder")); } }); applyBtn.on("click", /* @__PURE__ */ _asyncToGenerator(function* () { const savedBanner = $("<div>").addClass("Wikiplus-Banner").text(i18n_default.translate("wikiplus_settings_saved")); const settings = $("#Wikiplus-Setting-Input").val(); try { onSubmit({ settings }); $(".Wikiplus-InterBox-Content").html("").append(savedBanner); yield sleep_default(1500); _this11.hideSettingsPanel(dialog); } catch { notification_default.error(i18n_default.translate("wikiplus_settings_grammar_error")); } })); cancelBtn.on("click", () => { this.hideSettingsPanel(dialog); }); } hideSettingsPanel(dialog = $("body")) { dialog.find(".Wikiplus-InterBox-Close").trigger("click"); } bindPreloadEvents(onPreload) { $("#toc").children("ul").find("a").each(function(i) { $(this).on("mouseover", function() { $(this).off("mouseover"); onPreload({ sectionNumber: i + 1 }); }); }); } }; ui_default = new UI(); } }); //! src/Wikiplus/modules/utils/settings.js var Settings; var settings_default; var init_settings = __esm({ "src/Wikiplus/modules/utils/settings.js"() { "use strict"; Settings = class { getSetting(key, object = {}) { const w = object; let settings; try { settings = JSON.parse(localStorage["Wikiplus_Settings"]); } catch { return; } try { const customSettingFunction = new Function("return ".concat(settings[key])); if (typeof customSettingFunction === "function") { try { if (customSettingFunction()(w) === true) { } else { return customSettingFunction()(w) || settings[key]; } } catch { return settings[key]; } } else { return settings[key]; } } catch { try { let result = settings[key]; for (var _i4 = 0, _Object$keys3 = Object.keys(object); _i4 < _Object$keys3.length; _i4++) { const key2 = _Object$keys3[_i4]; result = result.replace("${".concat(key2, "}"), object[key2]); } return result; } catch { } } } }; settings_default = new Settings(); } }); //! src/Wikiplus/modules/wikiplus.less var init_wikiplus = __esm({ "src/Wikiplus/modules/wikiplus.less"() { } }); //! src/Wikiplus/modules/index.js var modules_exports = {}; var init_modules = __esm({ "src/Wikiplus/modules/index.js"() { "use strict"; init_page(); init_ui(); init_notification(); init_wiki(); init_settings(); init_log(); init_constants(); init_i18n(); init_wikiplus(); $(/* @__PURE__ */ _asyncToGenerator(function* () { const Pages = {}; const isCurrentPageEmpty = $(".noarticletext").length > 0 && constants_default.articleId === 0; const getPage = /* @__PURE__ */ function() { var _ref7 = _asyncToGenerator(function* ({ revisionId: revisionId2, title }) { if (Pages[revisionId2]) { return Pages[revisionId2]; } const newPage = new page_default({ revisionId: revisionId2, title }); yield newPage.init(); Pages[revisionId2] = newPage; return Pages[revisionId2]; }); return function getPage2(_x) { return _ref7.apply(this, arguments); }; }(); log_default.info("Wikiplus now loading. Version: ".concat(constants_default.version)); if (!window.mw) { console.log("Mediawiki JavaScript not loaded or not a Mediawiki website."); return; } if (!constants_default.userGroups.includes("autoconfirmed") && !constants_default.userGroups.includes("confirmed")) { notification_default.error(i18n_default.translate("not_autoconfirmed_user")); log_default.info(i18n_default.translate("not_autoconfirmed_user")); return; } if (!constants_default.isArticle || constants_default.action !== "view") { log_default.info("Not an editable page. Stop initialization."); return; } window._WikiplusPages = Pages; const currentPageName = constants_default.currentPageName; const revisionId = constants_default.revisionId; const currentPage = yield getPage({ revisionId, title: currentPageName }); const handleQuickEditButtonClicked = /* @__PURE__ */ function() { var _ref8 = _asyncToGenerator(function* ({ sectionNumber, sectionName, targetPageName } = {}) { const isOtherPage = targetPageName !== currentPageName; if (isOtherPage && constants_default.latestRevisionId !== constants_default.revisionId) { log_default.error("cross_page_history_revision_edit_warning"); return; } const revisionId2 = isOtherPage ? yield wiki_default.getLatestRevisionIdForPage(targetPageName) : constants_default.revisionId; const page = yield getPage({ revisionId: revisionId2, title: targetPageName }); const customSummary = settings_default.getSetting("defaultSummary", { sectionName, sectionNumber, sectionTargetName: targetPageName }); const summary = customSummary || (sectionName ? "/* ".concat(sectionName, " */ ").concat(i18n_default.translate("default_summary_suffix")) : i18n_default.translate("default_summary_suffix")); const timer = setTimeout(() => { notification_default.success(i18n_default.translate("loading")); }, 200); const sectionContent = yield page.getWikiText({ section: sectionNumber }); const isEditHistoryRevision = !isOtherPage && constants_default.latestRevisionId !== constants_default.revisionId; const escToExit = settings_default.getSetting("esc_to_exit_quickedit") === true || // 兼容老设置key settings_default.getSetting("esc_to_exit_quickedit") === "true" || settings_default.getSetting("escToExitQuickEdit") === true || settings_default.getSetting("escToExitQuickEdit") === "true"; const customEditTags = settings_default.getSetting("custom_edit_tags"); const defaultEditTags = []; const editTags = customEditTags !== null && customEditTags !== void 0 && customEditTags.length ? customEditTags : defaultEditTags; clearTimeout(timer); notification_default.empty(); if (isEditHistoryRevision) { notification_default.warning(i18n_default.translate("history_edit_warning")); } const shouldShowCreatePageTip = isOtherPage ? !revisionId2 : isCurrentPageEmpty; ui_default.showQuickEditPanel({ title: "".concat(i18n_default.translate("quickedit_topbtn")).concat(isEditHistoryRevision ? i18n_default.translate("history_edit_warning") : ""), content: shouldShowCreatePageTip ? i18n_default.translate("create_page_tip") : sectionContent, summary, onBack: ui_default.hideQuickEditPanel, onParse: (wikiText) => { return page.parseWikiText(wikiText); }, onEdit: function() { var _ref9 = _asyncToGenerator(function* ({ content, summary: summary2, isMinorEdit }) { const editPayload = { content, config: { summary: summary2, ...sectionNumber === -1 ? {} : { section: sectionNumber }, ...editTags.length ? { tags: editTags.join("|") } : {} } }; if (isMinorEdit) { editPayload.config.minor = "true"; } else { editPayload.config.notminor = "true"; } yield page.edit(editPayload); }); return function onEdit(_x2) { return _ref9.apply(this, arguments); }; }(), escExit: escToExit }); }); return function handleQuickEditButtonClicked2() { return _ref8.apply(this, arguments); }; }(); const handleSimpleRedirectButtonClicked = /* @__PURE__ */ function() { var _ref10 = _asyncToGenerator(function* () { ui_default.showSimpleRedirectPanel({ onEdit: function() { var _ref11 = _asyncToGenerator(function* ({ title, forceOverwrite = false }) { const page = yield getPage({ title }); const currentPageName2 = constants_default.currentPageName; const payload = { content: "#REDIRECT [[".concat(currentPageName2, "]]"), config: { summary: i18n_default.translate("redirect_from_summary", [title, currentPageName2]) } }; if (!forceOverwrite) { payload.config.createonly = "true"; } yield page.edit(payload); }); return function onEdit(_x3) { return _ref11.apply(this, arguments); }; }(), onSuccess: ({ title }) => { location.href = constants_default.articlePath.replace(/\$1/gi, title); } }); }); return function handleSimpleRedirectButtonClicked2() { return _ref10.apply(this, arguments); }; }(); const handleSettingsButtonClicked = /* @__PURE__ */ function() { var _ref12 = _asyncToGenerator(function* () { ui_default.showSettingsPanel({ onSubmit: ({ settings }) => { JSON.parse(settings); localStorage.setItem("Wikiplus_Settings", settings); } }); }); return function handleSettingsButtonClicked2() { return _ref12.apply(this, arguments); }; }(); const handlePreload = /* @__PURE__ */ function() { var _ref13 = _asyncToGenerator(function* ({ sectionNumber }) { yield currentPage.getWikiText({ section: sectionNumber }); }); return function handlePreload2(_x4) { return _ref13.apply(this, arguments); }; }(); ui_default.insertTopQuickEditEntry(handleQuickEditButtonClicked); ui_default.insertSectionQuickEditEntries(handleQuickEditButtonClicked); ui_default.insertLinkEditEntries(handleQuickEditButtonClicked); ui_default.insertSimpleRedirectButton(handleSimpleRedirectButtonClicked); ui_default.insertSettingsPanelButton(handleSettingsButtonClicked); ui_default.bindPreloadEvents(handlePreload); })); } }); //! src/Wikiplus/resize.ts var resize_exports = {}; var import_ext_gadget; var init_resize = __esm({ "src/Wikiplus/resize.ts"() { "use strict"; import_ext_gadget = require("ext.gadget.Util"); void (0, import_ext_gadget.getBody)().then(($body) => { $(window).on("resize", () => { const windowWidth = $(window).width(); const $wikiplusInterbox = $body.find(".Wikiplus-InterBox"); if ($wikiplusInterbox) { $wikiplusInterbox.css("max-width", "calc(".concat(windowWidth, "px - 2em)")); } }); }); } }); //! src/Wikiplus/Wikiplus.ts _asyncToGenerator(function* () { const { wgAction, wgIsArticle } = mw.config.get(); if (wgAction !== "view" || !wgIsArticle) { return; } const { "visualeditor-enable": isVeEnable } = mw.user.options.get(); const loader = /* @__PURE__ */ function() { var _ref15 = _asyncToGenerator(function* () { yield Promise.resolve().then(() => (init_modules(), modules_exports)); yield Promise.resolve().then(() => (init_resize(), resize_exports)); }); return function loader2() { return _ref15.apply(this, arguments); }; }(); if (isVeEnable) { yield mw.loader.using("ext.visualEditor.core"); } void loader(); })(); })();
该页面使用的模板:
Template:Gadget Header
(
查看源代码
)
返回
MediaWiki:Gadget-Wikiplus.js
。
开关有限宽度模式