MediaWiki:Gadget-Navigation popups.js
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
/**
* SPDX-License-Identifier: CC-BY-SA-4.0
* _addText: '{{Gadget Header|license=CC-BY-SA-4.0}}'
*
* @base {@link https://en.wikipedia.org/wiki/MediaWiki:Gadget-popups.js}
* @base {@link https://zh.wikipedia.org/w/index.php?title=User:Lupin/strings-draft&oldid=579996170}
* @base {@link https://zh.wikipedia.org/wiki/MediaWiki:Gadget-navpop.css}
* @source {@link https://git.qiuwen.net.cn/InterfaceAdmin/QiuwenGadgets/src/branch/master/src/Navigation_popups}
* @license CC-BY-SA-4.0 {@link https://www.qiuwenbaike.cn/wiki/H:CC-BY-SA-4.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";
// dist/Navigation_popups/Navigation_popups.js
var _templateObject;
var _templateObject2;
var _templateObject3;
var _templateObject4;
var _templateObject5;
var _templateObject6;
var _templateObject7;
var _templateObject8;
var _templateObject9;
var _templateObject10;
var _templateObject11;
var _templateObject12;
var _templateObject13;
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);
});
};
}
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 _taggedTemplateLiteral(e, t) {
return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
}
//! src/Navigation_popups/modules/api.ts
var import_ext_gadget = require("ext.gadget.Util");
var api = (0, import_ext_gadget.initMwApi)("Navigation popups/1.0");
//! src/Navigation_popups/modules/string.ts
var message = {
// summary data, searching etc.
article: window.wgULS("条目", "條目"),
category: window.wgULS("个分类", "個分類"),
categories: window.wgULS("个分类", "個分類"),
image: window.wgULS("个文件", "個檔案"),
images: window.wgULS("个文件", "個檔案"),
stub: "小作品",
"section stub": window.wgULS("小章节", "小章節"),
"Empty page": window.wgULS("空页面", "空頁面"),
kB: window.wgULS("千字节<sub>(以1000为一进)</sub>", "千位元組<sub>(以1000為一進)</sub>"),
bytes: window.wgULS("字节", "位元組"),
day: "天",
days: "天",
hour: window.wgULS("小时", "小時"),
hours: window.wgULS("小时", "小時"),
minute: "分",
minutes: "分",
second: "秒",
seconds: "秒",
week: "周",
weeks: "周",
month: "月",
months: "月",
year: "年",
years: "年",
search: window.wgULS("搜索", "搜尋"),
SearchHint: window.wgULS("搜索包含 %s 的页面", "搜尋包含 %s 的頁面"),
web: "Bing",
global: "全域",
"more...": "更多……",
// article-related actions and info
// (some actions also apply to user pages)
actions: window.wgULS("操作", "動作"),
// /// view articles and view talk
popupsMenu: "Popups",
"disable previews": window.wgULS("禁用预览", "禁用預覽"),
togglePreviewsHint: window.wgULS("切换本页 Popups 的预览开关", "切換本頁 Popups 的預覽開關"),
"toggle previews": window.wgULS("切换预览开关", "切換預覽開關"),
reset: window.wgULS("复位", "複位"),
disable: "禁用 Popups",
disablePopupsHint: window.wgULS("在本页禁用 Popups,刷新页面以重新启用。", "在本頁禁用 Popups,重新整理頁面以重新啟用。"),
purgePopupsHint: window.wgULS("复位 Popups,清除所有缓存数据。", "複位 Popups,清除所有快取資料。"),
PopupsHint: window.wgULS("复位 Popups,清除所有缓存数据。", "複位 Popups,清除所有快取資料。"),
spacebar: "空格",
view: window.wgULS("查看", "檢視"),
"view article": window.wgULS("查看条目", "檢視條目"),
viewHint: window.wgULS("前往 %s", "前往 %s"),
talk: window.wgULS("讨论", "討論"),
"talk page": window.wgULS("讨论页", "討論頁"),
"this revision": window.wgULS("此修订版本", "此修訂版本"),
"revision %s of %s": window.wgULS("页面 $2 的修订版本 $1", "頁面 $2 的修訂版本 $1"),
"Revision %s of %s": window.wgULS("页面 $2 的修订版本 $1", "頁面 $2 的修訂版本 $1"),
"the revision prior to revision %s of %s": window.wgULS("页面 $2 的修订版本 $1 之前的修订版本", "頁面 $2 的修訂版本 $1 之前的修訂版本"),
"Toggle image size": window.wgULS("点击切换图片大小", "點擊切換圖片大小"),
del: window.wgULS("删除", "删除"),
// /// delete, protect, move
delete: window.wgULS("删除", "删除"),
deleteHint: window.wgULS("删除 %s", "删除 %s"),
undeleteShort: window.wgULS("恢复", "恢復"),
UndeleteHint: window.wgULS("恢复 %s", "恢復 %s"),
protect: window.wgULS("保护", "保護"),
protectHint: window.wgULS("保护 %s", "保護 %s"),
unprotectShort: window.wgULS("解除", "解除"),
unprotectHint: window.wgULS("解除对 %s 的保护", "解除對 %s 的保護"),
move: window.wgULS("移动", "移動"),
"move page": window.wgULS("移动页面", "移動頁面"),
MovepageHint: window.wgULS("修改 %s 的标题", "修改 %s 的標題"),
edit: window.wgULS("编辑", "編輯"),
// /// edit articles and talk
"edit article": window.wgULS("编辑条目", "編輯條目"),
editHint: window.wgULS("修改 %s 的内容", "修改 %s 的內容"),
"edit talk": window.wgULS("编辑讨论页", "編輯對話頁"),
new: window.wgULS("新", "新"),
"new topic": window.wgULS("新话题", "新話題"),
newSectionHint: window.wgULS("在 %s 增加新的讨论话题", "在 %s 增加新的討論話題"),
"null edit": window.wgULS("空编辑", "空編輯"),
nullEditHint: window.wgULS("进行一次对 %s 的空编辑", "製造一次對 %s 的空編輯"),
hist: window.wgULS("历史", "歷史"),
// /// history, diffs, editors, related
history: window.wgULS("历史", "歷史"),
historyHint: window.wgULS("%s 的修订历史", "%s 的修訂歷史"),
last: window.wgULS("之前", "之前"),
// [[MediaWiki:Last]]
lastEdit: window.wgULS("最近更改", "最近更改"),
"show last edit": window.wgULS("最近一次更改", "最新一次修訂"),
"Show the last edit": window.wgULS("显示最近一次更改的差异", "顯示最新一次修訂的差異"),
lastContrib: window.wgULS("最近编辑", "最近編輯"),
"last set of edits": window.wgULS("最近编辑", "最近編輯"),
lastContribHint: window.wgULS("显示由最后一位编辑者造成的差异", "顯示由最後一位編輯者製造的差異"),
cur: window.wgULS("当前", "當前"),
diffCur: window.wgULS("与当前版本的差异", "與目前版本的差異"),
"Show changes since revision %s": window.wgULS("显示自修订版本 %s 的差异", "顯示自修訂版本 %s 的差異"),
"%s old": window.wgULS("%s 前的最后版本", "%s 前的最后版本"),
// as in 4 weeks old
oldEdit: window.wgULS("旧编辑", "舊編輯"),
purge: window.wgULS("清除缓存", "清除快取"),
purgeHint: window.wgULS("清除服务器中 %s 的缓存", "清除伺服器中 %s 的快取"),
raw: window.wgULS("源代码", "原始碼"),
rawHint: window.wgULS("查看 %s 的源代码", "檢視 %s 的原始碼"),
render: window.wgULS("仅正文", "僅正文"),
renderHint: window.wgULS("显示 %s 的纯HTML解析(仅正文内容)", "顯示 %s 的純HTML解析(僅正文內容)"),
"Show the edit made to get revision": window.wgULS("显示编辑以得到修订版本", "顯示編輯以得到修訂版本"),
sinceMe: window.wgULS("自我", "自我"),
"changes since mine": window.wgULS("自我修订的差异", "自我修訂的差異"),
sinceMeHint: window.wgULS("显示自我上次修改以来的差异", "顯示自我上次修改以來的差異"),
"Couldn't find an edit by %s\nin the last %s edits to\n%s": window.wgULS("在 $3 最近 $2 次编辑中找不到 $1 做出的修改", "在 $3 最近 $2 次編輯中找不到 $1 做出的修改"),
eds: window.wgULS("编辑", "編輯"),
editors: window.wgULS("编辑者", "編輯者"),
editorListHint: window.wgULS("列出编辑过 %s 的用户", "列出編輯過 %s 的使用者"),
related: window.wgULS("相关", "相關"),
relatedChanges: window.wgULS("相关更改", "相關更改"),
"related changes": window.wgULS("相关更改", "相關更改"),
RecentchangeslinkedHint: window.wgULS("显示相关 %s 的修改", "顯示相關 %s 的修改"),
editOld: window.wgULS("编辑旧版", "編輯舊版"),
// /// edit old version, or revert
rv: window.wgULS("回退", "恢復"),
revert: window.wgULS("回退", "恢復"),
revertHint: window.wgULS("回退到 %s", "恢復到 %s"),
undo: window.wgULS("撤销", "撤銷"),
undoHint: window.wgULS("撤销这次编辑", "撤銷這次編輯"),
defaultpopupRedlinkSummary: window.wgULS("移除到空页面[[%s]]的链接(Popups)", "移除到空頁面[[%s]]的連結(Popups)"),
defaultpopupFixDabsSummary: window.wgULS("消歧义[[%s]]到[[%s]](Popups)", "消歧義[[%s]]到[[%s]](Popups)"),
defaultpopupFixRedirsSummary: window.wgULS("忽略从[[%s]]到[[%s]]的重定向(Popups)", "忽略從[[%s]]到[[%s]]的重新導向(Popups)"),
defaultpopupExtendedRevertSummary: window.wgULS("回退到$2在$1时编辑的修订版本$3(Popups)", "還原到$2在$1時製作的修訂版本$3(Popups)"),
defaultpopupRevertToPreviousSummary: window.wgULS("回退到修订版本%s的上一个版本(Popups)", "還原到修訂版本%s的上一個版本(Popups)"),
defaultpopupRevertSummary: window.wgULS("回退到修订版本%s(Popups)", "還原到修訂版本%s(Popups)"),
defaultpopupQueriedRevertToPreviousSummary: window.wgULS("回退到修订版本$1的上一个版本,由$3在$2时编辑(Popups)", "還原到修訂版本$1的上一個版本,由$3在$2時製作(Popups)"),
defaultpopupQueriedRevertSummary: window.wgULS("回退到$3在$2时编辑的修订版本$1(Popups)", "還原到$3在$2時製作的修訂版本$1(Popups)"),
defaultpopupRmDabLinkSummary: window.wgULS("移除到消歧义页[[%s]]的链接(Popups)", "移除到消歧義頁[[%s]]的連結(Popups)"),
Redirects: window.wgULS("重定向", "重定向"),
// as in Redirects to ...
// " to ": window.wgULS( "到","到" ),
// as in Redirects to ...
"Bypass redirect": window.wgULS("忽略重定向", "忽略重新導向"),
"Fix this redirect": window.wgULS("修复重定向", "修復重新導向"),
disambig: window.wgULS("消歧义", "消歧義"),
// /// add or remove dab etc.
disambigHint: window.wgULS("消歧义这个链接到 [[%s]]", "消歧義這個連結到 [[%s]]"),
"Click to disambiguate this link to:": window.wgULS("点击以消歧义这个链接到:", "點擊以消歧義這個連結到:"),
"remove this link": window.wgULS("移除链接", "移除連結"),
"remove all links to this page from this article": window.wgULS("移除此条目到这页的所有链接", "移除此條目到這頁的所有連結"),
"remove all links to this disambig page from this article": window.wgULS("移除此条目到这消歧义的所有链接", "移除此條目到這消歧義的所有連結"),
mainlink: window.wgULS("主链接", "主連結"),
// /// links, watch, unwatch
wikiLink: window.wgULS("个内部链接", "个內部連結"),
wikiLinks: window.wgULS("个内部链接", "个內部連結"),
"links here": window.wgULS("链入", "鏈入"),
whatLinksHere: window.wgULS("链入页面", "鏈入頁面"),
"what links here": window.wgULS("链入页面", "鏈入頁面"),
WhatlinkshereHint: window.wgULS("显示链接到 %s 的页面", "顯示連結到 %s 的頁面"),
unwatchShort: window.wgULS("取消", "取消"),
watchThingy: window.wgULS("监视", "監視"),
// called watchThingy because {}.watch is a function
watchHint: window.wgULS("加入 %s 到我的监视列表", "加入 %s 到我的監視列表"),
unwatchHint: window.wgULS("从我的监视列表移除 %s", "從我的監視列表移除 %s"),
"Only found one editor: %s made %s edits": window.wgULS("仅找到一位编者:%s 制造了 %s 次编辑", "僅找到一位編者:%s 製造了 %s 次編輯"),
"%s seems to be the last editor to the page %s": window.wgULS("%s 看上去是 %s 这页的最后一位编者", "%s 看上去是 %s 這頁的最後一位編者"),
rss: window.wgULS("RSS", "RSS"),
// diff previews
"Diff truncated for performance reasons": window.wgULS("出于性能考虑,差异已被截断", "出於效能考慮,差異已被截斷"),
"Old revision": window.wgULS("旧版本", "舊版本"),
"New revision": window.wgULS("新版本", "新版本"),
"Something went wrong :-(": window.wgULS("出问题了 :-(", "出問題了 :-("),
"Empty revision, maybe non-existent": window.wgULS("空的修订,可能并不存在", "空的修訂,可能並不存在"),
"Unknown date": window.wgULS("未知日期", "未知日期"),
// other special previews
"Empty category": window.wgULS("空的分类", "空的分類"),
"Category members (%s shown)": window.wgULS("分类成员(%s 显示)", "分類成員(%s 顯示)"),
"No image links found": window.wgULS("未找到文件链接", "未找到檔案連結"),
"File links": window.wgULS("文件链接", "檔案連結"),
"not commons": window.wgULS("维基共享中无此名称的文件。", "維基共享中無此名稱的檔案。"),
"commons only": window.wgULS("此文件来自维基共享。", "此檔案來自維基共享。"),
"No image found": window.wgULS("找不到文件", "找不到檔案"),
"commons dupe": window.wgULS("维基共享中存在此文件的副本。", "維基共享中存在此檔案的副本。"),
"commons conflict": window.wgULS("维基共享中存在此文件名称不同的副本。", "維基共享中存在此檔名稱不同的副本。"),
// user-related actions and info
user: window.wgULS("用户", "使用者"),
// /// user page, talk, email, space
"user page": window.wgULS("用户页", "使用者頁"),
"user talk": window.wgULS("用户讨论", "使用者對話"),
"edit user talk": window.wgULS("编辑用户讨论", "編輯使用者對話"),
"leave comment": window.wgULS("留言", "留言"),
email: window.wgULS("电邮", "電郵"),
"email user": window.wgULS("电邮用户", "電郵使用者"),
EmailuserHint: window.wgULS("给 %s 发送电子邮件", "給 %s 發送電子郵件"),
space: window.wgULS("子页面", "子頁面"),
// short form for userSpace link
PrefixindexHint: window.wgULS("显示 %s 的用户页子页面", "顯示 %s 的使用者頁子頁面"),
count: window.wgULS("统计", "統計"),
// /// contributions, tree, log
"edit counter": window.wgULS("编辑次数", "編輯次數"),
katelinkHint: window.wgULS("%s 的编辑次数", "%s 的編輯次數"),
contribs: window.wgULS("贡献", "貢獻"),
contributions: window.wgULS("贡献", "貢獻"),
deletedContribs: window.wgULS("已删除的贡献", "已刪除的貢獻"),
ContributionsHint: window.wgULS("%s 的用户贡献", "%s 的使用者貢獻"),
tree: window.wgULS("树", "樹"),
contribsTreeHint: window.wgULS("根据名字空间查看 %s 的贡献", "根據命名空間檢視 %s 的貢獻"),
log: window.wgULS("日志", "日誌"),
"user log": window.wgULS("用户日志", "使用者日誌"),
userLogHint: window.wgULS("显示 %s 的用户日志", "顯示 %s 的使用者日誌"),
unblockShort: window.wgULS("解除", "解除"),
block: window.wgULS("封禁", "封鎖"),
"block user": window.wgULS("封禁用户", "封鎖使用者"),
IpblocklistHint: window.wgULS("解封 %s", "解封 %s"),
BlockipHint: window.wgULS("封禁 %s", "封鎖 %s"),
"block log": window.wgULS("封禁日志", "封鎖日誌"),
blockLogHint: window.wgULS("显示 %s 的封禁日志", "顯示 %s 的封鎖日誌"),
protectLogHint: window.wgULS("显示 %s 的保护日志", "顯示 %s 的保護日誌"),
pageLogHint: window.wgULS("显示 %s 的日志", "顯示 %s 的日誌"),
deleteLogHint: window.wgULS("显示 %s 的删除日志", "顯示 %s 的刪除日誌"),
"Invalid %s %s": window.wgULS("选项 %s 不可用:%s", "選項 %s 不可用:%s"),
m: "小",
// Autoediting
"Enter a non-empty edit summary or press cancel to abort": window.wgULS("输入编辑摘要,或按取消中止操作", "輸入編輯摘要,或按取消中止操作"),
"Failed to get revision information, please edit manually.\n\n": window.wgULS("获取修订版本信息失败,请手动修改。\n\n", "獲取修訂版本資訊失敗,請手動修改。\n\n"),
"The %s button has been automatically clicked. Please wait for the next page to load.": window.wgULS("按钮 %s 已被自动点击,请等待下一个页面加载。", "按鈕 %s 已被自動點擊,請等待下一個頁面載入。"),
"Could not find button %s. Please check the settings in your javascript file.": window.wgULS("找不到按钮 %s,请检查您 JavaScript 文件中的设置。", "找不到按鈕 %s,請檢查您 JavaScript 檔案中的設定。"),
// Popups setup
"Open full-size image": window.wgULS("查看全尺寸图像", "檢視全尺寸影像"),
// 以下内容由 AnnAngela 补正
bingSearchHint: window.wgULS("在 Bing 上搜索“%s”", "在 bing 上搜尋「%s」"),
"enable previews": window.wgULS("启用预览", "啟用預覽"),
"show preview": window.wgULS("禁用预览", "禁用預覽"),
historyfeedHint: window.wgULS("该页面的近期更改 RSS feed", "該頁面的近期更改 RSS feed"),
"send thanks": window.wgULS("发送感谢", "傳送感謝"),
ThanksHint: window.wgULS("向该用户发送一封感谢消息", "向該使用者傳送一封感謝訊息"),
"mark patrolled": window.wgULS("标记为已巡查", "標記為已巡查"),
markpatrolledHint: window.wgULS("标记该编辑为已巡查", "標記該編輯為已巡查"),
"Could not marked this edit as patrolled": window.wgULS("无法标记该编辑为已巡查", "無法標記該編輯為已巡查"),
defaultpopupReviewedSummary: window.wgULS("标记从版本%s到%s间的编辑为已巡查", "標記從版本%s到%s間的編輯為已巡查"),
"Image from Commons": window.wgULS("来自维基共享的图片", "來自維基共用的圖片"),
"Description page": window.wgULS("图片描述页", "圖片描述頁"),
"Alt text:": window.wgULS("替换文本(Alt):", "替換文字(Alt):"),
revdel: window.wgULS("历史版本被隐藏", "歷史版本被隱藏"),
DeletedcontributionsHint: window.wgULS("用户%s的被删除编辑次数", "使用者%s的被刪除編輯次數"),
"No backlinks found": window.wgULS("找不到链入页面", "找不到鏈入頁面"),
" and more": window.wgULS("以及其他页面", "以及其他頁面"),
"Download preview data": window.wgULS("下载预览数据", "下載預覽資料"),
"Not a registered username": window.wgULS("非已注册的用户", "非已註冊的使用者"),
BLOCKED: window.wgULS("被封禁", "被封鎖"),
"Has blocks": window.wgULS("被部分封禁", "被部分封鎖"),
" edits since: ": window.wgULS("次编辑,注册日期为", "次編輯,註冊日期為"),
"last edit on ": window.wgULS("最后一次编辑于", "最後一次編輯於"),
EmailUserHint: window.wgULS("给 %s 发送电子邮件", "給 %s 發送電子郵件"),
RANGEBLOCKED: window.wgULS("IP段被封禁", "IP段被封鎖"),
"IP user": window.wgULS("IP用户", "IP使用者"),
"♀": "♀",
"♂": "♂",
HIDDEN: window.wgULS("全域隐藏", "全域隱藏"),
LOCKED: window.wgULS("全域锁定", "全域鎖定"),
"Invalid user": window.wgULS("非法用户名", "非法使用者名稱"),
diff: window.wgULS("差异", "差異"),
" to ": "至",
autoedit_version: "np20140416",
PrefixIndexHint: window.wgULS("显示用户%s的子页面", "顯示使用者%s的子頁面"),
nullEditSummary: window.wgULS("进行一次零编辑", "進行一次零編輯"),
// 用户组名称从系统消息获取
"group-no-autoconfirmed": window.wgULS("非自动确认用户", "非自動確認使用者"),
separator: "、",
comma: ","
};
//! src/Navigation_popups/modules/core.js
var popups = () => {
const pg = {
api: {},
re: {},
ns: {},
string: {},
wiki: {},
user: {},
misc: {},
option: {},
optionDefault: {},
flag: {},
cache: {},
structures: {},
timer: {},
counter: {},
current: {},
fn: {},
endoflist: null
};
if (window.pg && !(window.pg instanceof HTMLElement)) {
return;
}
window.pg = pg;
const setupTooltips = (container, remove, force, popData) => {
log("setupTooltips, container=".concat(container, ", remove=").concat(remove));
if (!container) {
if (getValueOf("popupOnEditSelection") && document && document.editform && document.editform.wpTextbox1) {
document.editform.wpTextbox1.onmouseup = doSelectionPopup;
}
container = defaultPopupsContainer();
}
if (!remove && !force && container.ranSetupTooltipsAlready) {
return;
}
container.ranSetupTooltipsAlready = !remove;
const anchors = container.querySelectorAll("a");
setupTooltipsLoop(anchors, 0, 250, 100, remove, popData);
};
const defaultPopupsContainer = () => {
if (getValueOf("popupOnlyArticleLinks")) {
return document.querySelector(".skin-vector-2022 .vector-body") || document.querySelector("#mw_content") || document.querySelector("#content") || document.querySelector("#article") || document;
}
return document;
};
const setupTooltipsLoop = function setupTooltipsLoop2(anchors, begin, howmany, sleep, remove, popData, ...args) {
log(simplePrintf("setupTooltipsLoop(%s,%s,%s,%s,%s)", [anchors, begin, howmany, sleep, remove, popData, ...args]));
const finish = begin + howmany;
const loopend = Math.min(finish, anchors.length);
let j = loopend - begin;
log("setupTooltips: anchors.length=".concat(anchors.length, ", begin=").concat(begin, ", howmany=").concat(howmany, ", loopend=").concat(loopend, ", remove=").concat(remove));
const doTooltip = remove ? removeTooltip : addTooltip;
if (j > 0) {
do {
const a = anchors[loopend - j];
if (a === void 0 || !a || !a.href) {
log("got null anchor at index ".concat(loopend) - j);
continue;
}
doTooltip(a, popData);
} while (--j);
}
if (finish < anchors.length) {
setTimeout(() => {
setupTooltipsLoop2(anchors, finish, howmany, sleep, remove, popData);
}, sleep);
} else {
if (!remove && !getValueOf("popupTocLinks")) {
rmTocTooltips();
}
pg.flag.finishedLoading = true;
}
};
const rmTocTooltips = () => {
const toc = document.querySelector("#toc");
if (toc) {
const tocLinks = toc.querySelectorAll("a");
const tocLen = tocLinks.length;
for (let j = 0; j < tocLen; ++j) {
removeTooltip(tocLinks[j], true);
}
}
};
const addTooltip = (a, popData) => {
if (!isPopupLink(a)) {
return;
}
a.onmouseover = mouseOverWikiLink;
a.onmouseout = mouseOutWikiLink;
a.onmousedown = killPopup;
a.hasPopup = true;
a.popData = popData;
};
const removeTooltip = (a) => {
if (!a.hasPopup) {
return;
}
a.onmouseover = null;
a.onmouseout = null;
if (a.originalTitle) {
a.title = a.originalTitle;
}
a.hasPopup = false;
};
const removeTitle = (a) => {
a.originalTitle || (a.originalTitle = a.title);
a.title = "";
};
const restoreTitle = (a) => {
if (a.title || !a.originalTitle) {
return;
}
a.title = a.originalTitle;
};
const registerHooks = (np) => {
const popupMaxWidth = getValueOf("popupMaxWidth");
if (typeof popupMaxWidth === "number") {
const setMaxWidth = () => {
np.mainDiv.style.maxWidth = "".concat(popupMaxWidth, "px");
np.maxWidth = popupMaxWidth;
};
np.addHook(setMaxWidth, "unhide", "before");
}
np.addHook(addPopupShortcuts, "unhide", "after");
np.addHook(rmPopupShortcuts, "hide", "before");
};
const removeModifierKeyListener = (a) => {
document.removeEventListener("keydown", a.modifierKeyListener, false);
document.removeEventListener("keyup", a.modifierKeyListener, false);
};
const mouseOverWikiLink = function mouseOverWikiLink3(evt) {
if (!evt && window.event) {
evt = window.event;
}
if (getValueOf("popupModifier")) {
const action = getValueOf("popupModifierAction");
const key = action === "disable" ? "keyup" : "keydown";
const self = this;
self.modifierKeyListener = (evt2) => {
mouseOverWikiLink2(self, evt2);
};
document.addEventListener(key, self.modifierKeyListener, false);
}
return mouseOverWikiLink2(this, evt);
};
const footnoteTarget = (a) => {
const aTitle = Title.fromAnchor(a);
const anch = aTitle.anchor;
if (!/^(cite_note-|_note-|endnote)/.test(anch)) {
return false;
}
const lTitle = Title.fromURL(location.href);
if (lTitle.toString(true) !== aTitle.toString(true)) {
return false;
}
let el = document.querySelector("#".concat(anch));
while (el && typeof el.nodeName === "string") {
const nt = el.nodeName.toLowerCase();
if (nt === "li") {
return el;
} else if (nt === "body") {
return false;
} else if (el.parentNode) {
el = el.parentNode;
} else {
return false;
}
}
return false;
};
const footnotePreview = (x, navpop) => {
setPopupHTML("<hr>".concat(x.innerHTML), "popupPreview", navpop.idNumber);
};
const modifierPressed = (evt) => {
const mod = getValueOf("popupModifier");
if (!mod) {
return false;
}
if (!evt && window.event) {
evt = window.event;
}
return evt && mod && evt["".concat(mod.toLowerCase(), "Key")];
};
const isCorrectModifier = (_a, evt) => {
if (!getValueOf("popupModifier")) {
return true;
}
const action = getValueOf("popupModifierAction");
return action === "enable" && modifierPressed(evt) || action === "disable" && !modifierPressed(evt);
};
const mouseOverWikiLink2 = (a, evt) => {
if (!isCorrectModifier(a, evt)) {
return;
}
if (getValueOf("removeTitles")) {
removeTitle(a);
}
if (a === pg.current.link && a.navpopup && a.navpopup.isVisible()) {
return;
}
pg.current.link = a;
if (getValueOf("simplePopups") && !pg.option.popupStructure) {
setDefault("popupStructure", "original");
}
const article = new Title().fromAnchor(a);
pg.current.article = article;
if (!a.navpopup) {
a.navpopup = newNavpopup(a, article);
pg.current.linksHash[a.href] = a.navpopup;
pg.current.links.push(a);
}
if (a.navpopup.pending === null || a.navpopup.pending !== 0) {
simplePopupContent(a, article);
}
a.navpopup.showSoonIfStable(a.navpopup.delay);
clearInterval(pg.timer.checkPopupPosition);
pg.timer.checkPopupPosition = setInterval(checkPopupPosition, 600);
if (getValueOf("simplePopups") && getValueOf("popupPreviewButton") && !a.simpleNoMore) {
const d = document.createElement("div");
d.className = "popupPreviewButtonDiv";
const s = document.createElement("span");
d.append(s);
s.className = "popupPreviewButton";
s["on".concat(getValueOf("popupPreviewButtonEvent"))] = () => {
a.simpleNoMore = true;
d.style.display = "none";
nonsimplePopupContent(a, article);
};
s.innerHTML = popupString("show preview");
setPopupHTML(d, "popupPreview", a.navpopup.idNumber);
}
if (a.navpopup.pending !== 0) {
nonsimplePopupContent(a, article);
}
};
const simplePopupContent = (a, article) => {
a.navpopup.hasPopupMenu = false;
a.navpopup.setInnerHTML(popupHTML(a));
fillEmptySpans({
navpopup: a.navpopup
});
if (getValueOf("popupDraggable")) {
let dragHandle = getValueOf("popupDragHandle") || null;
if (dragHandle && dragHandle !== "all") {
dragHandle += a.navpopup.idNumber;
}
setTimeout(() => {
a.navpopup.makeDraggable(dragHandle);
}, 150);
}
if (getValueOf("popupRedlinkRemoval") && a.className === "new") {
setPopupHTML("<br>".concat(popupRedlinkHTML(article)), "popupRedlink", a.navpopup.idNumber);
}
};
const debugData = (navpopup) => {
if (getValueOf("popupDebugging") && navpopup.idNumber) {
setPopupHTML("idNumber=".concat(navpopup.idNumber, ", pending=").concat(navpopup.pending), "popupError", navpopup.idNumber);
}
};
const newNavpopup = (a, article) => {
const navpopup = new Navpopup();
navpopup.fuzz = 5;
navpopup.delay = getValueOf("popupDelay") * 1e3;
navpopup.idNumber = ++pg.idNumber;
navpopup.parentAnchor = a;
navpopup.parentPopup = a.popData && a.popData.owner;
navpopup.article = article;
registerHooks(navpopup);
return navpopup;
};
const shouldShowNonSimple = (a) => {
return !getValueOf("simplePopups") || a.simpleNoMore;
};
const shouldShow = (a, option) => {
if (shouldShowNonSimple(a)) {
return getValueOf(option);
}
return window[option] !== void 0 && window[option];
};
const nonsimplePopupContent = (a, article) => {
let diff2;
let history;
const params = parseParams(a.href);
const oldid = params.oldid === void 0 ? null : params.oldid;
if (shouldShow(a, "popupPreviewDiffs")) {
({
diff: diff2
} = params);
}
if (shouldShow(a, "popupPreviewHistory")) {
history = params.action === "history";
}
a.navpopup.pending = 0;
const referenceElement = footnoteTarget(a);
if (referenceElement) {
footnotePreview(referenceElement, a.navpopup);
} else if (diff2 || diff2 === 0) {
loadDiff(article, oldid, diff2, a.navpopup);
} else if (history) {
loadAPIPreview("history", article, a.navpopup);
} else if (shouldShowNonSimple(a) && pg.re.contribs.test(a.href)) {
loadAPIPreview("contribs", article, a.navpopup);
} else if (shouldShowNonSimple(a) && pg.re.backlinks.test(a.href)) {
loadAPIPreview("backlinks", article, a.navpopup);
} else if (
// FIXME should be able to get all preview combinations with options
article.namespaceId() === pg.nsImageId && (shouldShow(a, "imagePopupsForImages") || !anchorContainsImage(a))
) {
loadAPIPreview("imagepagepreview", article, a.navpopup);
loadImage(article, a.navpopup);
} else {
if (article.namespaceId() === pg.nsCategoryId && shouldShow(a, "popupCategoryMembers")) {
loadAPIPreview("category", article, a.navpopup);
} else if ((article.namespaceId() === pg.nsUserId || article.namespaceId() === pg.nsUsertalkId) && shouldShow(a, "popupUserInfo")) {
loadAPIPreview("userinfo", article, a.navpopup);
}
if (shouldShowNonSimple(a)) {
startArticlePreview(article, oldid, a.navpopup);
}
}
};
const pendingNavpopTask = (navpop) => {
if (navpop && navpop.pending === null) {
navpop.pending = 0;
}
++navpop.pending;
debugData(navpop);
};
const completedNavpopTask = (navpop) => {
if (navpop && navpop.pending) {
--navpop.pending;
}
debugData(navpop);
};
const startArticlePreview = (article, oldid, navpop) => {
navpop.redir = 0;
loadPreview(article, oldid, navpop);
};
const loadPreview = (article, oldid, navpop) => {
if (!navpop.redir) {
navpop.originalArticle = article;
}
article.oldid = oldid;
loadAPIPreview("revision", article, navpop);
};
const loadPreviewFromRedir = (redirMatch, navpop) => {
const target = new Title().fromWikiText(redirMatch[2]);
if (navpop.article.anchor) {
target.anchor = navpop.article.anchor;
}
navpop.redir++;
navpop.redirTarget = target;
const warnRedir = redirLink(target, navpop.article);
setPopupHTML(warnRedir, "popupWarnRedir", navpop.idNumber);
navpop.article = target;
fillEmptySpans({
redir: true,
redirTarget: target,
navpopup: navpop
});
return loadPreview(target, null, navpop);
};
const insertPreview = (download) => {
if (!download.owner) {
return;
}
const redirMatch = pg.re.redirect.exec(download.data);
if (download.owner.redir === 0 && redirMatch) {
loadPreviewFromRedir(redirMatch, download.owner);
return;
}
if (download.owner.visible || !getValueOf("popupLazyPreviews")) {
insertPreviewNow(download);
} else {
const id = download.owner.redir ? "PREVIEW_REDIR_HOOK" : "PREVIEW_HOOK";
download.owner.addHook(() => {
insertPreviewNow(download);
return true;
}, "unhide", "after", id);
}
};
const insertPreviewNow = (download) => {
if (!download.owner) {
return;
}
const wikiText = download.data;
const navpop = download.owner;
const art = navpop.redirTarget || navpop.originalArticle;
makeFixDabs(wikiText, navpop);
if (getValueOf("popupSummaryData")) {
getPageInfo(wikiText, download);
setPopupTrailer(getPageInfo(wikiText, download), navpop.idNumber);
}
let imagePage = "";
imagePage = art.namespaceId() === pg.nsImageId ? art.toString() : getValidImageFromWikiText(wikiText);
if (imagePage) {
loadImage(Title.fromWikiText(imagePage), navpop);
}
if (getValueOf("popupPreviews")) {
insertArticlePreview(download, art, navpop);
}
};
const insertArticlePreview = (download, art, navpop) => {
if (download && typeof download.data === "string") {
if (art.namespaceId() === pg.nsTemplateId && getValueOf("popupPreviewRawTemplates")) {
const h = '<hr><span style="font-family: monospace;">'.concat(download.data.entify().split(String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n"], ["\\n"])))).join(String.raw(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["<br>\n"], ["<br>\\n"])))), "</span>");
setPopupHTML(h, "popupPreview", navpop.idNumber);
} else {
const p = prepPreviewmaker(download.data, art, navpop);
p.showPreview();
}
}
};
const prepPreviewmaker = (data, article, navpop) => {
const d = anchorize(data, article.anchorString());
const urlBase = joinPath([pg.wiki.articlebase, article.urlString()]);
const p = new Previewmaker(d, urlBase, navpop);
return p;
};
const anchorize = (d, anch) => {
if (!anch) {
return d;
}
const anchRe = new RegExp("(?:=+\\s*".concat(literalizeRegex(anch).replace(/[ _]/g, "[_ ]"), "\\s*=+|\\{\\{\\s*").concat(getValueOf("popupAnchorRegexp"), "\\s*(?:\\|[^|}]*)*?\\s*").concat(literalizeRegex(anch), "\\s*(?:\\|[^}]*)?}})"));
const match = d.match(anchRe);
if (match && match.length > 0 && match[0]) {
return d.slice(Math.max(0, d.indexOf(match[0])));
}
const lines = d.split("\n");
for (let i = 0; i < lines.length; ++i) {
lines[i] = lines[i].replace(/\[{2}([^\]|]*?\|)?(.*?)]{2}/g, "$2").replace(/'''([^'])/g, "$1").replace(/''([^'])/g, "$1");
if (anchRe.test(lines[i])) {
return d.split("\n").slice(i).join("\n").replace(/^[^=]*/, "");
}
}
return d;
};
const killPopup = function killPopup2() {
removeModifierKeyListener(this);
if (getValueOf("popupShortcutKeys")) {
rmPopupShortcuts();
}
if (!pg) {
return;
}
if (pg.current.link && pg.current.link.navpopup) {
pg.current.link.navpopup.banish();
}
pg.current.link = null;
abortAllDownloads();
if (pg.timer.checkPopupPosition) {
clearInterval(pg.timer.checkPopupPosition);
pg.timer.checkPopupPosition = null;
}
return true;
};
class Drag {
constructor() {
this.startCondition = null;
this.endHook = null;
}
/**
* Gets an event in a cross-browser manner.
*
* @param {Event} e
* @private
*/
static fixE(e) {
if (e === void 0) {
e = window.event;
}
if (e.layerX === void 0) {
e.layerX = e.offsetX;
}
if (e.layerY === void 0) {
e.layerY = e.offsetY;
}
return e;
}
/**
* Initialises the Drag instance by telling it which object you want to be draggable, and what
* you want to drag it by.
*
* @param {DOMElement} o The "handle" by which <code>oRoot</code> is dragged.
* @param {DOMElement} oRoot The object which moves when <code>o</code> is dragged, or <code>o</code> if omitted.
*/
init(o, oRoot) {
const self = this;
this.obj = o;
o.onmousedown = (e) => {
self.start(e);
};
o.dragging = false;
o.popups_draggable = true;
o.hmode = true;
o.vmode = true;
o.root = oRoot || o;
if (Number.isNaN(Number.parseInt(o.root.style.left, 10))) {
o.root.style.left = "0px";
}
if (Number.isNaN(Number.parseInt(o.root.style.top, 10))) {
o.root.style.top = "0px";
}
o.root.onthisStart = () => {
};
o.root.onthisEnd = () => {
};
o.root.onthis = () => {
};
}
/**
* Starts the drag.
*
* @private
* @param {Event} e
*/
start(e) {
const o = this.obj;
e = Drag.fixE(e);
if (this.startCondition && !this.startCondition(e)) {
return;
}
const y = Number.parseInt(o.vmode ? o.root.style.top : o.root.style.bottom, 10);
const x = Number.parseInt(o.hmode ? o.root.style.left : o.root.style.right, 10);
o.root.onthisStart(x, y);
o.lastMouseX = e.clientX;
o.lastMouseY = e.clientY;
const self = this;
o.onmousemoveDefault = document.onmousemove;
o.dragging = true;
document.onmousemove = (e2) => {
self.drag(e2);
};
document.onmouseup = (e2) => {
self.end(e2);
};
return false;
}
/**
* Does the drag.
*
* @param {Event} e
* @private
*/
drag(e) {
e = Drag.fixE(e);
const o = this.obj;
const ey = e.clientY;
const ex = e.clientX;
const y = Number.parseInt(o.vmode ? o.root.style.top : o.root.style.bottom, 10);
const x = Number.parseInt(o.hmode ? o.root.style.left : o.root.style.right, 10);
const nx = x + (ex - o.lastMouseX) * (o.hmode ? 1 : -1);
const ny = y + (ey - o.lastMouseY) * (o.vmode ? 1 : -1);
this.obj.root.style[o.hmode ? "left" : "right"] = "".concat(nx, "px");
this.obj.root.style[o.vmode ? "top" : "bottom"] = "".concat(ny, "px");
this.obj.lastMouseX = ex;
this.obj.lastMouseY = ey;
this.obj.root.onthis(nx, ny);
return false;
}
/**
* Ends the drag.
*
* @private
*/
end() {
document.onmousemove = this.obj.onmousemoveDefault;
document.onmouseup = null;
this.obj.dragging = false;
if (this.endHook) {
this.endHook(Number.parseInt(this.obj.root.style[this.obj.hmode ? "left" : "right"], 10), Number.parseInt(this.obj.root.style[this.obj.vmode ? "top" : "bottom"], 10));
}
}
}
pg.structures.original = {};
pg.structures.original.popupLayout = () => {
return ["popupError", "popupImage", "popupTopLinks", "popupTitle", "popupUserData", "popupData", "popupOtherLinks", "popupRedir", ["popupWarnRedir", "popupRedirTopLinks", "popupRedirTitle", "popupRedirData", "popupRedirOtherLinks"], "popupMiscTools", ["popupRedlink"], "popupPrePreviewSep", "popupPreview", "popupSecondPreview", "popupPreviewMore", "popupPostPreview", "popupFixDab"];
};
pg.structures.original.popupRedirSpans = () => {
return ["popupRedir", "popupWarnRedir", "popupRedirTopLinks", "popupRedirTitle", "popupRedirData", "popupRedirOtherLinks"];
};
pg.structures.original.popupTitle = (x) => {
log("defaultstructure.popupTitle");
if (!getValueOf("popupNavLinks")) {
return navlinkStringToHTML("<b><<mainlink>></b>", x.article, x.params);
}
return "";
};
pg.structures.original.popupTopLinks = (x) => {
log("defaultstructure.popupTopLinks");
if (getValueOf("popupNavLinks")) {
return navLinksHTML(x.article, x.hint, x.params);
}
return "";
};
pg.structures.original.popupImage = (x) => {
log("original.popupImage, x.article=".concat(x.article, ", x.navpop.idNumber=").concat(x.navpop.idNumber));
return imageHTML(x.article, x.navpop.idNumber);
};
pg.structures.original.popupRedirTitle = pg.structures.original.popupTitle;
pg.structures.original.popupRedirTopLinks = pg.structures.original.popupTopLinks;
const copyStructure = (oldStructure, newStructure) => {
pg.structures[newStructure] = {};
for (const prop in pg.structures[oldStructure]) {
if (!Object.hasOwn(pg.structures[oldStructure], prop)) {
continue;
}
pg.structures[newStructure][prop] = pg.structures[oldStructure][prop];
}
};
copyStructure("original", "nostalgia");
pg.structures.nostalgia.popupTopLinks = (x) => {
let str = "";
str += "<b><<mainlink|shortcut= >></b>";
str += "if(user){<br><<contribs|shortcut=c>>";
str += "if(wikimedia){*<<count|shortcut=#>>}";
str += "if(ipuser){}else{*<<email|shortcut=E>>}if(admin){*<<block|shortcut=b>>}}";
const editstr = "<<edit|shortcut=e>>";
const editOldidStr = "if(oldid){<<editOld|shortcut=e>>|<<revert|shortcut=v|rv>>|<<edit|cur>>}else{".concat(editstr, "}");
const historystr = "<<history|shortcut=h>>";
const watchstr = "<<unwatch|unwatchShort>>|<<watch|shortcut=w|watchThingy>>";
str += "<br>if(talk){".concat(editOldidStr, "|<<new|shortcut=+>>*").concat(historystr, "*").concat(watchstr, "*<b><<article|shortcut=a>></b>|<<editArticle|edit>>}else{").concat(
// not a talk page
editOldidStr,
"*"
).concat(historystr, "*").concat(watchstr, "*<b><<talk|shortcut=t>></b>|<<editTalk|edit>>|<<newTalk|shortcut=+|new>>}");
str += "<br><<whatLinksHere|shortcut=l>>*<<relatedChanges|shortcut=r>>";
str += "if(admin){<br>}else{*}<<move|shortcut=m>>";
str += "if(admin){*<<unprotect|unprotectShort>>|<<protect|shortcut=p>>*<<undelete|undeleteShort>>|<<delete|shortcut=d>>}";
return navlinkStringToHTML(str, x.article, x.params);
};
pg.structures.nostalgia.popupRedirTopLinks = pg.structures.nostalgia.popupTopLinks;
copyStructure("original", "fancy");
pg.structures.fancy.popupTitle = (x) => {
return navlinkStringToHTML("<font size=+0><<mainlink>></font>", x.article, x.params);
};
pg.structures.fancy.popupTopLinks = (x) => {
const hist = "<<history|shortcut=h|hist>>|<<lastEdit|shortcut=/|last>>|<<editors|shortcut=E|eds>>";
const watch = "<<unwatch|unwatchShort>>|<<watch|shortcut=w|watchThingy>>";
const move = "<<move|shortcut=m|move>>";
return navlinkStringToHTML("if(talk){<<edit|shortcut=e>>|<<new|shortcut=+|+>>*".concat(hist, "*<<article|shortcut=a>>|<<editArticle|edit>>*").concat(watch, "*").concat(move, "}else{<<edit|shortcut=e>>*").concat(hist, "*<<talk|shortcut=t|>>|<<editTalk|edit>>|<<newTalk|shortcut=+|new>>*").concat(watch, "*").concat(move, "}<br>"), x.article, x.params);
};
pg.structures.fancy.popupOtherLinks = (x) => {
const admin = "<<unprotect|unprotectShort>>|<<protect|shortcut=p>>*<<undelete|undeleteShort>>|<<delete|shortcut=d|del>>";
let user = "<<contribs|shortcut=c>>if(wikimedia){|<<count|shortcut=#|#>>}";
user += "if(ipuser){|<<arin>>}else{*<<email|shortcut=E|".concat(popupString("email"), ">>}if(admin){*<<block|shortcut=b>>}");
const normal = "<<whatLinksHere|shortcut=l|links here>>*<<relatedChanges|shortcut=r|related>>";
return navlinkStringToHTML("<br>if(user){".concat(user, "*}if(admin){").concat(admin, "if(user){<br>}else{*}}").concat(normal), x.article, x.params);
};
pg.structures.fancy.popupRedirTitle = pg.structures.fancy.popupTitle;
pg.structures.fancy.popupRedirTopLinks = pg.structures.fancy.popupTopLinks;
pg.structures.fancy.popupRedirOtherLinks = pg.structures.fancy.popupOtherLinks;
copyStructure("fancy", "fancy2");
pg.structures.fancy2.popupTopLinks = // hack out the <br> at the end and put one at the beginning
(x) => {
return "<br>".concat(pg.structures.fancy.popupTopLinks(x).replace(/<br>$/i, ""));
};
pg.structures.fancy2.popupLayout = () => {
return ["popupError", "popupImage", "popupTitle", "popupUserData", "popupData", "popupTopLinks", "popupOtherLinks", "popupRedir", ["popupWarnRedir", "popupRedirTopLinks", "popupRedirTitle", "popupRedirData", "popupRedirOtherLinks"], "popupMiscTools", ["popupRedlink"], "popupPrePreviewSep", "popupPreview", "popupSecondPreview", "popupPreviewMore", "popupPostPreview", "popupFixDab"];
};
copyStructure("original", "menus");
pg.structures.menus.popupLayout = () => {
return ["popupError", "popupImage", "popupTopLinks", "popupTitle", "popupOtherLinks", "popupRedir", ["popupWarnRedir", "popupRedirTopLinks", "popupRedirTitle", "popupRedirData", "popupRedirOtherLinks"], "popupUserData", "popupData", "popupMiscTools", ["popupRedlink"], "popupPrePreviewSep", "popupPreview", "popupSecondPreview", "popupPreviewMore", "popupPostPreview", "popupFixDab"];
};
pg.structures.menus.popupTopLinks = (x, shorter) => {
const s = [];
const dropdiv = '<div class="popup_drop">';
const enddiv = "</div>";
let hist = "<<history|shortcut=h>>";
if (!shorter) {
hist = "<menurow>".concat(hist, "|<<historyfeed|rss>>|<<editors|shortcut=E>></menurow>");
}
const lastedit = "<<lastEdit|shortcut=/|show last edit>>";
const thank = "if(diff){<<thank|send thanks>>}";
const jsHistory = "<<lastContrib|last set of edits>><<sinceMe|changes since mine>>";
const linkshere = "<<whatLinksHere|shortcut=l|what links here>>";
const related = "<<relatedChanges|shortcut=r|related changes>>";
const search = "<menurow><<search|shortcut=s>></menurow>";
const watch = "<menurow><<unwatch|unwatchShort>>|<<watch|shortcut=w|watchThingy>></menurow>";
const protect = "<menurow><<unprotect|unprotectShort>>|<<protect|shortcut=p>>|<<protectlog|log>></menurow>";
const del = "<menurow><<undelete|undeleteShort>>|<<delete|shortcut=d>>|<<deletelog|log>></menurow>";
const move = "<<move|shortcut=m|move page>>";
const nullPurge = "<menurow><<nullEdit|shortcut=n|null edit>>|<<purge|shortcut=P>></menurow>";
const viewOptions = "<menurow><<view|shortcut=v>>|<<render|shortcut=S>>|<<raw>></menurow>";
const editRow = "if(oldid){<menurow><<edit|shortcut=e>>|<<editOld|shortcut=e|this revision>></menurow><menurow><<revert|shortcut=v>>|<<undo>></menurow>}else{<<edit|shortcut=e>>}";
const markPatrolled = "if(rcid){<<markpatrolled|mark patrolled>>}";
const newTopic = "if(talk){<<new|shortcut=+|new topic>>}";
const protectDelete = "if(admin){".concat(protect).concat(del, "}");
if (getValueOf("popupActionsMenu")) {
s.push("<<mainlink>>*".concat(dropdiv).concat(menuTitle("actions")));
} else {
s.push("".concat(dropdiv, "<<mainlink>>"));
}
s.push("<menu>", editRow + markPatrolled + newTopic + hist + lastedit + thank);
if (!shorter) {
s.push(jsHistory);
}
s.push(move + linkshere + related);
if (!shorter) {
s.push(nullPurge + search);
}
if (!shorter) {
s.push(viewOptions);
}
s.push("<hr>".concat(watch).concat(protectDelete), "<hr>if(talk){<<article|shortcut=a|view article>><<editArticle|edit article>>}else{<<talk|shortcut=t|talk page>><<editTalk|edit talk>><<newTalk|shortcut=+|new topic>>}</menu>".concat(enddiv));
const email = "<<email|shortcut=E|email user>>";
const contribs = "if(wikimedia){<menurow>}<<contribs|shortcut=c|contributions>>if(wikimedia){</menurow>}if(admin){<menurow><<deletedContribs>></menurow>}";
s.push("if(user){*".concat(dropdiv).concat(menuTitle("user")), "<menu>", "<menurow><<userPage|shortcut=u|user page>>|<<userSpace|space>></menurow>", "<<userTalk|shortcut=t|user talk>><<editUserTalk|edit user talk>><<newUserTalk|shortcut=+|leave comment>>");
if (shorter) {
s.push("if(ipuser){}else{".concat(email, "}"));
} else {
s.push("if(ipuser){<<arin>>}else{".concat(email, "}"));
}
s.push("<hr>".concat(contribs, "<<userlog|shortcut=L|user log>>"), "if(wikimedia){<<count|shortcut=#|edit counter>>}", "if(admin){<menurow><<unblock|unblockShort>>|<<block|shortcut=b|block user>></menurow>}", "<<blocklog|shortcut=B|block log>>", "</menu>".concat(enddiv, "}"));
if (getValueOf("popupSetupMenu") && !x.navpop.hasPopupMenu) {
x.navpop.hasPopupMenu = true;
s.push("*".concat(dropdiv).concat(menuTitle("popupsMenu"), "<menu>"), "<<togglePreviews|toggle previews>>", "<<purgePopups|reset>>", "<<disablePopups|disable>>", "</menu>".concat(enddiv));
}
return navlinkStringToHTML(s.join(""), x.article, x.params);
};
const menuTitle = (s) => {
return '<a href="#" noPopup=1>'.concat(popupString(s), "</a>");
};
pg.structures.menus.popupRedirTitle = pg.structures.menus.popupTitle;
pg.structures.menus.popupRedirTopLinks = pg.structures.menus.popupTopLinks;
copyStructure("menus", "shortmenus");
pg.structures.shortmenus.popupTopLinks = (x) => {
return pg.structures.menus.popupTopLinks(x, true);
};
pg.structures.shortmenus.popupRedirTopLinks = pg.structures.shortmenus.popupTopLinks;
pg.structures.lite = {};
pg.structures.lite.popupLayout = () => {
return ["popupTitle", "popupPreview"];
};
pg.structures.lite.popupTitle = (x) => {
log("".concat(x.article, ": structures.lite.popupTitle"));
return '<div><span class="popup_mainlink"><b>'.concat(x.article.toString(), "</b></span></div>");
};
const substitute = (data, cmdBody) => {
const fromRe = new RegExp(cmdBody.from, cmdBody.flags);
return data.replace(fromRe, cmdBody.to);
};
const execCmds = (data, cmdList) => {
var _iterator = _createForOfIteratorHelper(cmdList), _step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
const element = _step.value;
data = element.action(data, element);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return data;
};
const parseCmd = function parseCmd2(str) {
if (str.length === 0) {
return [];
}
let p = false;
switch (str.charAt(0)) {
case "s":
p = parseSubstitute(str);
break;
default:
return false;
}
if (p) {
return [p, parseCmd2(p.remainder)];
}
return false;
};
const unEscape = (str, sep) => {
return str.split("\\\\").join("\\").split("\\".concat(sep)).join(sep).split(String.raw(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n"], ["\\n"])))).join("\n");
};
const parseSubstitute = (str) => {
let from;
let to;
let flags;
let tmp;
if (str.length < 4) {
return false;
}
const sep = str.charAt(1);
str = str.slice(2);
tmp = skipOver(str, sep);
if (tmp) {
from = tmp.segment;
str = tmp.remainder;
} else {
return false;
}
tmp = skipOver(str, sep);
if (tmp) {
to = tmp.segment;
str = tmp.remainder;
} else {
return false;
}
flags = "";
if (str.length > 0) {
tmp = skipOver(str, ";") || skipToEnd(str, ";");
if (tmp) {
flags = tmp.segment;
str = tmp.remainder;
}
}
return {
action: substitute,
from,
to,
flags,
remainder: str
};
};
const skipOver = (str, sep) => {
const endSegment = findNext(str, sep);
if (endSegment < 0) {
return false;
}
const segment = unEscape(str.slice(0, Math.max(0, endSegment)), sep);
return {
segment,
remainder: str.slice(Math.max(0, endSegment + 1))
};
};
const skipToEnd = (str, _sep) => {
return {
segment: str,
remainder: ""
};
};
const findNext = (str, ch) => {
for (let i = 0; i < str.length; ++i) {
if (str.charAt(i) === "\\") {
i += 2;
}
if (str.charAt(i) === ch) {
return i;
}
}
return -1;
};
const setCheckbox = (param, box) => {
const val = mw.util.getParamValue(param);
if (val) {
switch (val) {
case "1":
case "yes":
case "true":
box.checked = true;
break;
case "0":
case "no":
case "false":
box.checked = false;
}
}
};
const autoEdit = function autoEdit4() {
setupPopups(() => {
if (mw.util.getParamValue("autoimpl") !== popupString("autoedit_version")) {
return false;
}
if (mw.util.getParamValue("autowatchlist") && mw.util.getParamValue("actoken") === autoClickToken()) {
pg.fn.modifyWatchlist(mw.util.getParamValue("title"), mw.util.getParamValue("action"));
}
if (!document.editform) {
return false;
}
if (autoEdit4.alreadyRan) {
return false;
}
autoEdit4.alreadyRan = true;
const cmdString = mw.util.getParamValue("autoedit");
if (cmdString) {
try {
const editbox = document.editform.wpTextbox1;
const cmdList = parseCmd(cmdString);
const input = editbox.value;
const output = execCmds(input, cmdList);
editbox.value = output;
} catch {
return;
}
}
setCheckbox("autominor", document.editform.wpMinoredit);
setCheckbox("autowatch", document.editform.wpWatchthis);
const rvid = mw.util.getParamValue("autorv");
if (rvid) {
const url = "".concat(pg.wiki.apiwikibase, "?action=query&format=json&formatversion=2&prop=revisions&revids=").concat(rvid);
startDownload(url, null, autoEdit2);
} else {
autoEdit2();
}
});
};
const autoEdit2 = (d) => {
let summary = mw.util.getParamValue("autosummary");
let summaryprompt = mw.util.getParamValue("autosummaryprompt");
let summarynotice = "";
if (d && d.data && mw.util.getParamValue("autorv")) {
const s = getRvSummary(summary, d.data);
if (s === false) {
summaryprompt = true;
summarynotice = popupString("Failed to get revision information, please edit manually.\n\n");
summary = simplePrintf(summary, [mw.util.getParamValue("autorv"), "(unknown)", "(unknown)"]);
} else {
summary = s;
}
}
if (summaryprompt) {
const txt = summarynotice + popupString("Enter a non-empty edit summary or press cancel to abort");
const response = prompt(txt, summary);
if (response) {
summary = response;
} else {
return;
}
}
if (summary) {
document.editform.wpSummary.value = summary;
}
setTimeout(autoEdit3, 100);
};
const autoClickToken = () => {
return mw.user.sessionId();
};
const autoEdit3 = () => {
if (mw.util.getParamValue("actoken") !== autoClickToken()) {
return;
}
const btn = mw.util.getParamValue("autoclick");
if (btn) {
if (document.editform && document.editform[btn]) {
const button = document.editform[btn];
const msg = tprintf("The %s button has been automatically clicked. Please wait for the next page to load.", [button.value]);
bannerMessage(msg);
document.title = "(".concat(document.title, ")");
button.click();
} else {
void mw.notify(tprintf("Could not find button %s. Please check the settings in your javascript file.", [btn]), {
tag: "popups",
type: "error"
});
}
}
};
const bannerMessage = (s) => {
const headings = document.querySelectorAll("h1");
if (headings) {
const div = document.createElement("div");
div.innerHTML = "<font size=+1><b>".concat(pg.escapeQuotesHTML(s), "</b></font>");
headings[0].parentNode.insertBefore(div, headings[0]);
}
};
const getRvSummary = (template, json) => {
try {
const o = getJsObj(json);
const [edit] = anyChild(o.query.pages).revisions;
const timestamp = edit.timestamp.split(/[A-Z]/g).join(" ").replace(/^ *| *$/g, "");
return simplePrintf(template, [edit.revid, timestamp, edit.userhidden ? "(hidden)" : edit.user]);
} catch {
return false;
}
};
class Downloader {
constructor(url) {
if (typeof XMLHttpRequest !== "undefined") {
this.http = new XMLHttpRequest();
}
this.url = url;
this.id = null;
this.lastModified = null;
this.callbackFunction = null;
this.onFailure = null;
this.aborted = false;
this.method = "GET";
this.async = true;
}
/**
* Submits the http request.
*
* @param {*} x
*/
send(x) {
if (!this.http) {
return null;
}
return this.http.send(x);
}
/* Aborts the download, setting the <code>aborted</code> field to true. */
abort() {
if (!this.http) {
return null;
}
this.aborted = true;
return this.http.abort();
}
/** Returns the downloaded data. */
getData() {
if (!this.http) {
return null;
}
return this.http.responseText;
}
/** Prepares the download. */
setTarget() {
if (!this.http) {
return null;
}
this.http.open(this.method, this.url, this.async);
this.http.setRequestHeader("Api-User-Agent", pg.api.userAgent);
}
/** Gets the state of the download. */
getReadyState() {
if (!this.http) {
return null;
}
return this.http.readyState;
}
/**
* Starts the download.
* Note that setTarget {@source Downloader#setTarget} must be run first
*/
start() {
if (!this.http) {
return;
}
const self = this;
pg.misc.downloadsInProgress[this.id] = self;
this.http.send(null);
}
/**
* Gets the 'Last-Modified' date from the download headers.
* Should be run after the download completes.
* Returns <code>null</code> on failure.
*
* @return {Date}
*/
getLastModifiedDate() {
if (!this.http) {
return null;
}
let lastmod;
try {
lastmod = this.http.getResponseHeader("Last-Modified");
} catch {
}
if (lastmod) {
return new Date(lastmod);
}
return null;
}
/**
* Sets the callback function.
*
* @param {Function} f callback function, called as <code>f(this)</code> on success
*/
setCallback(f) {
if (!this.http) {
return;
}
this.http.onreadystatechange = f;
}
getStatus() {
if (!this.http) {
return null;
}
return this.http.status;
}
}
new Downloader();
pg.misc.downloadsInProgress = {};
const newDownload = function newDownload2(url, id, callback, onfailure) {
const d = new Downloader(url);
if (!d.http) {
return "ohdear";
}
d.id = id;
d.setTarget();
onfailure || (onfailure = 2);
const f = function() {
if (d.getReadyState() === 4) {
delete pg.misc.downloadsInProgress[this.id];
try {
if (d.getStatus() === 200) {
d.data = d.getData();
d.lastModified = d.getLastModifiedDate();
callback(d);
} else if (typeof onfailure === "number") {
if (onfailure > 0) {
newDownload2(url, id, callback, onfailure - 1);
}
} else if (typeof onfailure === "function") {
onfailure(d, url, id, callback);
}
} catch {
}
}
};
d.setCallback(f);
return d;
};
const fakeDownload = (url, id, callback, data, lastModified, owner) => {
const d = newDownload(url, callback);
d.owner = owner;
d.id = id;
d.data = data;
d.lastModified = lastModified;
return callback(d);
};
const startDownload = (url, id, callback) => {
const d = newDownload(url, id, callback);
if (typeof d === "string") {
return d;
}
d.start();
return d;
};
const abortAllDownloads = () => {
for (const x in pg.misc.downloadsInProgress) {
if (!Object.hasOwn(pg.misc.downloadsInProgress, x)) {
continue;
}
try {
pg.misc.downloadsInProgress[x].aborted = true;
pg.misc.downloadsInProgress[x].abort();
delete pg.misc.downloadsInProgress[x];
} catch {
}
}
};
const Insta = {};
const setupLivePreview = () => {
let _b;
Insta.conf = {
baseUrl: "",
user: {},
wiki: {
lang: pg.wiki.lang,
interwiki: pg.wiki.interwiki,
default_thumb_width: 180
},
paths: {
articles: "".concat(pg.wiki.articlePath, "/"),
// Only used for Insta previews with images. (not in popups)
math: "/math/",
images: "https://tu.zhongwen.wiki/images/qiuwenbaike/zh/",
images_fallback: "//wm.zhongwen.wiki/commons/"
},
locale: {
user: mw.config.get("wgFormattedNamespaces")[pg.nsUserId],
image: mw.config.get("wgFormattedNamespaces")[pg.nsImageId],
category: mw.config.get("wgFormattedNamespaces")[pg.nsCategoryId],
// shouldn't be used in popup previews, i think
months: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
}
};
(_b = Insta.conf.user).name || (_b.name = "Qiuwen Baike contributors");
Insta.conf.user.signature = "[[".concat(Insta.conf.locale.user, ":").concat(Insta.conf.user.name, "|").concat(Insta.conf.user.name, "]]");
Insta.BLOCK_IMAGE = new RegExp("^\\[\\[(?:File|Image|".concat(Insta.conf.locale.image, "):.*?\\|.*?(?:frame|thumbnail|thumb|none|right|left|center)"), "i");
};
Insta.dump = function(from, to) {
if (typeof from === "string") {
from = document.querySelector("#".concat(from));
}
if (typeof to === "string") {
to = document.querySelector("#".concat(to));
}
to.innerHTML = this.convert(from.value);
};
Insta.convert = (wiki) => {
const ll = typeof wiki === "string" ? wiki.replace(/\r/g, "").split(/\n/) : wiki;
let o = "";
let p = 0;
let r;
const remain = () => {
return ll.length;
};
const sh = () => {
return ll.shift();
};
const ps = (s) => {
o += s;
};
const f = function f2(...args) {
let i = 1;
const a = args;
let [f3] = a;
let o2 = "";
let c;
let p2;
for (; i < a.length; i++) {
if ((p2 = f3.indexOf("?")) + 1) {
c = f3.charAt(p2 + 1) === "?" ? 1 : 0;
i -= c;
o2 += f3.slice(0, Math.max(0, p2)) + (c ? "?" : a[i]);
f3 = f3.slice(p2 + 1 + c);
} else {
break;
}
}
return o2 + f3;
};
const html_entities = (s) => {
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
};
const htmlescape_text = (s) => {
return s.replace(/</g, "<").replace(/>/g, ">").replace(/:/g, ":").replace(/\[/g, "[").replace(/]/g, "]");
};
const htmlescape_attr = (s) => {
return htmlescape_text(s).replace(/'/g, "'").replace(/"/g, """);
};
const str_imatch = (a, b) => {
let i;
let l;
for (i = 0, l = Math.min(a.length, b.length); i < l; i++) {
if (a.charAt(i) !== b.charAt(i)) {
break;
}
}
return i;
};
const compareLineStringOrReg = (c) => {
return typeof c === "string" ? ll[0] && ll[0].slice(0, c.length) === c : r = ll[0] && ll[0].match(c);
};
const compareLineString = (c) => {
return ll[0] === c;
};
const charAtPoint = (p2) => {
return ll[0].charAt(p2);
};
const endl = (s) => {
ps(s);
sh();
};
const parse_list = () => {
let prev = "";
while (remain() && compareLineStringOrReg(/^([#*:;]+)(.*)$/)) {
const l_match = r;
sh();
const ipos = str_imatch(prev, l_match[1]);
for (let prevPos = prev.length - 1; prevPos >= ipos; prevPos--) {
const pi = prev.charAt(prevPos);
if (pi === "*") {
ps("</ul>");
} else if (pi === "#") {
ps("</ol>");
} else if (["", "*", "#"].indexOf(l_match[1].charAt(prevPos))) {
ps("</dl>");
}
}
for (let matchPos = ipos; matchPos < l_match[1].length; matchPos++) {
const li = l_match[1].charAt(matchPos);
if (li === "*") {
ps("<ul>");
} else if (li === "#") {
ps("<ol>");
} else if (["", "*", "#"].indexOf(prev.charAt(matchPos))) {
ps("<dl>");
}
}
switch (l_match[1].at(-1)) {
case "*":
case "#":
ps("<li>".concat(parse_inline_nowiki(l_match[2])));
break;
case ";": {
ps("<dt>");
const dt_match = l_match[2].match(/(.*?)(:.*?)$/);
if (dt_match) {
ps(parse_inline_nowiki(dt_match[1]));
ll.unshift(dt_match[2]);
} else {
ps(parse_inline_nowiki(l_match[2]));
}
break;
}
case ":":
ps("<dd>".concat(parse_inline_nowiki(l_match[2])));
}
[, prev] = l_match;
}
for (let i = prev.length - 1; i >= 0; i--) {
ps(f("</?>", prev.charAt(i) === "*" ? "ul" : prev.charAt(i) === "#" ? "ol" : "dl"));
}
};
const parse_table = () => {
endl(f("<table>", compareLineStringOrReg(/^{\|( .*)$/) ? r[1] : ""));
for (; remain(); ) {
if (compareLineStringOrReg("|")) {
switch (charAtPoint(1)) {
case "}":
endl("</table>");
return;
case "-":
endl(f("<tr>", compareLineStringOrReg(/\|-*(.*)/)[1]));
break;
default:
parse_table_data();
}
} else if (compareLineStringOrReg("!")) {
parse_table_data();
} else {
sh();
}
}
};
const parse_table_data = () => {
let td_line;
let match_i;
const td_match = sh().match(/^(\|\+|\||!)((?:([^[|]*?)\|(?!\|))?(.*))$/);
if (td_match[1] === "|+") {
ps("<caption");
} else {
ps("<t".concat(td_match[1] === "|" ? "d" : "h"));
}
if (td_match[3]) {
match_i = 4;
} else {
match_i = 2;
}
ps(">");
if (td_match[1] === "|+") {
ps(parse_inline_nowiki(td_match[match_i]));
} else {
td_line = td_match[match_i].split(td_match[1] === "|" ? "||" : /\|\||!!/);
ps(parse_inline_nowiki(td_line.shift()));
while (td_line.length > 0) {
ll.unshift(td_match[1] + td_line.pop());
}
}
let tc = 0;
const td = [];
while (remain()) {
td.push(sh());
if (compareLineStringOrReg("|")) {
if (!tc) {
break;
} else if (charAtPoint(1) === "}") {
tc--;
}
} else if (!tc && compareLineStringOrReg("!")) {
break;
} else if (compareLineStringOrReg("{|")) {
tc++;
}
}
if (td.length > 0) {
ps(Insta.convert(td));
}
};
const parse_pre = () => {
ps("<pre>");
do {
endl("".concat(parse_inline_nowiki(ll[0].slice(1)), "\n"));
} while (remain() && compareLineStringOrReg(" "));
ps("</pre>");
};
const parse_block_image = () => {
ps(parse_image(sh()));
};
const parse_image = (str) => {
let tag = str.substring(str.indexOf(":") + 1, str.length - 2);
let width;
let attr = [];
let filename;
let caption = "";
let thumb = 0;
let frame = 0;
let center = 0;
let align = "";
if (/\|/.test(tag)) {
let nesting = 0;
let last_attr;
for (let i = tag.length - 1; i > 0; i--) {
if (tag.charAt(i) === "|" && !nesting) {
last_attr = tag.slice(i + 1);
tag = tag.slice(0, Math.max(0, i));
break;
} else {
switch (tag.slice(i - 1, i - 1 + 2)) {
case "]]":
nesting++;
i--;
break;
case "[[":
nesting--;
i--;
}
}
}
attr = tag.split(/\s*\|\s*/);
attr.push(last_attr);
filename = attr.shift();
let w_match;
for (; attr.length > 0; attr.shift()) {
w_match = attr[0].match(/^(\d*)(?:[px]*\d*)?px$/);
if (w_match) {
[, width] = w_match;
} else {
switch (attr[0]) {
case "thumb":
case "thumbnail":
thumb = true;
frame = true;
break;
case "frame":
frame = true;
break;
case "none":
case "right":
case "left":
center = false;
[align] = attr;
break;
case "center":
center = true;
align = "none";
break;
default:
if (attr.length === 1) {
[caption] = attr;
}
}
}
}
} else {
filename = tag;
}
return "";
};
const parse_inline_nowiki = (str) => {
let start;
let lastend = 0;
let substart = 0;
let nestlev = 0;
let open;
let close;
let subloop;
let html = "";
while ((start = str.indexOf("<no".concat("wiki", ">"), substart)) !== -1) {
html += parse_inline_wiki(str.substring(lastend, start));
start += 8;
substart = start;
subloop = true;
do {
open = str.indexOf("<no".concat("wiki", ">"), substart);
close = str.indexOf("</no".concat("wiki", ">"), substart);
if (close <= open || open === -1) {
if (close === -1) {
return html + html_entities(str.slice(start));
}
substart = close + 9;
if (nestlev) {
nestlev--;
} else {
lastend = substart;
html += html_entities(str.substring(start, lastend - 9));
subloop = false;
}
} else {
substart = open + 8;
nestlev++;
}
} while (subloop);
}
return html + parse_inline_wiki(str.slice(lastend));
};
const parse_inline_images = (str) => {
let start;
let substart = 0;
let nestlev = 0;
let loop;
let close;
let open;
let wiki2;
let html;
while ((start = str.indexOf("[[", substart)) !== -1) {
if (new RegExp("^(Image|File|".concat(Insta.conf.locale.image, "):"), "i").test(str.slice(start + 2))) {
loop = true;
substart = start;
do {
substart += 2;
close = str.indexOf("]]", substart);
open = str.indexOf("[[", substart);
if (close <= open || open === -1) {
if (close === -1) {
return str;
}
substart = close;
if (nestlev) {
nestlev--;
} else {
wiki2 = str.substring(start, close + 2);
html = parse_image(wiki2);
str = str.replace(wiki2, html);
substart = start + html.length;
loop = false;
}
} else {
substart = open;
nestlev++;
}
} while (loop);
} else {
break;
}
}
return str;
};
const parse_inline_formatting = (str) => {
let em;
let st;
let i;
let li;
let o2 = "";
while ((i = str.indexOf("''", li)) + 1) {
o2 += str.substring(li, i);
li = i + 2;
if (str.charAt(i + 2) === "'") {
li++;
st = !st;
o2 += st ? "<strong>" : "</strong>";
} else {
em = !em;
o2 += em ? "<em>" : "</em>";
}
}
return o2 + str.slice(li);
};
const parse_inline_wiki = (str) => {
str = parse_inline_images(str);
str = parse_inline_formatting(str);
str = str.replace(/<math>(.*?)<\/math>/gi, "");
let date = /* @__PURE__ */ new Date();
let minutes = date.getUTCMinutes();
if (minutes < 10) {
minutes = "0".concat(minutes);
}
date = f("?:?, ? ? ? (UTC)", date.getUTCHours(), minutes, date.getUTCDate(), Insta.conf.locale.months[date.getUTCMonth()], date.getUTCFullYear());
return str.replace(/~{5}(?!~)/g, date).replace(/~{4}(?!~)/g, "".concat(Insta.conf.user.name, " ").concat(date)).replace(/~{3}(?!~)/g, Insta.conf.user.name).replace(new RegExp("\\[\\[:((?:".concat(Insta.conf.locale.category, "|Image|File|").concat(Insta.conf.locale.image, "|").concat(Insta.conf.wiki.interwiki, "):[^|]*?)\\]\\](\\w*)"), "gi"), (_$0, $1, $2) => {
return f("<a href='?'>?</a>", Insta.conf.paths.articles + htmlescape_attr($1), htmlescape_text($1) + htmlescape_text($2));
}).replace(new RegExp("\\[\\[(?:".concat(Insta.conf.locale.category, "|").concat(Insta.conf.wiki.interwiki, "):.*?\\]\\]"), "gi"), "").replace(new RegExp("\\[\\[:((?:".concat(Insta.conf.locale.category, "|Image|File|").concat(Insta.conf.locale.image, "|").concat(Insta.conf.wiki.interwiki, "):.*?)\\|([^\\]]+?)\\]\\](\\w*)"), "gi"), (_$0, $1, $2, $3) => {
return f("<a href='?'>?</a>", Insta.conf.paths.articles + htmlescape_attr($1), htmlescape_text($2) + htmlescape_text($3));
}).replace(/\[\[(\/[^|]*?)]]/g, (_$0, $1) => {
return f("<a href='?'>?</a>", Insta.conf.baseUrl + htmlescape_attr($1), htmlescape_text($1));
}).replace(/\[\[(\/.*?)\|(.+?)]]/g, (_$0, $1, $2) => {
return f("<a href='?'>?</a>", Insta.conf.baseUrl + htmlescape_attr($1), htmlescape_text($2));
}).replace(/\[\[([^[|]*?)]](\w*)/g, (_$0, $1, $2) => {
return f("<a href='?'>?</a>", Insta.conf.paths.articles + htmlescape_attr($1), htmlescape_text($1) + htmlescape_text($2));
}).replace(/\[\[([^[]*?)\|([^\]]+?)]](\w*)/g, (_$0, $1, $2, $3) => {
return f("<a href='?'>?</a>", Insta.conf.paths.articles + htmlescape_attr($1), htmlescape_text($2) + htmlescape_text($3));
}).replace(/\[\[([^\]]*?:)?(.*?)( *\(.*?\))?\|]]/g, (_$0, $1, $2, $3) => {
return f("<a href='?'>?</a>", Insta.conf.paths.articles + htmlescape_attr($1) + htmlescape_attr($2) + htmlescape_attr($3), htmlescape_text($2));
}).replace(/\[(https?|news|ftp|mailto|gopher|irc):(\/*)([^\]]*?) (.*?)]/g, (_$0, $1, $2, $3, $4) => {
return f("<a class='external' href='?:?'>?</a>", htmlescape_attr($1), htmlescape_attr($2) + htmlescape_attr($3), htmlescape_text($4));
}).replace(/\[http:\/\/(.*?)]/g, (_$0, $1) => {
return f("<a class='external' href='http://?'>[#]</a>", htmlescape_attr($1));
}).replace(/\[(news|ftp|mailto|gopher|irc):(\/*)(.*?)]/g, (_$0, $1, $2, $3) => {
return f("<a class='external' href='?:?'>?:?</a>", htmlescape_attr($1), htmlescape_attr($2) + htmlescape_attr($3), htmlescape_text($1), htmlescape_text($2) + htmlescape_text($3));
}).replace(/(^| )(https?|news|ftp|mailto|gopher|irc):(\/*)([^ $]*[^ !$,.:;?])/g, (_$0, $1, $2, $3, $4) => {
return f("?<a class='external' href='?:?'>?:?</a>", htmlescape_text($1), htmlescape_attr($2), htmlescape_attr($3) + htmlescape_attr($4), htmlescape_text($2), htmlescape_text($3) + htmlescape_text($4));
}).replace("__NOTOC__", "").replace("__NOINDEX__", "").replace("__INDEX__", "").replace("__NOEDITSECTION__", "");
};
for (; remain(); ) {
if (compareLineStringOrReg(/^(={1,6})(.*)\1(.*)$/)) {
p = 0;
endl(f("<h?>?</h?>?", r[1].length, parse_inline_nowiki(r[2]), r[1].length, r[3]));
} else if (compareLineStringOrReg(/^[#*:;]/)) {
p = 0;
parse_list();
} else if (compareLineStringOrReg(" ")) {
p = 0;
parse_pre();
} else if (compareLineStringOrReg("{|")) {
p = 0;
parse_table();
} else if (compareLineStringOrReg(/^----+$/)) {
p = 0;
endl("<hr>");
} else if (compareLineStringOrReg(Insta.BLOCK_IMAGE)) {
p = 0;
parse_block_image();
} else {
if (compareLineString("")) {
p = remain() > 1 && ll[1] === "";
if (p) {
endl("<p><br>");
}
} else {
if (!p) {
ps("<p>");
p = 1;
}
ps("".concat(parse_inline_nowiki(ll[0]), " "));
}
sh();
}
}
return o;
};
const wiki2html = (txt, baseurl) => {
Insta.conf.baseUrl = baseurl;
return Insta.convert(txt);
};
const popupFilterPageSize = (data) => {
return formatBytes(data.length);
};
const popupFilterCountLinks = (data) => {
const num = countLinks(data);
return "".concat(String(num), " ").concat(num === 1 ? popupString("wikiLink") : popupString("wikiLinks"));
};
const popupFilterCountImages = (data) => {
const num = countImages(data);
return "".concat(String(num), " ").concat(num === 1 ? popupString("image") : popupString("images"));
};
const popupFilterCountCategories = (data) => {
const num = countCategories(data);
return "".concat(String(num), " ").concat(num === 1 ? popupString("category") : popupString("categories"));
};
const popupFilterLastModified = (_data, download) => {
const lastmod = download.lastModified;
const now = /* @__PURE__ */ new Date();
const age = now - lastmod;
if (lastmod && getValueOf("popupLastModified")) {
return tprintf("%s old", [formatAge(age)]).replace(/ /g, " ");
}
return "";
};
const formatAge = (age) => {
let a = 0 + age;
const aa = a;
const seclen = 1e3;
const minlen = 60 * seclen;
const hourlen = 60 * minlen;
const daylen = 24 * hourlen;
const weeklen = 7 * daylen;
const numweeks = (a - a % weeklen) / weeklen;
a -= numweeks * weeklen;
const sweeks = addunit(numweeks, "week");
const numdays = (a - a % daylen) / daylen;
a -= numdays * daylen;
const sdays = addunit(numdays, "day");
const numhours = (a - a % hourlen) / hourlen;
a -= numhours * hourlen;
const shours = addunit(numhours, "hour");
const nummins = (a - a % minlen) / minlen;
a -= nummins * minlen;
const smins = addunit(nummins, "minute");
const numsecs = (a - a % seclen) / seclen;
a -= numsecs * seclen;
const ssecs = addunit(numsecs, "second");
if (aa > 4 * weeklen) {
return sweeks;
}
if (aa > weeklen) {
return "".concat(sweeks, " ").concat(sdays);
}
if (aa > daylen) {
return "".concat(sdays, " ").concat(shours);
}
if (aa > 6 * hourlen) {
return shours;
}
if (aa > hourlen) {
return "".concat(shours, " ").concat(smins);
}
if (aa > 10 * minlen) {
return smins;
}
if (aa > minlen) {
return "".concat(smins, " ").concat(ssecs);
}
return ssecs;
};
const addunit = (num, str) => {
return "".concat(num, " ").concat(num === 1 ? popupString(str) : popupString("".concat(str, "s")));
};
const runPopupFilters = (list, data, download) => {
const ret = [];
var _iterator2 = _createForOfIteratorHelper(list), _step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
const element = _step2.value;
if (element && typeof element === "function") {
const s = element(data, download, download.owner.article);
if (s) {
ret.push(s);
}
}
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
return ret;
};
const getPageInfo = (data, download) => {
if (!data || data.length === 0) {
return popupString("Empty page");
}
const popupFilters = getValueOf("popupFilters") || [];
const extraPopupFilters = getValueOf("extraPopupFilters") || [];
const pageInfoArray = runPopupFilters([...popupFilters, ...extraPopupFilters], data, download);
let pageInfo = pageInfoArray.join(", ");
if (pageInfo !== "") {
pageInfo = upcaseFirst(pageInfo);
}
return pageInfo;
};
const countLinks = (wikiText) => {
return wikiText.split("[[").length - 1;
};
const countImages = (wikiText) => {
return (wikiText.split(pg.re.image).length - 1) / (pg.re.imageBracketCount + 1);
};
const countCategories = (wikiText) => {
return (wikiText.split(pg.re.category).length - 1) / (pg.re.categoryBracketCount + 1);
};
const popupFilterStubDetect = (data, _download, article) => {
const counts = stubCount(data, article);
if (counts.real) {
return popupString("stub");
}
if (counts.sect) {
return popupString("section stub");
}
return "";
};
const popupFilterDisambigDetect = (data, _download, article) => {
if (!getValueOf("popupAllDabsStubs") && article.namespace()) {
return "";
}
return isDisambig(data, article) ? popupString("disambig") : "";
};
const formatBytes = (num) => {
return num > 949 ? Math.round(num / 100) / 10 + popupString("kB") : "".concat(num, " ").concat(popupString("bytes"));
};
const Stringwrapper = function Stringwrapper2() {
this.indexOf = function(x) {
return this.toString().indexOf(x);
};
this.toString = function() {
return this.value;
};
this.split = function(x) {
return this.toString().split(x);
};
this.substring = function(x, y) {
if (y === void 0) {
return this.toString().slice(Math.max(0, x));
}
return this.toString().substring(x, y);
};
this.split = function(x) {
return this.toString().split(x);
};
this.replace = function(x, y) {
return this.toString().replace(x, y);
};
};
class Title extends Stringwrapper {
constructor(val) {
super();
this.value = null;
this.anchor = "";
this.setUtf(val);
}
/**
* Returns the canonical representation of the article title, optionally without anchor.
*
* @param {boolean} omitAnchor
* @fixme Decide specs for anchor
* @return String The article title and the anchor.
*/
toString(omitAnchor) {
return this.value + (!omitAnchor && this.anchor ? "#".concat(this.anchorString()) : "");
}
anchorString() {
if (!this.anchor) {
return "";
}
const split = this.anchor.split(/((?:\.[\dA-F]{2})+)/);
const len = split.length;
let value;
for (let j = 1; j < len; j += 2) {
value = split[j].split(".").join("%");
try {
value = decodeURIComponent(value);
} catch {
}
split[j] = value.split("_").join(" ");
}
return split.join("");
}
urlAnchor() {
const split = this.anchor.split("/((?:[%][0-9A-F]{2})+)/");
const len = split.length;
for (let j = 1; j < len; j += 2) {
split[j] = split[j].split("%").join(".");
}
return split.join("");
}
anchorFromUtf(str) {
this.anchor = encodeURIComponent(str.split(" ").join("_")).split("%3A").join(":").split("'").join("%27").split("%").join(".");
}
fromURL(h) {
if (typeof h !== "string") {
this.value = null;
return this;
}
const splitted = h.split("?");
splitted[0] = splitted[0].split("&").join("%26");
h = splitted.join("?");
const contribs = pg.re.contribs.exec(h);
if (contribs) {
if (contribs[1] === "title=") {
contribs[3] = contribs[3].split("+").join(" ");
}
const u = new Title(contribs[3]);
this.setUtf(Title.decodeNasties("".concat(mw.config.get("wgFormattedNamespaces")[pg.nsUserId], ":").concat(u.stripNamespace())));
return this;
}
const email = pg.re.email.exec(h);
if (email) {
this.setUtf(Title.decodeNasties("".concat(mw.config.get("wgFormattedNamespaces")[pg.nsUserId], ":").concat(new Title(email[3]).stripNamespace())));
return this;
}
const backlinks = pg.re.backlinks.exec(h);
if (backlinks) {
this.setUtf(Title.decodeNasties(new Title(backlinks[3])));
return this;
}
const specialdiff = pg.re.specialdiff.exec(h);
if (specialdiff) {
this.setUtf(Title.decodeNasties(new Title("".concat(mw.config.get("wgFormattedNamespaces")[pg.nsSpecialId], ":Diff"))));
return this;
}
const m = pg.re.main.exec(h);
if (m === null) {
this.value = null;
} else {
const fromBotInterface = /\?(.+&)?title=/.test(h);
if (fromBotInterface) {
m[2] = m[2].split("+").join("_");
}
const extracted = m[2] + (m[3] ? "#".concat(m[3]) : "");
if (pg.flag.isSafari && /%25[\dA-Fa-f]{2}/.test(extracted)) {
this.setUtf(decodeURIComponent(unescape(extracted)));
} else {
this.setUtf(Title.decodeNasties(extracted));
}
}
return this;
}
static decodeNasties(txt) {
try {
let ret = decodeURI(Title.decodeEscapes(txt));
ret = ret.replace(/[ _]*$/, "");
return ret;
} catch {
return txt;
}
}
// Decode valid %-encodings, otherwise escape them
static decodeEscapes(txt) {
const split = txt.split(/((?:%[\dA-Fa-f]{2})+)/);
const len = split.length;
if (len === 1) {
return split[0].replace(/%(?![\dA-Fa-f]{2})/g, "%25");
}
for (let i = 1; i < len; i += 2) {
split[i] = decodeURIComponent(split[i]);
}
return split.join("");
}
fromAnchor(a) {
if (!a) {
this.value = null;
return this;
}
return this.fromURL(a.href);
}
fromWikiText(txt) {
txt = myDecodeURI(txt);
this.setUtf(txt);
return this;
}
hintValue() {
if (!this.value) {
return "";
}
return safeDecodeURI(this.value);
}
toUserName(withNs) {
if (this.namespaceId() !== pg.nsUserId && this.namespaceId() !== pg.nsUsertalkId) {
this.value = null;
return;
}
this.value = (withNs ? "".concat(mw.config.get("wgFormattedNamespaces")[pg.nsUserId], ":") : "") + this.stripNamespace().split("/")[0];
}
userName(withNs) {
const t = new Title(this.value);
t.toUserName(withNs);
if (t.value) {
return t;
}
return null;
}
toTalkPage() {
if (this.value === null) {
return null;
}
const namespaceId = this.namespaceId();
if (namespaceId >= 0 && namespaceId % 2 === 0) {
const localizedNamespace = mw.config.get("wgFormattedNamespaces")[namespaceId + 1];
if (localizedNamespace !== void 0) {
this.value = localizedNamespace === "" ? this.stripNamespace() : "".concat(localizedNamespace.split(" ").join("_"), ":").concat(this.stripNamespace());
return this.value;
}
}
this.value = null;
return null;
}
// Return canonical, localized namespace
namespace() {
return mw.config.get("wgFormattedNamespaces")[this.namespaceId()];
}
namespaceId() {
const n = this.value.indexOf(":");
if (n < 0) {
return 0;
}
const namespaceId = mw.config.get("wgNamespaceIds")[this.value.slice(0, Math.max(0, n)).split(" ").join("_").toLowerCase()];
if (namespaceId === void 0) {
return 0;
}
return namespaceId;
}
talkPage() {
const t = new Title(this.value);
t.toTalkPage();
if (t.value) {
return t;
}
return null;
}
isTalkPage() {
if (this.talkPage() === null) {
return true;
}
return false;
}
toArticleFromTalkPage() {
if (this.value === null) {
return null;
}
const namespaceId = this.namespaceId();
if (namespaceId >= 0 && namespaceId % 2 === 1) {
const localizedNamespace = mw.config.get("wgFormattedNamespaces")[namespaceId - 1];
if (localizedNamespace !== void 0) {
this.value = localizedNamespace === "" ? this.stripNamespace() : "".concat(localizedNamespace.split(" ").join("_"), ":").concat(this.stripNamespace());
return this.value;
}
}
this.value = null;
return null;
}
articleFromTalkPage() {
const t = new Title(this.value);
t.toArticleFromTalkPage();
if (t.value) {
return t;
}
return null;
}
articleFromTalkOrArticle() {
const t = new Title(this.value);
if (t.toArticleFromTalkPage()) {
return t;
}
return this;
}
isIpUser() {
return pg.re.ipUser.test(this.userName());
}
stripNamespace() {
const n = this.value.indexOf(":");
if (n < 0) {
return this.value;
}
const namespaceId = this.namespaceId();
if (namespaceId === pg.nsMainspaceId) {
return this.value;
}
return this.value.slice(Math.max(0, n + 1));
}
setUtf(value) {
if (!value) {
this.value = "";
return;
}
const anch = value.indexOf("#");
if (anch < 0) {
this.value = value.split("_").join(" ");
this.anchor = "";
return;
}
this.value = value.slice(0, Math.max(0, anch)).split("_").join(" ");
this.anchor = value.slice(Math.max(0, anch + 1));
this.ns = null;
}
setUrl(urlfrag) {
const anch = urlfrag.indexOf("#");
this.value = safeDecodeURI(urlfrag.slice(0, Math.max(0, anch)));
this.anchor = this.value.slice(Math.max(0, anch + 1));
}
append(x) {
this.setUtf(this.value + x);
}
urlString(x) {
x || (x = {});
let v = this.toString(true);
if (!x.omitAnchor && this.anchor) {
v += "#".concat(this.urlAnchor());
}
if (!x.keepSpaces) {
v = v.split(" ").join("_");
}
return encodeURI(v).split("&").join("%26").split("?").join("%3F").split("+").join("%2B");
}
removeAnchor() {
return new Title(this.toString(true));
}
toUrl() {
return pg.wiki.titlebase + this.urlString();
}
}
Title.fromURL = (h) => {
return new Title().fromURL(h);
};
Title.fromAnchor = (a) => {
return new Title().fromAnchor(a);
};
Title.fromWikiText = (txt) => {
return new Title().fromWikiText(txt);
};
const parseParams = (url) => {
const specialDiff = pg.re.specialdiff.exec(url);
if (specialDiff) {
const split = specialDiff[1].split("/");
if (split.length === 1) {
return {
oldid: split[0],
diff: "prev"
};
} else if (split.length === 2) {
return {
oldid: split[0],
diff: split[1]
};
}
}
const ret = {};
if (!url.includes("?")) {
return ret;
}
[url] = url.split("#");
const s = url.split("?").slice(1).join(",");
const t = s.split("&");
var _iterator3 = _createForOfIteratorHelper(t), _step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
const element = _step3.value;
const z = element.split("=");
z.push(null);
[, ret[z[0]]] = z;
}
} catch (err) {
_iterator3.e(err);
} finally {
_iterator3.f();
}
if (ret.diff && ret.oldid === void 0) {
ret.oldid = "prev";
}
if (ret.oldid && (ret.oldid === "prev" || ret.oldid === "next" || ret.oldid === "cur")) {
const helper = ret.diff;
ret.diff = ret.oldid;
ret.oldid = helper;
}
return ret;
};
const myDecodeURI = (str) => {
let ret;
try {
ret = decodeURI(str.toString());
} catch {
return str;
}
for (let i = 0; i < pg.misc.decodeExtras.length; ++i) {
const {
from
} = pg.misc.decodeExtras[i];
const {
to
} = pg.misc.decodeExtras[i];
ret = ret.split(from).join(to);
}
return ret;
};
const safeDecodeURI = (str) => {
const ret = myDecodeURI(str);
return ret || str;
};
const isDisambig = (data, article) => {
if (!getValueOf("popupAllDabsStubs") && article.namespace()) {
return false;
}
return !article.isTalkPage() && pg.re.disambig.test(data);
};
const stubCount = (data, article) => {
if (!getValueOf("popupAllDabsStubs") && article.namespace()) {
return false;
}
let sectStub = 0;
let realStub = 0;
if (pg.re.stub.test(data)) {
const s = data.split(pg.re.stub);
for (let i = 1; i < s.length; i += 2) {
if (s[i]) {
++sectStub;
} else {
++realStub;
}
}
}
return {
real: realStub,
sect: sectStub
};
};
const isValidImageName = (str) => {
return !str.includes("{");
};
const isInStrippableNamespace = (article) => {
return article.namespaceId() !== 0;
};
const isInMainNamespace = (article) => {
return article.namespaceId() === 0;
};
const anchorContainsImage = (a) => {
if (a === null) {
return false;
}
const kids = a.childNodes;
var _iterator4 = _createForOfIteratorHelper(kids), _step4;
try {
for (_iterator4.s(); !(_step4 = _iterator4.n()).done; ) {
const kid = _step4.value;
if (kid.nodeName === "IMG") {
return true;
}
}
} catch (err) {
_iterator4.e(err);
} finally {
_iterator4.f();
}
return false;
};
const isPopupLink = (a) => {
if (!markNopopupSpanLinks.done) {
markNopopupSpanLinks();
}
if (a.inNopopupSpan) {
return false;
}
if (a.onmousedown || a.getAttribute("nopopup")) {
return false;
}
const h = a.href;
if (h === "".concat(document.location.href, "#")) {
return false;
}
if (!pg.re.basenames.test(h)) {
return false;
}
if (!pg.re.urlNoPopup.test(h)) {
return true;
}
return (pg.re.email.test(h) || pg.re.contribs.test(h) || pg.re.backlinks.test(h) || pg.re.specialdiff.test(h)) && !h.includes("&limit=");
};
const markNopopupSpanLinks = function markNopopupSpanLinks2() {
if (!getValueOf("popupOnlyArticleLinks")) {
fixVectorMenuPopups();
}
const $body = $("body");
const s = $body.find(".nopopups").toArray();
var _iterator5 = _createForOfIteratorHelper(s), _step5;
try {
for (_iterator5.s(); !(_step5 = _iterator5.n()).done; ) {
const element = _step5.value;
const as = element.querySelectorAll("a");
var _iterator6 = _createForOfIteratorHelper(as), _step6;
try {
for (_iterator6.s(); !(_step6 = _iterator6.n()).done; ) {
const a = _step6.value;
a.inNopopupSpan = true;
}
} catch (err) {
_iterator6.e(err);
} finally {
_iterator6.f();
}
}
} catch (err) {
_iterator5.e(err);
} finally {
_iterator5.f();
}
markNopopupSpanLinks2.done = true;
};
const fixVectorMenuPopups = () => {
const $body = $("body");
$body.find("nav.vector-menu h3:first a:first").prop("inNopopupSpan", true);
};
const getPageWithCaching = (url, onComplete, owner) => {
log("getPageWithCaching, url=".concat(url));
const i = findInPageCache(url);
let d;
if (i > -1) {
d = fakeDownload(url, owner.idNumber, onComplete, pg.cache.pages[i].data, pg.cache.pages[i].lastModified, owner);
} else {
d = getPage(url, onComplete, owner);
if (d && owner && owner.addDownload) {
owner.addDownload(d);
d.owner = owner;
}
}
};
const getPage = (url, onComplete, owner) => {
log("getPage");
const callback = (d) => {
if (!d.aborted) {
addPageToCache(d);
onComplete(d);
}
};
return startDownload(url, owner.idNumber, callback);
};
const findInPageCache = (url) => {
for (let i = 0; i < pg.cache.pages.length; ++i) {
if (url === pg.cache.pages[i].url) {
return i;
}
}
return -1;
};
const addPageToCache = (download) => {
log("addPageToCache ".concat(download.url));
const page = {
url: download.url,
data: download.data,
lastModified: download.lastModified
};
return pg.cache.pages.push(page);
};
const getJsObj = (json) => {
try {
const json_ret = JSON.parse(json);
if (json_ret.warnings) {
for (let w = 0; w < json_ret.warnings.length; w++) {
if (json_ret.warnings[w]["*"]) {
log(json_ret.warnings[w]["*"]);
} else {
log(json_ret.warnings[w].warnings);
}
}
} else if (json_ret.error) {
errlog("".concat(json_ret.error.code, ": ").concat(json_ret.error.info));
}
return json_ret;
} catch {
errlog("Something went wrong with getJsObj, json=".concat(json));
return 1;
}
};
const anyChild = (obj) => {
for (const p in obj) {
if (!Object.hasOwn(obj, p)) {
continue;
}
return obj[p];
}
return null;
};
const upcaseFirst = (str) => {
if (typeof str !== "string" || str === "") {
return;
}
return str.charAt(0).toUpperCase() + str.slice(1);
};
const findInArray = (arr, foo) => {
if (!arr || arr.length === 0) {
return -1;
}
const len = arr.length;
for (let i = 0; i < len; ++i) {
if (arr[i] === foo) {
return i;
}
}
return -1;
};
const nextOne = (array, value) => {
const i = findInArray(array, value);
if (i < 0) {
return null;
}
return array[i + 1];
};
const literalizeRegex = (str) => {
return mw.util.escapeRegExp(str);
};
String.prototype.entify = function() {
return this.split("&").join("&").split("<").join("<").split(">").join(
">"
/* +shy */
).split('"').join(""");
};
const removeNulls = (val) => {
return val !== null;
};
const joinPath = (list) => {
return list.filter(removeNulls).join("/");
};
const simplePrintf = (str, subs) => {
if (!str || !subs) {
return str;
}
const ret = [];
const s = str.split(/(%s|\$\d+)/);
let i = 0;
do {
ret.push(s.shift());
if (s.length === 0) {
break;
}
const cmd = s.shift();
if (cmd === "%s") {
if (i < subs.length) {
ret.push(subs[i]);
} else {
ret.push(cmd);
}
++i;
} else {
const j = Number.parseInt(cmd.replace("$", ""), 10) - 1;
if (j > -1 && j < subs.length) {
ret.push(subs[j]);
} else {
ret.push(cmd);
}
}
} while (s.length > 0);
return ret.join("");
};
const isString = (x) => {
return typeof x === "string" || x instanceof String;
};
const isNumber = (x) => {
return typeof x === "number" || x instanceof Number;
};
const isRegExp = (x) => {
return x instanceof RegExp;
};
const isArray = (x) => {
return Array.isArray(x);
};
const isObject = (x) => {
return x instanceof Object;
};
const isFunction = (x) => {
return !isRegExp(x) && (typeof x === "function" || x instanceof Function);
};
const repeatString = (s, mult) => {
let ret = "";
for (let i = 0; i < mult; ++i) {
ret += s;
}
return ret;
};
const zeroFill = (s, min) => {
min || (min = 2);
const t = s.toString();
return repeatString("0", min - t.length) + t;
};
const map = (f, o) => {
if (isArray(o)) {
return map_array(f, o);
}
return map_object(f, o);
};
const map_array = (f, o) => {
const ret = [];
var _iterator7 = _createForOfIteratorHelper(o), _step7;
try {
for (_iterator7.s(); !(_step7 = _iterator7.n()).done; ) {
const element = _step7.value;
ret.push(f(element));
}
} catch (err) {
_iterator7.e(err);
} finally {
_iterator7.f();
}
return ret;
};
const map_object = (f, o) => {
const ret = {};
for (const i in o) {
if (!Object.hasOwn(o, i)) {
continue;
}
ret[o] = f(o[i]);
}
return ret;
};
pg.escapeQuotesHTML = (text) => {
return text.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
};
pg.unescapeQuotesHTML = (html) => {
const txt = document.createElement("textarea");
txt.innerHTML = html;
return txt.value;
};
const retargetDab = (newTarget, oldTarget, friendlyCurrentArticleName, titleToEdit) => {
log("retargetDab: newTarget=".concat(newTarget, " oldTarget=").concat(oldTarget));
return changeLinkTargetLink({
newTarget,
text: newTarget.split(" ").join(" "),
hint: tprintf("disambigHint", [newTarget]),
summary: simplePrintf(getValueOf("popupFixDabsSummary"), [friendlyCurrentArticleName, newTarget]),
clickButton: getValueOf("popupDabsAutoClick"),
minor: true,
oldTarget,
watch: getValueOf("popupWatchDisambiggedPages"),
title: titleToEdit
});
};
const listLinks = (wikitext, oldTarget, titleToEdit) => {
const reg = /\[\[([^|]*?) *(\||]])/gi;
let ret = [];
const splitted = wikitext.split(reg);
const omitRegex = /^[a-z]*:|^[Ss]pecial:|^[Ii]mage|^[Cc]ategory/;
const friendlyCurrentArticleName = oldTarget.toString();
const wikPos = getValueOf("popupDabWiktionary");
for (let i = 1; i < splitted.length; i += 3) {
if (typeof splitted[i] === "string" && splitted[i].length > 0 && !omitRegex.test(splitted[i])) {
ret.push(retargetDab(splitted[i], oldTarget, friendlyCurrentArticleName, titleToEdit));
}
}
ret = rmDupesFromSortedList(ret.sort());
if (wikPos) {
const wikTarget = "wiktionary:".concat(friendlyCurrentArticleName.replace(/^(.+)\s+\([^)]+\)\s*$/, "$1"));
const meth = wikPos.toLowerCase() === "first" ? "unshift" : "push";
ret[meth](retargetDab(wikTarget, oldTarget, friendlyCurrentArticleName, titleToEdit));
}
ret.push(changeLinkTargetLink({
newTarget: null,
text: popupString("remove this link").split(" ").join(" "),
hint: popupString("remove all links to this disambig page from this article"),
clickButton: getValueOf("popupDabsAutoClick"),
oldTarget,
summary: simplePrintf(getValueOf("popupRmDabLinkSummary"), [friendlyCurrentArticleName]),
watch: getValueOf("popupWatchDisambiggedPages"),
title: titleToEdit
}));
return ret;
};
const rmDupesFromSortedList = (list) => {
const ret = [];
var _iterator8 = _createForOfIteratorHelper(list), _step8;
try {
for (_iterator8.s(); !(_step8 = _iterator8.n()).done; ) {
const element = _step8.value;
if (ret.length === 0 || element !== ret.at(-1)) {
ret.push(element);
}
}
} catch (err) {
_iterator8.e(err);
} finally {
_iterator8.f();
}
return ret;
};
const makeFixDab = (data, navpop) => {
const titleToEdit = navpop.parentPopup && navpop.parentPopup.article.toString();
const list = listLinks(data, navpop.originalArticle, titleToEdit);
if (list.length === 0) {
log("listLinks returned empty list");
return null;
}
let html = "<hr>".concat(popupString("Click to disambiguate this link to:"), "<br>");
html += list.join(", ");
return html;
};
const makeFixDabs = (wikiText, navpop) => {
if (getValueOf("popupFixDabs") && isDisambig(wikiText, navpop.article) && Title.fromURL(location.href).namespaceId() !== pg.nsSpecialId && navpop.article.talkPage()) {
setPopupHTML(makeFixDab(wikiText, navpop), "popupFixDab", navpop.idNumber);
}
};
const popupRedlinkHTML = (article) => {
return changeLinkTargetLink({
newTarget: null,
text: popupString("remove this link").split(" ").join(" "),
hint: popupString("remove all links to this page from this article"),
clickButton: getValueOf("popupRedlinkAutoClick"),
oldTarget: article.toString(),
summary: simplePrintf(getValueOf("popupRedlinkSummary"), [article.toString()])
});
};
const setPopupHTML = function setPopupHTML2(str, elementId, popupId, onSuccess, append) {
if (popupId === void 0) {
popupId = pg.idNumber;
}
const popupElement = document.querySelector("#".concat(elementId).concat(popupId));
if (popupElement) {
if (!append) {
popupElement.innerHTML = "";
}
if (isString(str)) {
popupElement.innerHTML += str;
} else {
popupElement.append(str);
}
if (onSuccess) {
onSuccess();
}
setTimeout(checkPopupPosition, 100);
return true;
}
setTimeout(() => {
setPopupHTML2(str, elementId, popupId, onSuccess);
}, 600);
return null;
};
const setPopupTrailer = (str, id) => {
return setPopupHTML(str, "popupData", id);
};
const fillEmptySpans = (args) => {
let redir = true;
let rcid;
if (typeof args !== "object" || args.redir === void 0 || !args.redir) {
redir = false;
}
const a = args.navpopup.parentAnchor;
let article;
let hint;
let oldid;
let params = {};
if (redir && typeof args.redirTarget === typeof {}) {
article = args.redirTarget;
} else {
article = new Title().fromAnchor(a);
hint = a.originalTitle || article.hintValue();
params = parseParams(a.href);
oldid = getValueOf("popupHistoricalLinks") ? params.oldid : null;
({
rcid
} = params);
}
const x = {
article,
hint,
oldid,
rcid,
navpop: args.navpopup,
params
};
const structure = pg.structures[getValueOf("popupStructure")];
if (typeof structure !== "object") {
setPopupHTML("popupError", "Unknown structure (this should never happen): ".concat(pg.option.popupStructure), args.navpopup.idNumber);
return;
}
const spans = flatten(pg.misc.layout);
const numspans = spans.length;
const redirs = pg.misc.redirSpans;
for (let i = 0; i < numspans; ++i) {
const found = redirs && redirs.includes(spans[i]);
if (found && !redir || !found && redir) {
continue;
}
const structurefn = structure[spans[i]];
if (structurefn === void 0) {
continue;
}
let setfn = setPopupHTML;
if (getValueOf("popupActiveNavlinks") && (spans[i].indexOf("popupTopLinks") === 0 || spans[i].indexOf("popupRedirTopLinks") === 0)) {
setfn = setPopupTipsAndHTML;
}
switch (typeof structurefn) {
case "function":
log("running ".concat(spans[i], "({\n article:").concat(x.article, ", hint:").concat(x.hint, ", oldid: ").concat(x.oldid, "})"));
setfn(structurefn(x), spans[i], args.navpopup.idNumber);
break;
case "string":
setfn(structurefn, spans[i], args.navpopup.idNumber);
break;
default:
errlog("unknown thing with label ".concat(spans[i], " (span index was ").concat(i, ")"));
break;
}
}
};
const flatten = function flatten2(list, start) {
const ret = [];
if (start === void 0) {
start = 0;
}
for (let i = start; i < list.length; ++i) {
if (typeof list[i] === typeof []) {
return [...ret, ...flatten2(list[i]), ...flatten2(list, i + 1)];
}
ret.push(list[i]);
}
return ret;
};
const popupHTML = function popupHTML2(a) {
getValueOf("popupStructure");
const structure = pg.structures[pg.option.popupStructure];
if (typeof structure !== "object") {
pg.option.popupStructure = pg.optionDefault.popupStructure;
return popupHTML2(a);
}
if (typeof structure.popupLayout !== "function") {
return "Bad layout";
}
pg.misc.layout = structure.popupLayout();
pg.misc.redirSpans = typeof structure.popupRedirSpans === "function" ? structure.popupRedirSpans() : [];
return makeEmptySpans(pg.misc.layout, a.navpopup);
};
const makeEmptySpans = function makeEmptySpans2(list, navpop) {
let ret = "";
var _iterator9 = _createForOfIteratorHelper(list), _step9;
try {
for (_iterator9.s(); !(_step9 = _iterator9.n()).done; ) {
const element = _step9.value;
if (typeof element === "string") {
ret += emptySpanHTML(element, navpop.idNumber, "div");
} else if (typeof element === typeof [] && element.length > 0) {
ret = ret.split(/(<\/[^>]*?>$)/).join(makeEmptySpans2(element, navpop));
} else if (typeof element === typeof {} && element.nodeType) {
ret += emptySpanHTML(element.name, navpop.idNumber, element.nodeType);
}
}
} catch (err) {
_iterator9.e(err);
} finally {
_iterator9.f();
}
return ret;
};
const emptySpanHTML = function emptySpanHTML2(name, id, tag, classname) {
tag || (tag = "span");
classname || (classname = emptySpanHTML2.classAliases[name]);
classname || (classname = name);
if (name === getValueOf("popupDragHandle")) {
classname += " popupDragHandle";
}
return simplePrintf('<%s id="%s" class="%s"></%s>', [tag, name + id, classname, tag]);
};
emptySpanHTML.classAliases = {
popupSecondPreview: "popupPreview"
};
const imageHTML = (_article, idNumber) => {
return simplePrintf('<a id="popupImageLink$1"><img align="right" valign="top" id="popupImg$1" style="display:none"></img></a>', [idNumber]);
};
const popTipsSoonFn = (id, when, popData) => {
when || (when = 250);
const popTips = () => {
setupTooltips(document.querySelector("#".concat(id)), false, true, popData);
};
return () => {
setTimeout(popTips, when, popData);
};
};
const setPopupTipsAndHTML = (html, divname, idnumber, popData) => {
setPopupHTML(html, divname, idnumber, getValueOf("popupSubpopups") ? popTipsSoonFn(divname + idnumber, null, popData) : null);
};
const fuzzyCursorOffMenus = (_x, _y, _fuzz, parent) => {
if (!parent) {
return null;
}
const uls = parent.querySelectorAll("ul");
var _iterator10 = _createForOfIteratorHelper(uls), _step10;
try {
for (_iterator10.s(); !(_step10 = _iterator10.n()).done; ) {
const ul = _step10.value;
if (ul.className === "popup_menu" && ul.offsetWidth > 0) {
return false;
}
}
} catch (err) {
_iterator10.e(err);
} finally {
_iterator10.f();
}
return true;
};
const checkPopupPosition = () => {
if (pg.current.link && pg.current.link.navpopup) {
pg.current.link.navpopup.limitHorizontalPosition();
}
};
const mouseOutWikiLink = function mouseOutWikiLink2() {
const self = this;
removeModifierKeyListener(self);
if (self.navpopup === null || self.navpopup === void 0) {
return;
}
if (!self.navpopup.isVisible()) {
self.navpopup.banish();
return;
}
restoreTitle(self);
Navpopup.tracker.addHook(posCheckerHook(self.navpopup));
};
const posCheckerHook = (navpop) => {
return () => {
if (!navpop.isVisible()) {
return true;
}
if (Navpopup.tracker.dirty) {
return false;
}
const {
x
} = Navpopup.tracker;
const {
y
} = Navpopup.tracker;
const mouseOverNavpop = navpop.isWithin(x, y, navpop.fuzz, navpop.mainDiv) || !fuzzyCursorOffMenus(x, y, navpop.fuzz, navpop.mainDiv);
let t = getValueOf("popupHideDelay");
if (t) {
t *= 1e3;
}
if (!t) {
if (!mouseOverNavpop) {
if (navpop.parentAnchor) {
restoreTitle(navpop.parentAnchor);
}
navpop.banish();
return true;
}
return false;
}
const d = Date.now();
if (!navpop.mouseLeavingTime) {
navpop.mouseLeavingTime = d;
return false;
}
if (mouseOverNavpop) {
navpop.mouseLeavingTime = null;
return false;
}
if (d - navpop.mouseLeavingTime > t) {
navpop.mouseLeavingTime = null;
navpop.banish();
return true;
}
return false;
};
};
const runStopPopupTimer = (navpop) => {
if (!navpop.stopPopupTimer) {
navpop.stopPopupTimer = setInterval(posCheckerHook(navpop), 500);
navpop.addHook(() => {
clearInterval(navpop.stopPopupTimer);
}, "hide", "before");
}
};
class Previewmaker {
constructor(wikiText, baseUrl, owner) {
this.originalData = wikiText;
this.baseUrl = baseUrl;
this.owner = owner;
this.maxCharacters = getValueOf("popupMaxPreviewCharacters");
this.maxSentences = getValueOf("popupMaxPreviewSentences");
this.setData();
}
setData() {
const maxSize = Math.max(1e4, 2 * this.maxCharacters);
this.data = this.originalData.slice(0, Math.max(0, maxSize));
}
/**
* Remove HTML comments
*
* @private
*/
killComments() {
this.data = this.data.replace(/^<!--[^$]*?-->\n|\n<!--[^$]*?-->(?=\n)|<!--[^$]*?-->/g, "");
}
/**
* @private
*/
killDivs() {
this.data = this.data.replace(/< *div[^>]* *>[\S\s]*?< *\/ *div *>/gi, "");
}
/**
* @private
*/
killGalleries() {
this.data = this.data.replace(/< *gallery[^>]* *>[\S\s]*?< *\/ *gallery *>/gi, "");
}
/**
* @param {Object} opening
* @param {Object} closing
* @param {Object} subopening
* @param {Object} subclosing
* @param {Object} repl
* @private
*/
kill(opening, closing, subopening, subclosing, repl) {
let oldk = this.data;
let k = Previewmaker.killStuff(this.data, opening, closing, subopening, subclosing, repl);
while (k.length < oldk.length) {
oldk = k;
k = Previewmaker.killStuff(k, opening, closing, subopening, subclosing, repl);
}
this.data = k;
}
/**
* @param {Object} txt
* @param {Object} opening
* @param {Object} closing
* @param {Object} subopening
* @param {Object} subclosing
* @param {Object} repl
* @private
*/
static killStuff(txt, opening, closing, subopening, subclosing, repl) {
const op = Previewmaker.makeRegexp(opening);
const cl = Previewmaker.makeRegexp(closing, "^");
const sb = subopening ? Previewmaker.makeRegexp(subopening, "^") : null;
const sc = subclosing ? Previewmaker.makeRegexp(subclosing, "^") : cl;
if (!op || !cl) {
void mw.notify("Navigation Popups error: op or cl is null! something is wrong.", {
tag: "popups",
type: "error"
});
return;
}
if (!op.test(txt)) {
return txt;
}
let ret = "";
const opResult = op.exec(txt);
ret = txt.slice(0, Math.max(0, opResult.index));
txt = txt.slice(Math.max(0, opResult.index + opResult[0].length));
let depth = 1;
while (txt.length > 0) {
let removal = 0;
if (depth === 1 && cl.test(txt)) {
depth--;
removal = cl.exec(txt)[0].length;
} else if (depth > 1 && sc.test(txt)) {
depth--;
removal = sc.exec(txt)[0].length;
} else if (sb && sb.test(txt)) {
depth++;
removal = sb.exec(txt)[0].length;
}
removal || (removal = 1);
txt = txt.slice(Math.max(0, removal));
if (depth === 0) {
break;
}
}
return ret + (repl || "") + txt;
}
/**
* @param {string|RegExp} x
* @param {string|RegExp} prefix
* @param {string|RegExp} suffix
* @private
*/
static makeRegexp(x, prefix, suffix) {
prefix || (prefix = "");
suffix || (suffix = "");
let reStr = "";
let flags = "";
if (isString(x)) {
reStr = prefix + literalizeRegex(x) + suffix;
} else if (isRegExp(x)) {
let s = x.toString().slice(1);
const sp = s.split("/");
flags = sp.at(-1);
sp[sp.length - 1] = "";
s = sp.join("/");
s = s.slice(0, Math.max(0, s.length - 1));
reStr = prefix + s + suffix;
} else {
log("makeRegexp failed");
}
log("makeRegexp: got reStr=".concat(reStr, ", flags=").concat(flags));
return new RegExp(reStr, flags);
}
/**
* @private
*/
killBoxTemplates() {
this.kill(/{{[^\s{|}]*?(float|box)[ _](begin|start)/i, /}}\s*/, "{{");
this.kill(/{{[^\s{|}]*?(infobox|elementbox|frame)[ _]/i, /}}\s*/, "{{");
}
/**
* @private
*/
killTemplates() {
this.kill("{{", "}}", "{", "}", " ");
}
/**
* @private
*/
killTables() {
this.kill("{|", /\|}\s*/, "{|");
this.kill(/<table.*?>/i, /<\/table.*?>/i, /<table.*?>/i);
this.data = this.data.replace(/^\|.*$/gm, "");
}
/**
* @private
*/
killImages() {
const forbiddenNamespaceAliases = [];
for (var _i = 0, _Object$entries = Object.entries(mw.config.get("wgNamespaceIds")); _i < _Object$entries.length; _i++) {
const [localizedNamespaceLc, namespaceId] = _Object$entries[_i];
if (namespaceId !== pg.nsImageId && namespaceId !== pg.nsCategoryId) {
return;
}
forbiddenNamespaceAliases.push(localizedNamespaceLc.split(" ").join("[ _]"));
}
this.kill(new RegExp("[[][[]\\s*(".concat(forbiddenNamespaceAliases.join("|"), ")\\s*:"), "i"), /]]\s*/, "[", "]");
}
/**
* @private
*/
killHTML() {
this.kill(/<ref\b[^/>]*?>/i, /<\/ref>/i);
this.data = this.data.replace(/(^|\n) *<.*/g, "\n");
const splitted = this.data.split(/(<[\W\w]*?(?:>|$|(?=<)))/);
const len = splitted.length;
for (let i = 1; i < len; i += 2) {
switch (splitted[i]) {
case "<no".concat("wiki", ">"):
case "</no".concat("wiki", ">"):
case "<block".concat("quote", ">"):
case "</block".concat("quote", ">"):
break;
default:
splitted[i] = "";
}
}
this.data = splitted.join("");
}
/**
* @private
*/
killChunks() {
const italicChunkRegex = /((^|\n)\s*:*\s*''[^']([^']|'''|'[^']){20}(.|\n[^\n])*''[\s!.?]*\n)+/g;
this.data = this.data.replace(italicChunkRegex, "\n");
}
/**
* @private
*/
mopup() {
this.data = this.data.replace(/^-{4,}/gm, "");
this.data = this.data.replace(/(^|\n) *:[^\n]*/g, "");
this.data = this.data.replace(/^__[_a-z]*__ *$/gim, "");
}
/**
* @private
*/
firstBit() {
let d = this.data;
if (getValueOf("popupPreviewCutHeadings")) {
this.data = this.data.replace(/\s*(==+[^=]*==+)\s*/g, "\n\n$1 ");
this.data = this.data.replace(/([:;]) *\n{2,}/g, "$1\n");
this.data = this.data.replace(/^\s*/, "");
const stuff = /^([^\n]|\n\S)*/.exec(this.data);
if (stuff) {
[d] = stuff;
}
if (!getValueOf("popupPreviewFirstParOnly")) {
d = this.data;
}
d = d.replace(/(==+[^=]*==+)\s*/g, "$1\n\n");
}
d = d.split(/([!.?]+["']*\s)/g);
d[0] = d[0].replace(/^\s*/, "");
const notSentenceEnds = /([^.][a-z]\. *[a-z]|etc|sic|dr|mr|mrs|ms|st|no|op|cit|\[[^\]]*|\s[a-z])$/i;
d = this.fixSentenceEnds(d, notSentenceEnds);
this.fullLength = d.join("").length;
let n = this.maxSentences;
let dd = Previewmaker.firstSentences(d, n);
do {
dd = Previewmaker.firstSentences(d, n);
--n;
} while (dd.length > this.maxCharacters && n !== 0);
this.data = dd;
}
/**
* @param {string} strs
* @param {RegExp} reg
* @private
*/
fixSentenceEnds(strs, reg) {
for (let i = 0; i < strs.length - 2; ++i) {
if (reg.test(strs[i])) {
const a = [];
for (let j = 0; j < strs.length; ++j) {
if (j < i) {
a[j] = strs[j];
}
if (j === i) {
a[i] = strs[i] + strs[i + 1] + strs[i + 2];
}
if (j > i + 2) {
a[j - 2] = strs[j];
}
}
return this.fixSentenceEnds(a, reg);
}
}
return strs;
}
/**
* @param {string[]} strs
* @param {number} howmany
* @private
*/
static firstSentences(strs, howmany) {
const t = strs.slice(0, 2 * howmany);
return t.join("");
}
/**
* @private
*/
killBadWhitespace() {
this.data = this.data.replace(/^ *'+ *$/gm, "");
}
/**
* Runs the various methods to generate the preview.
* The preview is stored in the <code>html</html> field.
*
* @private
*/
makePreview() {
if (this.owner.article.namespaceId() !== pg.nsTemplateId && this.owner.article.namespaceId() !== pg.nsImageId) {
this.killComments();
this.killDivs();
this.killGalleries();
this.killBoxTemplates();
if (getValueOf("popupPreviewKillTemplates")) {
this.killTemplates();
} else {
this.killMultilineTemplates();
}
this.killTables();
this.killImages();
this.killHTML();
this.killChunks();
this.mopup();
this.firstBit();
this.killBadWhitespace();
} else {
this.killHTML();
}
this.html = wiki2html(this.data, this.baseUrl);
this.fixHTML();
this.stripLongTemplates();
}
/**
* @param {string} data
* @private
*/
static esWiki2HtmlPart(data) {
const reLinks = /(?:\[\[([^\]|]*)(?:\|([^\]|]*))*]]([a-z]*))/gi;
reLinks.lastIndex = 0;
let match;
let result = "";
let postfixIndex = 0;
while ((match = reLinks.exec(data)) !== null) {
var _match$;
result += "".concat(pg.escapeQuotesHTML(data.substring(postfixIndex, match.index)), '<a href="').concat(Insta.conf.paths.articles).concat(pg.escapeQuotesHTML(match[1]), '">').concat(pg.escapeQuotesHTML(((_match$ = match[2]) !== null && _match$ !== void 0 ? _match$ : match[1]) + match[3]), "</a>");
postfixIndex = reLinks.lastIndex;
}
result += pg.escapeQuotesHTML(data.slice(Math.max(0, postfixIndex)));
return result;
}
editSummaryPreview() {
const reAes = /\/\* *(.*?) *\*\//g;
reAes.lastIndex = 0;
const match = reAes.exec(this.data);
if (match) {
const prefix = this.data.slice(0, Math.max(0, match.index - 1));
const [, section] = match;
const postfix = this.data.slice(Math.max(0, reAes.lastIndex));
let start = "<span class='autocomment'>";
let end = "</span>";
if (prefix.length > 0) {
start = "".concat(Previewmaker.esWiki2HtmlPart(prefix), " ").concat(start, "- ");
}
if (postfix.length > 0) {
end = ": ".concat(end).concat(Previewmaker.esWiki2HtmlPart(postfix));
}
const t = new Title().fromURL(this.baseUrl);
t.anchorFromUtf(section);
const sectionLink = "".concat(Insta.conf.paths.articles + pg.escapeQuotesHTML(t.toString(true)), "#").concat(pg.escapeQuotesHTML(t.anchor));
return "".concat(start, '<a href="').concat(sectionLink, '">→</a> ').concat(pg.escapeQuotesHTML(section)).concat(end);
}
return Previewmaker.esWiki2HtmlPart(this.data);
}
/**
* Works around livepreview bugs.
*
* @private
*/
fixHTML() {
if (!this.html) {
return;
}
let ret = this.html;
ret = ret.replace(new RegExp('(<a href="'.concat(pg.wiki.articlePath, '/[^"]*)[?](.*?")'), "g"), "$1%3F$2");
ret = ret.replace(new RegExp("(<a href='".concat(pg.wiki.articlePath, "/[^']*)[?](.*?')"), "g"), "$1%3F$2");
this.html = ret;
}
/**
* Generates the preview and displays it in the current popup.
* Does nothing if the generated preview is invalid or consists of whitespace only.
* Also activates wikilinks in the preview for subpopups if the popupSubpopups option is true.
*/
showPreview() {
this.makePreview();
if (typeof this.html !== "string") {
return;
}
if (/^\s*$/.test(this.html)) {
return;
}
setPopupHTML("<hr>", "popupPrePreviewSep", this.owner.idNumber);
setPopupTipsAndHTML(this.html, "popupPreview", this.owner.idNumber, {
owner: this.owner
});
const more = this.fullLength > this.data.length ? this.moreLink() : "";
setPopupHTML(more, "popupPreviewMore", this.owner.idNumber);
}
/**
* @private
*/
moreLink() {
const a = document.createElement("a");
a.className = "popupMoreLink";
a.innerHTML = popupString("more...");
const self = this;
a.onclick = () => {
self.maxCharacters += 2e3;
self.maxSentences += 20;
self.setData();
self.showPreview();
};
return a;
}
/**
* @private
*/
stripLongTemplates() {
this.html = this.html.replace(/^.{0,1000}{{[^}]*?(<(p|br)( \/)?>\s*){2,}([^{}]*?}})?/gi, "");
this.html = this.html.split("\n").join(" ");
this.html = this.html.replace(/{{[^}]*<pre>[^}]*}}/gi, "");
}
/**
* @private
*/
killMultilineTemplates() {
this.kill("{{{", "}}}");
this.kill(/\s*{{[^{}]*\n/, "}}", "{{");
}
}
const loadAPIPreview = (queryType, article, navpop) => {
const art = new Title(article).urlString();
let url = "".concat(pg.wiki.apiwikibase, "?format=json&formatversion=2&action=query&");
let htmlGenerator = () => {
void mw.notify("invalid html generator", {
tag: "popups",
type: "error"
});
};
let usernameart = "";
switch (queryType) {
case "history":
url += "titles=".concat(art, "&prop=revisions&rvlimit=").concat(getValueOf("popupHistoryPreviewLimit"));
htmlGenerator = APIhistoryPreviewHTML;
break;
case "category":
url += "list=categorymembers&cmtitle=".concat(art);
htmlGenerator = APIcategoryPreviewHTML;
break;
case "userinfo": {
const username = new Title(article).userName();
usernameart = encodeURIComponent(username);
url += pg.re.ipUser.test(username) ? "list=blocks&bkprop=range|restrictions&bkip=".concat(usernameart) : "list=users|usercontribs&usprop=blockinfo|groups|editcount|registration|gender&ususers=".concat(usernameart, "&meta=globaluserinfo&guiprop=groups|unattached&guiuser=").concat(usernameart, "&uclimit=1&ucprop=timestamp&ucuser=").concat(usernameart);
htmlGenerator = APIuserInfoPreviewHTML;
break;
}
case "contribs":
usernameart = encodeURIComponent(new Title(article).userName());
url += "list=usercontribs&ucuser=".concat(usernameart, "&uclimit=").concat(getValueOf("popupContribsPreviewLimit"));
htmlGenerator = APIcontribsPreviewHTML;
break;
case "imagepagepreview": {
let trail = "";
if (getValueOf("popupImageLinks")) {
trail = "&list=imageusage&iutitle=".concat(art);
}
url += "titles=".concat(art, "&prop=revisions|imageinfo&rvprop=content").concat(trail);
htmlGenerator = APIimagepagePreviewHTML;
break;
}
case "backlinks":
url += "list=backlinks&bltitle=".concat(art);
htmlGenerator = APIbacklinksPreviewHTML;
break;
case "revision":
url += article.oldid ? "revids=".concat(article.oldid) : "titles=".concat(article.removeAnchor().urlString());
url += "&prop=revisions|pageprops|info|images|categories&rvprop=ids|timestamp|flags|comment|user|content&cllimit=max&imlimit=max";
htmlGenerator = APIrevisionPreviewHTML;
break;
}
pendingNavpopTask(navpop);
const callback = (d) => {
log("callback of API functions was hit");
if (queryType === "userinfo") {
fetchUserGroupNames(d.data).then(() => {
showAPIPreview(queryType, htmlGenerator(article, d, navpop), navpop.idNumber, navpop, d);
});
return;
}
showAPIPreview(queryType, htmlGenerator(article, d, navpop), navpop.idNumber, navpop, d);
};
const go = () => {
getPageWithCaching(url, callback, navpop);
return true;
};
if (navpop.visible || !getValueOf("popupLazyDownloads")) {
go();
} else {
navpop.addHook(go, "unhide", "before", "DOWNLOAD_".concat(queryType, "_QUERY_DATA"));
}
};
const linkList = (list) => {
list.sort((x, y) => {
return x === y ? 0 : x < y ? -1 : 1;
});
const buf = [];
var _iterator11 = _createForOfIteratorHelper(list), _step11;
try {
for (_iterator11.s(); !(_step11 = _iterator11.n()).done; ) {
const element = _step11.value;
buf.push(wikiLink({
article: new Title(element),
text: element.split(" ").join(" "),
action: "view"
}));
}
} catch (err) {
_iterator11.e(err);
} finally {
_iterator11.f();
}
return buf.join(", ");
};
const getTimeOffset = () => {
const tz = mw.user.options.get("timecorrection");
if (tz && tz.includes("|")) {
return Number.parseInt(tz.split("|")[1], 10);
}
return 0;
};
const getTimeZone = () => {
if (!pg.user.timeZone) {
const tz = mw.user.options.get("timecorrection");
pg.user.timeZone = "UTC";
if (tz) {
const tzComponents = tz.split("|");
if (tzComponents.length === 3 && tzComponents[0] === "ZoneInfo") {
[, , pg.user.timeZone] = tzComponents;
} else {
errlog("Unexpected timezone information: ".concat(tz));
}
}
}
return pg.user.timeZone;
};
const useTimeOffset = () => {
if (Intl.DateTimeFormat.prototype.formatToParts === void 0) {
return true;
}
const tz = mw.user.options.get("timecorrection");
if (tz && !tz.includes("ZoneInfo|")) {
return true;
}
return false;
};
const getLocales = () => {
if (!pg.user.locales) {
let userLanguage = document.querySelector("html").getAttribute("lang");
if (getValueOf("popupLocale")) {
userLanguage = getValueOf("popupLocale");
} else if (userLanguage === "en") {
userLanguage = getMWDateFormat() === "mdy" ? "en-US" : "en-GB";
}
pg.user.locales = Intl.DateTimeFormat.supportedLocalesOf([userLanguage, navigator.language]);
}
return pg.user.locales;
};
const getMWDateFormat = () => {
return mw.user.options.get("date");
};
const editPreviewTable = (article, h, reallyContribs) => {
let html = ["<table>"];
let day;
let curart = article;
let page;
let makeFirstColumnLinks;
if (reallyContribs) {
makeFirstColumnLinks = (currentRevision) => {
let result = "(";
result += '<a href="'.concat(pg.wiki.titlebase).concat(new Title(currentRevision.title).urlString(), "&diff=prev&oldid=").concat(currentRevision.revid, '">').concat(popupString("diff"), "</a>");
result += " | ";
result += '<a href="'.concat(pg.wiki.titlebase).concat(new Title(currentRevision.title).urlString(), '&action=history">').concat(popupString("hist"), "</a>");
result += ")";
return result;
};
} else {
const firstRevid = h[0].revid;
makeFirstColumnLinks = (currentRevision) => {
let result = "(";
result += '<a href="'.concat(pg.wiki.titlebase).concat(new Title(curart).urlString(), "&diff=").concat(firstRevid, "&oldid=").concat(currentRevision.revid, '">').concat(popupString("cur"), "</a>");
result += " | ";
result += '<a href="'.concat(pg.wiki.titlebase).concat(new Title(curart).urlString(), "&diff=prev&oldid=").concat(currentRevision.revid, '">').concat(popupString("last"), "</a>");
result += ")";
return result;
};
}
var _iterator12 = _createForOfIteratorHelper(h.entries()), _step12;
try {
for (_iterator12.s(); !(_step12 = _iterator12.n()).done; ) {
const [i, element] = _step12.value;
if (reallyContribs) {
page = element.title;
curart = new Title(page);
}
const minor = element.minor ? "<b>m </b>" : "";
const editDate = new Date(element.timestamp);
let thisDay = formattedDate(editDate);
const thisTime = formattedTime(editDate);
if (thisDay === day) {
thisDay = "";
} else {
day = thisDay;
}
if (thisDay) {
html.push('<tr><td colspan=3><span class="popup_history_date">'.concat(thisDay, "</span></td></tr>"));
}
html.push('<tr class="popup_history_row_'.concat(i % 2 ? "odd" : "even", '">'), "<td>".concat(makeFirstColumnLinks(element), "</td>"), '<td><a href="'.concat(pg.wiki.titlebase).concat(new Title(curart).urlString(), "&oldid=").concat(element.revid, '">').concat(thisTime, "</a></td>"));
let col3url = "";
let col3txt = "";
if (reallyContribs) {
col3url = pg.wiki.titlebase + curart.urlString();
col3txt = pg.escapeQuotesHTML(page);
} else {
const {
user
} = element;
if (element.userhidden) {
col3url = getValueOf("popupRevDelUrl");
col3txt = pg.escapeQuotesHTML(popupString("revdel"));
} else {
col3url = pg.re.ipUser.test(user) ? "".concat(pg.wiki.titlebase + mw.config.get("wgFormattedNamespaces")[pg.nsSpecialId], ":Contributions&target=").concat(new Title(user).urlString()) : "".concat(pg.wiki.titlebase + mw.config.get("wgFormattedNamespaces")[pg.nsUserId], ":").concat(new Title(user).urlString());
col3txt = pg.escapeQuotesHTML(user);
}
}
html.push("<td>".concat(reallyContribs ? minor : "", '<a href="').concat(col3url, '">').concat(col3txt, "</a></td>"));
let comment = "";
const c = element.comment || element.content;
if (c) {
comment = new Previewmaker(c, new Title(curart).toUrl()).editSummaryPreview();
} else if (element.commenthidden) {
comment = popupString("revdel");
}
html.push("<td>".concat(reallyContribs ? "" : minor).concat(comment, "</td>"), "</tr>");
html = [html.join("")];
}
} catch (err) {
_iterator12.e(err);
} finally {
_iterator12.f();
}
html.push("</table>");
return html.join("");
};
const adjustDate = (d, offset) => {
const o = offset * 60 * 1e3;
return new Date(+d + o);
};
const convertTimeZone = (date, timeZone) => {
return new Date(date.toLocaleString("en-US", {
timeZone
}));
};
const formattedDateTime = (date) => {
if (useTimeOffset()) {
return "".concat(formattedDate(date), " ").concat(formattedTime(date));
}
if (getMWDateFormat() === "ISO 8601") {
const d2 = convertTimeZone(date, getTimeZone());
return "".concat(map(zeroFill, [d2.getFullYear(), d2.getMonth() + 1, d2.getDate()]).join("-"), "T").concat(map(zeroFill, [d2.getHours(), d2.getMinutes(), d2.getSeconds()]).join(":"));
}
const options = getValueOf("popupDateTimeFormatterOptions");
options.timeZone = getTimeZone();
return date.toLocaleString(getLocales(), options);
};
const formattedDate = (date) => {
let d2;
if (useTimeOffset()) {
d2 = adjustDate(date, getTimeOffset());
return map(zeroFill, [d2.getUTCFullYear(), d2.getUTCMonth() + 1, d2.getUTCDate()]).join("-");
}
if (getMWDateFormat() === "ISO 8601") {
d2 = convertTimeZone(date, getTimeZone());
return map(zeroFill, [d2.getFullYear(), d2.getMonth() + 1, d2.getDate()]).join("-");
}
const options = getValueOf("popupDateFormatterOptions");
options.timeZone = getTimeZone();
return date.toLocaleDateString(getLocales(), options);
};
const formattedTime = (date) => {
let d2;
if (useTimeOffset()) {
d2 = adjustDate(date, getTimeOffset());
return map(zeroFill, [d2.getUTCHours(), d2.getUTCMinutes(), d2.getUTCSeconds()]).join(":");
}
if (getMWDateFormat() === "ISO 8601") {
d2 = convertTimeZone(date, getTimeZone());
return map(zeroFill, [d2.getHours(), d2.getMinutes(), d2.getSeconds()]).join(":");
}
const options = getValueOf("popupTimeFormatterOptions");
options.timeZone = getTimeZone();
return date.toLocaleTimeString(getLocales(), options);
};
const fetchUserGroupNames = (userinfoResponse) => {
const queryObj = getJsObj(userinfoResponse).query;
const user = anyChild(queryObj.users);
const messages = [];
if (user.groups) {
var _iterator13 = _createForOfIteratorHelper(user.groups), _step13;
try {
for (_iterator13.s(); !(_step13 = _iterator13.n()).done; ) {
const groupName = _step13.value;
if (!["*", "user", "autoconfirmed"].includes(groupName)) {
messages.push("group-".concat(groupName, "-member"));
}
}
} catch (err) {
_iterator13.e(err);
} finally {
_iterator13.f();
}
}
if (queryObj.globaluserinfo && queryObj.globaluserinfo.groups) {
var _iterator14 = _createForOfIteratorHelper(queryObj.globaluserinfo.groups), _step14;
try {
for (_iterator14.s(); !(_step14 = _iterator14.n()).done; ) {
const groupName = _step14.value;
messages.push("group-".concat(groupName, "-member"));
}
} catch (err) {
_iterator14.e(err);
} finally {
_iterator14.f();
}
}
return getMwApi().loadMessagesIfMissing(messages);
};
const showAPIPreview = (queryType, html, id, navpop, download) => {
let target = "popupPreview";
completedNavpopTask(navpop);
switch (queryType) {
case "imagelinks":
case "category":
target = "popupPostPreview";
break;
case "userinfo":
target = "popupUserData";
break;
case "revision":
insertPreview(download);
return;
}
setPopupTipsAndHTML(html, target, id);
};
const APIrevisionPreviewHTML = (_article, download) => {
try {
const jsObj = getJsObj(download.data);
const page = anyChild(jsObj.query.pages);
if (page.missing) {
download.owner = null;
return;
}
const content = page && page.revisions && page.revisions[0].contentmodel === "wikitext" ? page.revisions[0].content : null;
if (typeof content === "string") {
download.data = content;
download.lastModified = new Date(page.revisions[0].timestamp);
}
} catch {
return "Revision preview failed :(";
}
};
const APIbacklinksPreviewHTML = (_article, download) => {
try {
const jsObj = getJsObj(download.data);
const list = jsObj.query.backlinks;
let html = [];
if (!list) {
return popupString("No backlinks found");
}
var _iterator15 = _createForOfIteratorHelper(list), _step15;
try {
for (_iterator15.s(); !(_step15 = _iterator15.n()).done; ) {
const element = _step15.value;
const t = new Title(element.title);
html.push('<a href="'.concat(pg.wiki.titlebase).concat(t.urlString(), '">').concat(t.toString().entify(), "</a>"));
}
} catch (err) {
_iterator15.e(err);
} finally {
_iterator15.f();
}
html = html.join(", ");
if (jsObj.continue && jsObj.continue.blcontinue) {
html += popupString(" and more");
}
return html;
} catch {
return "backlinksPreviewHTML went wonky";
}
};
pg.fn.APIsharedImagePagePreviewHTML = (obj) => {
log("APIsharedImagePagePreviewHTML");
const popupid = obj.requestid;
if (obj.query && obj.query.pages) {
const page = anyChild(obj.query.pages);
const content = page && page.revisions && page.revisions[0].contentmodel === "wikitext" ? page.revisions[0].content : null;
if (typeof content === "string" && pg && pg.current && pg.current.link && pg.current.link.navpopup) {
const p = new Previewmaker(content, pg.current.link.navpopup.article, pg.current.link.navpopup);
p.makePreview();
setPopupHTML(p.html, "popupSecondPreview", popupid);
}
}
};
const APIimagepagePreviewHTML = (article, download, navpop) => {
try {
const jsObj = getJsObj(download.data);
const page = anyChild(jsObj.query.pages);
const content = page && page.revisions && page.revisions[0].contentmodel === "wikitext" ? page.revisions[0].content : null;
let ret = "";
let alt = "";
try {
[{
alt
}] = navpop.parentAnchor.childNodes;
} catch {
}
if (alt) {
ret = "".concat(ret, "<hr><b>").concat(popupString("Alt text:"), "</b> ").concat(pg.escapeQuotesHTML(alt));
}
if (typeof content === "string") {
const p = prepPreviewmaker(content, article, navpop);
p.makePreview();
if (p.html) {
ret += "<hr>".concat(p.html);
}
if (getValueOf("popupSummaryData")) {
const info = getPageInfo(content, download);
log(info);
setPopupTrailer(info, navpop.idNumber);
}
}
if (page && page.imagerepository === "shared") {
const art = new Title(article);
const encart = encodeURIComponent("File:".concat(art.stripNamespace()));
const shared_url = "".concat(pg.wiki.apicommonsbase, "?format=json&formatversion=2&callback=pg.fn.APIsharedImagePagePreviewHTML&requestid=").concat(navpop.idNumber, "&action=query&prop=revisions&rvprop=content&titles=").concat(encart);
ret = "".concat(ret, "<hr>").concat(popupString("Image from Commons"), ': <a href="').concat(pg.wiki.commonsbase, "?title=").concat(encart, '">').concat(popupString("Description page"), "</a>");
mw.loader.load(shared_url);
}
showAPIPreview("imagelinks", APIimagelinksPreviewHTML(article, download), navpop.idNumber, download);
return ret;
} catch {
return "API imagepage preview failed :(";
}
};
const APIimagelinksPreviewHTML = (_article, download) => {
try {
const jsobj = getJsObj(download.data);
const list = jsobj.query.imageusage;
if (list) {
const ret = [];
var _iterator16 = _createForOfIteratorHelper(list), _step16;
try {
for (_iterator16.s(); !(_step16 = _iterator16.n()).done; ) {
const element = _step16.value;
ret.push(element.title);
}
} catch (err) {
_iterator16.e(err);
} finally {
_iterator16.f();
}
if (ret.length === 0) {
return popupString("No image links found");
}
return "<h2>".concat(popupString("File links"), "</h2>").concat(linkList(ret));
}
return popupString("No image links found");
} catch {
return "Image links preview generation failed :(";
}
};
const APIcategoryPreviewHTML = (_article, download) => {
try {
const jsobj = getJsObj(download.data);
const list = jsobj.query.categorymembers;
let ret = [];
var _iterator17 = _createForOfIteratorHelper(list), _step17;
try {
for (_iterator17.s(); !(_step17 = _iterator17.n()).done; ) {
const element = _step17.value;
ret.push(element.title);
}
} catch (err) {
_iterator17.e(err);
} finally {
_iterator17.f();
}
if (ret.length === 0) {
return popupString("Empty category");
}
ret = "<h2>".concat(tprintf("Category members (%s shown)", [ret.length]), "</h2>").concat(linkList(ret));
if (jsobj.continue && jsobj.continue.cmcontinue) {
ret += popupString(" and more");
}
return ret;
} catch {
return "Category preview failed :(";
}
};
const APIuserInfoPreviewHTML = (_article, download) => {
let ret = [];
let queryobj = {};
try {
queryobj = getJsObj(download.data).query;
} catch {
return "Userinfo preview failed :(";
}
const user = anyChild(queryobj.users);
if (user) {
const {
globaluserinfo
} = queryobj;
if (user.invalid === "") {
ret.push(popupString("Invalid user"));
} else if (user.missing === "") {
ret.push(popupString("Not a registered username"));
}
if (user.blockedby) {
if (user.blockpartial) {
ret.push("<b>".concat(popupString("Has blocks"), "</b>"));
} else {
ret.push("<b>".concat(popupString("BLOCKED"), "</b>"));
}
}
if (globaluserinfo && ("locked" in globaluserinfo || "hidden" in globaluserinfo)) {
let lockedSulAccountIsAttachedToThis = true;
for (let i = 0; globaluserinfo.unattached && i < globaluserinfo.unattached.length; i++) {
if (globaluserinfo.unattached[i].wiki === mw.config.get("wgDBname")) {
lockedSulAccountIsAttachedToThis = false;
break;
}
}
if (lockedSulAccountIsAttachedToThis) {
if ("locked" in globaluserinfo) {
ret.push("<b><i>".concat(popupString("LOCKED"), "</i></b>"));
}
if ("hidden" in globaluserinfo) {
ret.push("<b><i>".concat(popupString("HIDDEN"), "</i></b>"));
}
}
}
if (getValueOf("popupShowGender") && user.gender) {
switch (user.gender) {
case "male":
ret.push("".concat(popupString("he/him"), " · "));
break;
case "female":
ret.push("".concat(popupString("she/her"), " · "));
break;
}
}
if (user.groups) {
var _iterator18 = _createForOfIteratorHelper(user.groups), _step18;
try {
for (_iterator18.s(); !(_step18 = _iterator18.n()).done; ) {
const groupName = _step18.value;
if (!["*", "user", "autoconfirmed"].includes(groupName)) {
ret.push(pg.escapeQuotesHTML(mw.message("group-".concat(groupName, "-member"), user.gender).text()));
}
}
} catch (err) {
_iterator18.e(err);
} finally {
_iterator18.f();
}
}
if (globaluserinfo && globaluserinfo.groups) {
var _iterator19 = _createForOfIteratorHelper(globaluserinfo.groups), _step19;
try {
for (_iterator19.s(); !(_step19 = _iterator19.n()).done; ) {
const groupName = _step19.value;
ret.push(
// Messages that can be used here:
// * see [[Special:PrefixIndex/MediaWiki:Group-]]
// * for more information
"<i>".concat(pg.escapeQuotesHTML(mw.message("group-".concat(groupName, "-member"), user.gender).text()), "</i>")
);
}
} catch (err) {
_iterator19.e(err);
} finally {
_iterator19.f();
}
}
if (user.registration) {
var _user$editcount;
ret.push(pg.escapeQuotesHTML(((_user$editcount = user.editcount) !== null && _user$editcount !== void 0 ? _user$editcount : "0") + popupString(" edits since: ") + (user.registration ? formattedDate(new Date(user.registration)) : "")));
}
}
if (queryobj.usercontribs && queryobj.usercontribs.length > 0) {
ret.push(popupString("last edit on ") + formattedDate(new Date(queryobj.usercontribs[0].timestamp)));
}
if (queryobj.blocks) {
ret.push(popupString("IP user"));
for (let l = 0; l < queryobj.blocks.length; l++) {
let rbstr = queryobj.blocks[l].rangestart === queryobj.blocks[l].rangeend ? "BLOCK" : "RANGEBLOCK";
rbstr = Array.isArray(queryobj.blocks[l].restrictions) ? "".concat(rbstr, "ED") : "Has ".concat(rbstr.toLowerCase(), "s");
ret.push("<b>".concat(popupString(rbstr), "</b>"));
}
}
for (let m = 0; m < ret.length - 1; m++) {
if (ret[m].length > 3 && ret[m].slice(Math.max(0, ret[m].length - 3)) === " · ") {
ret[m] += ret[m + 1];
ret.splice(m + 1, 1);
m--;
}
}
ret = "<hr>".concat(ret.join(", "));
return ret;
};
const APIcontribsPreviewHTML = (article, download, navpop) => {
return APIhistoryPreviewHTML(article, download, navpop, true);
};
const APIhistoryPreviewHTML = (article, download, _navpop, reallyContribs) => {
try {
const jsobj = getJsObj(download.data);
let edits = [];
edits = reallyContribs ? jsobj.query.usercontribs : anyChild(jsobj.query.pages).revisions;
const ret = editPreviewTable(article, edits, reallyContribs);
return ret;
} catch {
return "History preview failed :-(";
}
};
const setupDebugging = () => {
if (window.popupDebug) {
window.log = (x) => {
console.log(x);
};
window.errlog = (x) => {
console.error("[Popups] ".concat(x));
};
log("Initializing logger");
} else {
window.log = () => {
};
window.errlog = () => {
};
}
};
const loadImage = (image, navpop) => {
if (typeof image.stripNamespace !== "function") {
void mw.notify("loadImages bad", {
tag: "popups",
type: "error"
});
}
if (!getValueOf("popupImages")) {
return;
}
if (!isValidImageName(image.toString())) {
return false;
}
const art = image.urlString();
let url = "".concat(pg.wiki.apiwikibase, "?format=json&formatversion=2&action=query");
url += "&prop=imageinfo&iiprop=url|mime&iiurlwidth=".concat(getValueOf("popupImageSizeLarge"));
url += "&titles=".concat(art);
pendingNavpopTask(navpop);
const callback = (d) => {
popupsInsertImage(navpop.idNumber, navpop, d);
};
const go = () => {
getPageWithCaching(url, callback, navpop);
return true;
};
if (navpop.visible || !getValueOf("popupLazyDownloads")) {
go();
} else {
navpop.addHook(go, "unhide", "after", "DOWNLOAD_IMAGE_QUERY_DATA");
}
};
const popupsInsertImage = (id, _navpop, download) => {
log("popupsInsertImage");
let imageinfo;
try {
const jsObj = getJsObj(download.data);
const imagepage = anyChild(jsObj.query.pages);
if (imagepage.imageinfo === void 0) {
return;
}
[imageinfo] = imagepage.imageinfo;
} catch {
log("popupsInsertImage failed :(");
return;
}
const popupImage = document.querySelector("#popupImg".concat(id));
if (!popupImage) {
log("could not find insertion point for image");
return;
}
popupImage.width = getValueOf("popupImageSize");
popupImage.style.display = "inline";
if (imageinfo.thumburl) {
popupImage.src = imageinfo.thumburl;
} else if (imageinfo.mime.indexOf("image") === 0) {
popupImage.src = imageinfo.url;
log("a thumb could not be found, using original image");
} else {
log("fullsize imagethumb, but not sure if it's an image");
}
const a = document.querySelector("#popupImageLink".concat(id));
if (a === null) {
return null;
}
switch (getValueOf("popupThumbAction")) {
case "imagepage":
if (pg.current.article.namespaceId() !== pg.nsImageId) {
a.href = imageinfo.descriptionurl;
popTipsSoonFn("popupImage".concat(id))();
break;
}
case "sizetoggle":
a.onclick = toggleSize;
a.title = popupString("Toggle image size");
return;
case "linkfull":
a.href = imageinfo.url;
a.title = popupString("Open full-size image");
}
};
const toggleSize = function toggleSize2() {
const self = this;
if (!self) {
void mw.notify("self is null :/", {
tag: "popups",
type: "error"
});
return;
}
const img = self.firstChild;
if (!img) {
void mw.notify("img is null :/", {
tag: "popups",
type: "error"
});
return;
}
img.style.width = !img.style.width || img.style.width === "" ? "100%" : "";
};
const getValidImageFromWikiText = (wikiText) => {
let matched;
let match;
const t = removeMatchesUnless(wikiText, /(<!--[\S\s]*?-->)/, 1, /^<!--[^[]*popup/i);
while ((match = pg.re.image.exec(t)) !== null) {
const m = match[2] || match[6];
if (isValidImageName(m)) {
matched = m;
break;
}
}
pg.re.image.lastIndex = 0;
if (!matched) {
return null;
}
return "".concat(mw.config.get("wgFormattedNamespaces")[pg.nsImageId], ":").concat(upcaseFirst(matched));
};
const removeMatchesUnless = (str, re1, parencount, re2) => {
const split = str.split(re1);
const c = parencount + 1;
for (let i = 0; i < split.length; ++i) {
if (i % c === 0 || re2.test(split[i])) {
continue;
}
split[i] = "";
}
return split.join("");
};
const setNamespaces = () => {
pg.nsSpecialId = -1;
pg.nsMainspaceId = 0;
pg.nsImageId = 6;
pg.nsUserId = 2;
pg.nsUsertalkId = 3;
pg.nsCategoryId = 14;
pg.nsTemplateId = 10;
};
const setRedirs = () => {
const r = "redirect";
const R = "REDIRECT";
const redirLists = {
ar: [R, "تحويل"],
be: [r, "перанакіраваньне"],
bg: [r, "пренасочване", "виж"],
bs: [r, "Preusmjeri", "preusmjeri", "PREUSMJERI"],
bn: [R, "পুনর্নির্দেশ"],
cs: [R, "PŘESMĚRUJ"],
cy: [r, "ail-cyfeirio"],
de: [R, "WEITERLEITUNG"],
el: [R, "ΑΝΑΚΑΤΕΥΘΥΝΣΗ"],
eo: [R, "ALIDIREKTU", "ALIDIREKTI"],
es: [R, "REDIRECCIÓN"],
et: [r, "suuna"],
ga: [r, "athsheoladh"],
gl: [r, "REDIRECCIÓN", "REDIRECIONAMENTO"],
he: [R, "הפניה"],
hu: [R, "ÁTIRÁNYÍTÁS"],
is: [r, "tilvísun", "TILVÍSUN"],
it: [R, "RINVIA", "Rinvia"],
ja: [R, "転送"],
mk: [r, "пренасочување", "види"],
nds: [r, "wiederleiden"],
"nds-nl": [R, "DEURVERWIEZING", "DUURVERWIEZING"],
nl: [R, "DOORVERWIJZING"],
nn: [r, "omdiriger"],
pl: [R, "PATRZ", "PRZEKIERUJ", "TAM"],
pt: [R, "redir"],
ru: [R, "ПЕРЕНАПРАВЛЕНИЕ", "ПЕРЕНАПР"],
sk: [r, "presmeruj"],
sr: [r, "Преусмери", "преусмери", "ПРЕУСМЕРИ", "Preusmeri", "preusmeri", "PREUSMERI"],
tt: [R, "yünältü", "перенаправление", "перенапр"],
uk: [R, "ПЕРЕНАПРАВЛЕННЯ", "ПЕРЕНАПР"],
vi: [r, "đổi"],
yi: [R, "ווייטערפירן"],
zh: [R, "重定向"]
// no comma
};
const redirList = redirLists[pg.wiki.lang] || [r, R];
pg.re.redirect = new RegExp("^\\s*[#](".concat(redirList.join("|"), ").*?\\[{2}([^\\|\\]]*)(|[^\\]]*)?\\]{2}\\s*(.*)"), "i");
};
const setInterwiki = () => {
if (pg.wiki.wikimedia) {
pg.wiki.interwiki = "aa|ab|ace|af|ak|als|am|an|ang|ar|arc|arz|as|ast|av|ay|az|ba|bar|bat-smg|bcl|be|be-x-old|bg|bh|bi|bjn|bm|bn|bo|bpy|br|bs|bug|bxr|ca|cbk-zam|cdo|ce|ceb|ch|cho|chr|chy|ckb|co|cr|crh|cs|csb|cu|cv|cy|da|de|diq|dsb|dv|dz|ee|el|eml|en|eo|es|et|eu|ext|fa|ff|fi|fiu-vro|fj|fo|fr|frp|frr|fur|fy|ga|gag|gan|gd|gl|glk|gn|got|gu|gv|ha|hak|haw|he|hi|hif|ho|hr|hsb|ht|hu|hy|hz|ia|id|ie|ig|ii|ik|ilo|io|is|it|iu|ja|jbo|jv|ka|kaa|kab|kbd|kg|ki|kj|kk|kl|km|kn|ko|koi|kr|krc|ks|ksh|ku|kv|kw|ky|la|lad|lb|lbe|lg|li|lij|lmo|ln|lo|lt|ltg|lv|map-bms|mdf|mg|mh|mhr|mi|mk|ml|mn|mo|mr|mrj|ms|mt|mus|mwl|my|myv|mzn|na|nah|nap|nds|nds-nl|ne|new|ng|nl|nn|no|nov|nrm|nv|ny|oc|om|or|os|pa|pag|pam|pap|pcd|pdc|pfl|pi|pih|pl|pms|pnb|pnt|ps|pt|qu|rm|rmy|rn|ro|roa-rup|roa-tara|ru|rue|rw|sa|sah|sc|scn|sco|sd|se|sg|sh|si|simple|sk|sl|sm|sn|so|sq|sr|srn|ss|st|stq|su|sv|sw|szl|ta|te|tet|tg|th|ti|tk|tl|tn|to|tpi|tr|ts|tt|tum|tw|ty|udm|ug|uk|ur|uz|ve|vec|vi|vls|vo|wa|war|wo|wuu|xal|xh|yi|yo|za|zea|zh|zh-classical|zh-min-nan|zh-yue|zu";
pg.re.interwiki = new RegExp("^".concat(pg.wiki.interwiki, ":"));
} else {
pg.wiki.interwiki = null;
pg.re.interwiki = /^$/;
}
};
const nsRe = (namespaceId) => {
const imageNamespaceVariants = [];
for (var _i2 = 0, _Object$entries2 = Object.entries(mw.config.get("wgNamespaceIds")); _i2 < _Object$entries2.length; _i2++) {
const [_localizedNamespaceLc, _namespaceId] = _Object$entries2[_i2];
if (_namespaceId !== namespaceId) {
continue;
}
const localizedNamespaceLc = upcaseFirst(_localizedNamespaceLc);
imageNamespaceVariants.push(mw.util.escapeRegExp(localizedNamespaceLc).split(" ").join("[ _]"), mw.util.escapeRegExp(encodeURI(localizedNamespaceLc)));
}
return "(?:".concat(imageNamespaceVariants.join("|"), ")");
};
const nsReImage = () => {
return nsRe(pg.nsImageId);
};
const getEditboxSelection = () => {
let editbox;
try {
editbox = document.editform.wpTextbox1;
} catch {
return;
}
if (document.selection) {
return document.selection.createRange().text;
}
const selStart = editbox.selectionStart;
const selEnd = editbox.selectionEnd;
return editbox.value.substring(selStart, selEnd);
};
const doSelectionPopup = () => {
const sel = getEditboxSelection();
const open = sel.indexOf("[[");
const pipe = sel.indexOf("|");
const close = sel.indexOf("]]");
if (open === -1 || pipe === -1 && close === -1) {
return;
}
if (pipe !== -1 && open > pipe || close !== -1 && open > close) {
return;
}
const article = new Title(sel.substring(open + 2, pipe < 0 ? close : pipe));
if (getValueOf("popupOnEditSelection") === "boxpreview") {
return doSeparateSelectionPopup(sel, article);
}
if (close > 0 && sel.slice(Math.max(0, close + 2)).includes("[[")) {
return;
}
const a = document.createElement("a");
a.href = pg.wiki.titlebase + article.urlString();
mouseOverWikiLink2(a);
if (a.navpopup) {
a.navpopup.addHook(() => {
runStopPopupTimer(a.navpopup);
}, "unhide", "after");
}
};
const doSeparateSelectionPopup = (str, article) => {
let div = document.querySelector("#selectionPreview");
if (!div) {
div = document.createElement("div");
div.id = "selectionPreview";
try {
const box = document.editform.wpTextbox1;
box.parentNode.insertBefore(div, box);
} catch {
return;
}
}
const p = prepPreviewmaker(str, article, newNavpopup(document.createElement("a"), article));
p.makePreview();
if (p.html) {
div.innerHTML = p.html;
}
div.ranSetupTooltipsAlready = false;
popTipsSoonFn("selectionPreview")();
};
class Mousetracker {
constructor() {
this.loopDelay = 400;
this.timer = null;
this.active = false;
this.dirty = true;
this.hooks = [];
}
/**
* Adds a hook, to be called when we get events.
*
* @param {Function} f A function which is called as
* <code>f(x,y)</code>. It should return <code>true</code> when it
* wants to be removed, and <code>false</code> otherwise.
*/
addHook(f) {
this.hooks.push(f);
}
/**
* Runs hooks, passing them the x
* and y coords of the mouse. Hook functions that return true are
* passed to {@source Mousetracker#removeHooks} for removal.
*
* @private
*/
runHooks() {
if (!this.hooks || this.hooks.length === 0) {
return;
}
let remove = false;
const removeObj = {};
const {
x
} = this;
const {
y
} = this;
const len = this.hooks.length;
for (let i = 0; i < len; ++i) {
if (this.hooks[i](x, y) === true) {
remove = true;
removeObj[i] = true;
}
}
if (remove) {
this.removeHooks(removeObj);
}
}
/**
* Removes hooks.
*
* @private
* @param {Object} removeObj An object whose keys are the index
* numbers of functions for removal, with values that evaluate to true
*/
removeHooks(removeObj) {
const newHooks = [];
const len = this.hooks.length;
for (let i = 0; i < len; ++i) {
if (!removeObj[i]) {
newHooks.push(this.hooks[i]);
}
}
this.hooks = newHooks;
}
/**
* Event listener for mouse wiggles.
* We simply grab the event, set x and y and run the hooks.
* This makes the cpu all hot and bothered :-(
*
* @private
* @param {Event} e Mousemove event
*/
track(e) {
e || (e = window.event);
let x;
let y;
if (e) {
if (e.pageX) {
x = e.pageX;
y = e.pageY;
} else if (e.clientX === void 0) {
return;
} else {
let left;
let top;
const docElt = document.documentElement;
if (docElt) {
left = docElt.scrollLeft;
}
left || (left = document.querySelector("body").scrollLeft || document.scrollLeft || 0);
if (docElt) {
top = docElt.scrollTop;
}
top || (top = document.querySelector("body").scrollTop || document.scrollTop || 0);
x = e.clientX + left;
y = e.clientY + top;
}
this.setPosition(x, y);
}
}
/**
* Sets the x and y coordinates stored and takes appropriate action,
* running hooks as appropriate.
*
* @param {Integer} x, y Screen coordinates to set
* @param {number} x
* @param {number} y
*/
setPosition(x, y) {
this.x = x;
this.y = y;
if (this.dirty || this.hooks.length === 0) {
this.dirty = false;
return;
}
if (typeof this.lastHook_x !== "number") {
this.lastHook_x = -100;
this.lastHook_y = -100;
}
let diff2 = (this.lastHook_x - x) * (this.lastHook_y - y);
diff2 = diff2 >= 0 ? diff2 : -diff2;
if (diff2 > 1) {
this.lastHook_x = x;
this.lastHook_y = y;
if (this.dirty) {
this.dirty = false;
} else {
this.runHooks();
}
}
}
/**
* Sets things in motion, unless they are already that is, registering an event listener on
* <code>document.onmousemove</code>. A half-hearted attempt is made to preserve the old event
* listener if there is one.
*/
enable() {
if (this.active) {
return;
}
this.active = true;
this.savedListener = document.onmousemove;
const self = this;
document.onmousemove = (e) => {
self.track(e);
};
if (this.loopDelay) {
this.timer = setInterval(() => {
self.runHooks();
}, this.loopDelay);
}
}
/**
* Disables the tracker, removing the event listener.
*/
disable() {
if (!this.active) {
return;
}
if (typeof this.savedListener === "function") {
document.onmousemove = this.savedListener;
} else {
delete document.onmousemove;
}
if (this.timer) {
clearInterval(this.timer);
}
this.active = false;
}
}
class Navpopup {
constructor() {
this.uid = Navpopup.uid++;
this.visible = false;
this.noshow = false;
this.hooks = {
create: [],
unhide: [],
hide: []
};
this.hookIds = {};
this.downloads = [];
this.pending = null;
this.fuzz = 5;
this.constrained = true;
this.width = 0;
this.height = 0;
this.mainDiv = null;
this.createMainDiv();
}
/**
* Retrieves the {@source #visible} attribute, indicating whether the popup is currently visible.
*
* @type boolean
*/
isVisible() {
return this.visible;
}
/**
* Repositions popup using CSS style.
*
* @private
* @param {integer} x x-coordinate (px)
* @param {integer} y y-coordinate (px)
* @param {boolean} noLimitHor Don't call {@source #limitHorizontalPosition}
*/
reposition(x, y, noLimitHor) {
log("reposition(".concat(x, ",").concat(y, ",").concat(noLimitHor, ")"));
if (x !== void 0 && x !== null) {
this.left = x;
}
if (y !== void 0 && y !== null) {
this.top = y;
}
if (this.left !== void 0 && this.top !== void 0) {
this.mainDiv.style.left = "".concat(this.left, "px");
this.mainDiv.style.top = "".concat(this.top, "px");
}
if (!noLimitHor) {
this.limitHorizontalPosition();
}
}
/**
* Prevents popups from being in silly locations. Hopefully.
* Should not be run if {@source #constrained} is true.
*
* @private
*/
limitHorizontalPosition() {
if (!this.constrained || this.tooWide) {
return;
}
this.updateDimensions();
const x = this.left;
const w = this.width;
const cWidth = document.querySelector("body").clientWidth;
if (x + w >= cWidth || x > 0 && this.maxWidth && this.width < this.maxWidth && this.height > this.width && x > cWidth - this.maxWidth) {
this.mainDiv.style.left = "-10000px";
this.mainDiv.style.width = "".concat(this.maxWidth, "px");
const naturalWidth = Number.parseInt(this.mainDiv.offsetWidth, 10);
let newLeft = cWidth - naturalWidth - 1;
if (newLeft < 0) {
newLeft = 0;
this.tooWide = true;
}
log("limitHorizontalPosition: moving to (".concat(newLeft, ",").concat(this.top, "); naturalWidth=").concat(naturalWidth, ", clientWidth=").concat(cWidth));
this.reposition(newLeft, null, true);
}
}
/**
* Brings popup to the top of the z-order.
* We increment the {@source #highest} property of the contructor here.
*
* @private
*/
raise() {
this.mainDiv.style.zIndex = Navpopup.highest + 1;
++Navpopup.highest;
}
/**
* Shows the popup provided {@source #noshow} is not true.
* Updates the position, brings the popup to the top of the z-order and unhides it.
*/
show() {
if (this.noshow) {
return;
}
this.reposition();
this.raise();
this.unhide();
}
/**
* Checks to see if the mouse pointer has
* stabilised (checking every <code>time</code>/2 milliseconds) and runs the
* {@source #show} method if it has.
*
* @param {integer} time The minimum time (ms) before the popup may be shown.
*/
showSoonIfStable(time) {
log("showSoonIfStable, time=".concat(time));
if (this.visible) {
return;
}
this.noshow = false;
this.stable_x = -1e4;
this.stable_y = -1e4;
const stableShow = () => {
log("stableShow called");
const new_x = Navpopup.tracker.x;
const new_y = Navpopup.tracker.y;
const dx = self.stable_x - new_x;
const dy = self.stable_y - new_y;
const fuzz2 = 0;
if (dx * dx <= fuzz2 && dy * dy <= fuzz2) {
log("mouse is stable");
clearInterval(self.showSoonStableTimer);
self.reposition(new_x + 2, new_y + 2);
self.show();
self.limitHorizontalPosition();
return;
}
self.stable_x = new_x;
self.stable_y = new_y;
};
const self = this;
this.showSoonStableTimer = setInterval(stableShow, time / 2);
}
/**
* Sets the {@source #noshow} flag and hides the popup. This should be called
* when the mouse leaves the link before
* (or after) it's actually been displayed.
*/
banish() {
log("banish called");
this.noshow = true;
if (this.showSoonStableTimer) {
log("clearing showSoonStableTimer");
clearInterval(this.showSoonStableTimer);
}
this.hide();
}
/**
* Runs hooks added with {@source #addHook}.
*
* @private
* @param {string} key Key name of the {@source #hooks} array - one of 'create', 'unhide', 'hide'
* @param {string} when Controls exactly when the hook is run: either 'before' or 'after'
*/
runHooks(key, when) {
if (!this.hooks[key]) {
return;
}
const keyHooks = this.hooks[key];
const len = keyHooks.length;
for (let i = 0; i < len; ++i) {
if (keyHooks[i] && keyHooks[i].when === when && Reflect.apply(keyHooks[i].hook, this, [])) {
if (keyHooks[i].hookId) {
delete this.hookIds[keyHooks[i].hookId];
}
keyHooks[i] = null;
}
}
}
/**
* Adds a hook to the popup. Hook functions are run with <code>this</code> set to refer to the
* Navpopup instance, and no arguments.
*
* @param {Function} hook The hook function. Functions that return true are deleted.
* @param {string} key Key name of the {@source #hooks} array - one of 'create', 'unhide', 'hide'
* @param {string} when Controls exactly when the hook is run: either 'before' or 'after'
* @param {string} uid A truthy string identifying the hook function; if it matches another hook
* in this position, it won't be added again.
*/
addHook(hook, key, when, uid) {
when || (when = "after");
if (!this.hooks[key]) {
return;
}
let hookId;
if (uid) {
hookId = [key, when, uid].join("|");
if (this.hookIds[hookId]) {
return;
}
this.hookIds[hookId] = true;
}
this.hooks[key].push({
hook,
when,
hookId
});
}
/**
* Creates the main DIV element, which contains all the actual popup content.
* Runs hooks with key 'create'.
*
* @private
*/
createMainDiv() {
var _this$className;
if (this.mainDiv) {
return;
}
this.runHooks("create", "before");
const mainDiv = document.createElement("div");
const self = this;
mainDiv.onclick = (e) => {
self.onclickListener(e);
};
mainDiv.className = (_this$className = this.className) !== null && _this$className !== void 0 ? _this$className : "navpopup_maindiv";
mainDiv.id = mainDiv.className + this.uid;
mainDiv.style.position = "absolute";
mainDiv.style.minWidth = "350px";
mainDiv.style.display = "none";
mainDiv.className = "navpopup";
mainDiv.navpopup = this;
this.mainDiv = mainDiv;
document.querySelector("body").append(mainDiv);
this.runHooks("create", "after");
}
/**
* Calls the {@source #raise} method.
*
* @private
*/
onclickListener() {
this.raise();
}
/**
* Makes the popup draggable, using a {@source Drag} object.
*
* @param {string} handleName
* @private
*/
makeDraggable(handleName) {
if (!this.mainDiv) {
this.createMainDiv();
}
const drag = new Drag();
if (!handleName) {
drag.startCondition = (e) => {
try {
if (!e.shiftKey) {
return false;
}
} catch {
return false;
}
return true;
};
}
let dragHandle;
if (handleName) {
dragHandle = document.querySelector("#".concat(handleName));
}
dragHandle || (dragHandle = this.mainDiv);
const self = this;
drag.endHook = (x, y) => {
Navpopup.tracker.dirty = true;
self.reposition(x, y);
};
drag.init(dragHandle, this.mainDiv);
}
/**
* Hides the popup using CSS. Runs hooks with key 'hide'.
* Sets {@source #visible} appropriately.
* {@source #banish} should be called externally instead of this method.
*
* @private
*/
hide() {
this.runHooks("hide", "before");
this.abortDownloads();
if (this.visible !== void 0 && this.visible) {
this.mainDiv.style.display = "none";
this.visible = false;
}
this.runHooks("hide", "after");
}
/**
* Shows the popup using CSS. Runs hooks with key 'unhide'.
* Sets {@source #visible} appropriately. {@source #show} should be called externally instead of this method.
*
* @private
*/
unhide() {
this.runHooks("unhide", "before");
if (this.visible !== void 0 && !this.visible) {
this.mainDiv.style.display = "inline";
this.visible = true;
}
this.runHooks("unhide", "after");
}
/**
* Sets the <code>innerHTML</code> attribute of the main div containing the popup content.
*
* @param {string} html The HTML to set.
*/
setInnerHTML(html) {
this.mainDiv.innerHTML = html;
}
/**
* Updates the {@source #width} and {@source #height} attributes with the CSS properties.
*
* @private
*/
updateDimensions() {
this.width = Number.parseInt(this.mainDiv.offsetWidth, 10);
this.height = Number.parseInt(this.mainDiv.offsetHeight, 10);
}
/**
* Checks if the point (x,y) is within {@source #fuzz} of the
* {@source #mainDiv}.
*
* @param {integer} x x-coordinate (px)
* @param {integer} y y-coordinate (px)
* @type boolean
*/
isWithin(x, y) {
if (!this.visible) {
return false;
}
this.updateDimensions();
const fuzz = this.fuzz || 0;
return x + fuzz >= this.left && x - fuzz <= this.left + this.width && y + fuzz >= this.top && y - fuzz <= this.top + this.height;
}
/**
* Adds a download to {@source #downloads}.
*
* @param {Downloader} download
*/
addDownload(download) {
if (!download) {
return;
}
this.downloads.push(download);
}
/**
* Aborts the downloads listed in {@source #downloads}.
*
* @see Downloader#abort
*/
abortDownloads() {
var _iterator20 = _createForOfIteratorHelper(this.downloads), _step20;
try {
for (_iterator20.s(); !(_step20 = _iterator20.n()).done; ) {
const d = _step20.value;
if (d && d.abort) {
d.abort();
}
}
} catch (err) {
_iterator20.e(err);
} finally {
_iterator20.f();
}
this.downloads = [];
}
}
Navpopup.uid = 0;
Navpopup.highest = 1e3;
Navpopup.tracker = new Mousetracker();
const delFmt = (x) => {
if (x.length === 0) {
return "";
}
return "<del class='popupDiff'>".concat(x.join(""), "</del>");
};
const insFmt = (x) => {
if (x.length === 0) {
return "";
}
return "<ins class='popupDiff'>".concat(x.join(""), "</ins>");
};
const countCrossings = (a, b, i, eject) => {
if (!b[i].row && b[i].row !== 0) {
return -1;
}
let count = 0;
var _iterator21 = _createForOfIteratorHelper(a.entries()), _step21;
try {
for (_iterator21.s(); !(_step21 = _iterator21.n()).done; ) {
const [j, element] = _step21.value;
if (!element.row && element.row !== 0) {
continue;
}
if ((j - b[i].row) * (i - element.row) > 0) {
if (eject) {
return true;
}
count++;
}
}
} catch (err) {
_iterator21.e(err);
} finally {
_iterator21.f();
}
return count;
};
const shortenDiffString = function shortenDiffString2(str, context) {
const re = /(<del[\S\s]*?<\/del>|<ins[\S\s]*?<\/ins>)/;
const splitted = str.split(re);
let ret = [""];
for (let i = 0; i < splitted.length; i += 2) {
if (splitted[i].length < 2 * context) {
ret[ret.length - 1] += splitted[i];
if (i + 1 < splitted.length) {
ret[ret.length - 1] += splitted[i + 1];
}
continue;
} else {
if (i > 0) {
ret[ret.length - 1] += splitted[i].slice(0, Math.max(0, context));
}
if (i + 1 < splitted.length) {
ret.push(splitted[i].slice(Math.max(0, splitted[i].length - context)) + splitted[i + 1]);
}
}
}
while (ret.length > 0 && !ret[0]) {
ret = ret.slice(1);
}
return ret;
};
const diffString = (o, n) => {
let i;
const oSplitted = o.split(/\b/);
const nSplitted = n.split(/\b/);
for (i = 0; i < oSplitted.length; ++i) {
oSplitted[i] = oSplitted[i].entify();
}
for (i = 0; i < nSplitted.length; ++i) {
nSplitted[i] = nSplitted[i].entify();
}
const out = diff(oSplitted, nSplitted);
let str = "";
let acc = [];
let maxOutputPair = 0;
for (i = 0; i < out.n.length; ++i) {
if (out.n[i].paired) {
if (maxOutputPair > out.n[i].row) {
out.o[out.n[i].row] = out.o[out.n[i].row].text;
out.n[i] = out.n[i].text;
}
if (maxOutputPair < out.n[i].row) {
maxOutputPair = out.n[i].row;
}
}
}
for (i = 0; i < out.o.length && !out.o[i].paired; ++i) {
acc.push(out.o[i]);
}
str += delFmt(acc);
acc = [];
for (i = 0; i < out.n.length; ++i) {
while (i < out.n.length && !out.n[i].paired) {
acc.push(out.n[i++]);
}
str += insFmt(acc);
acc = [];
if (i < out.n.length) {
str += out.n[i].text;
let m = out.n[i].row + 1;
while (m < out.o.length && !out.o[m].paired) {
acc.push(out.o[m++]);
}
str += delFmt(acc);
acc = [];
}
}
return str;
};
const jsReservedProperties = new RegExp("^(constructor|prototype|__((define|lookup)[GS]etter)__|eval|hasOwnProperty|propertyIsEnumerable|to(Source|String|LocaleString)|(un)?watch|valueOf)$");
const diffBugAlert = function diffBugAlert2(word) {
if (!diffBugAlert2.list[word]) {
diffBugAlert2.list[word] = 1;
void mw.notify("Bad word: ".concat(word, "\n\nPlease report this bug."), {
tag: "popups",
type: "error"
});
}
};
diffBugAlert.list = {};
const makeDiffHashtable = (src) => {
const ret = {};
for (let i = 0; i < src.length; i++) {
var _src$i, _ret$_src$i;
if (jsReservedProperties.test(src[i])) {
src[i] += "<!-- -->";
}
(_ret$_src$i = ret[_src$i = src[i]]) !== null && _ret$_src$i !== void 0 ? _ret$_src$i : ret[_src$i] = [];
try {
ret[src[i]].push(i);
} catch {
diffBugAlert(src[i]);
}
}
return ret;
};
const diff = (o, n) => {
const ns = makeDiffHashtable(n);
const os = makeDiffHashtable(o);
let i;
for (i in ns) {
if (ns[i].length === 1 && os[i] && os[i].length === 1) {
n[ns[i][0]] = {
text: n[ns[i][0]],
row: os[i][0],
paired: true
};
o[os[i][0]] = {
text: o[os[i][0]],
row: ns[i][0],
paired: true
};
}
}
for (i = 0; i < n.length - 1; i++) {
if (n[i].paired && !n[i + 1].paired && n[i].row + 1 < o.length && !o[n[i].row + 1].paired && n[i + 1] === o[n[i].row + 1]) {
n[i + 1] = {
text: n[i + 1],
row: n[i].row + 1,
paired: true
};
o[n[i].row + 1] = {
text: o[n[i].row + 1],
row: i + 1,
paired: true
};
}
}
for (i = n.length - 1; i > 0; i--) {
if (n[i].paired && !n[i - 1].paired && n[i].row > 0 && !o[n[i].row - 1].paired && n[i - 1] === o[n[i].row - 1]) {
n[i - 1] = {
text: n[i - 1],
row: n[i].row - 1,
paired: true
};
o[n[i].row - 1] = {
text: o[n[i].row - 1],
row: i - 1,
paired: true
};
}
}
return {
o,
n
};
};
const setSiteInfo = () => {
if (window.popupLocalDebug) {
pg.wiki.hostname = "en.wikipedia.org";
} else {
pg.wiki.hostname = location.hostname;
}
pg.wiki.wikimedia = /(wiki([mp]edia|source|books|news|quote|versity|species|voyage|data)|metawiki|wiktionary|mediawiki)\.org/.test(pg.wiki.hostname);
pg.wiki.wikia = /\.wikia\.com$/i.test(pg.wiki.hostname);
pg.wiki.isLocal = pg.wiki.hostname.startsWith("localhost");
pg.wiki.commons = pg.wiki.wikimedia && pg.wiki.hostname !== "commons.wikimedia.org" ? "commons.wikimedia.org" : null;
pg.wiki.lang = mw.config.get("wgContentLanguage");
const port = location.port ? ":".concat(location.port) : "";
pg.wiki.sitebase = pg.wiki.hostname + port;
};
const setUserInfo = () => {
const params = {
action: "query",
list: "users",
ususers: mw.config.get("wgUserName"),
usprop: "rights"
};
pg.user.canReview = false;
if (getValueOf("popupReview")) {
getMwApi().get(params).done((data) => {
const [{
rights
}] = data.query.users;
pg.user.canReview = rights.includes("review");
});
}
};
const fetchSpecialPageNames = () => {
const params = {
action: "query",
format: "json",
formatversion: "2",
maxage: 3600,
meta: "siteinfo",
siprop: "specialpagealiases",
// cache for an hour
uselang: "content"
};
return getMwApi().get(params).then((data) => {
pg.wiki.specialpagealiases = data.query.specialpagealiases;
});
};
const setTitleBase = () => {
const protocol = window.popupLocalDebug ? "http:" : location.protocol;
pg.wiki.articlePath = mw.config.get("wgArticlePath").replace(/\/\$1/, "");
pg.wiki.botInterfacePath = mw.config.get("wgScript");
pg.wiki.APIPath = "".concat(mw.config.get("wgScriptPath"), "/api.php");
const titletail = "".concat(pg.wiki.botInterfacePath, "?title=");
pg.wiki.titlebase = "".concat(protocol, "//").concat(pg.wiki.sitebase).concat(titletail);
pg.wiki.wikibase = "".concat(protocol, "//").concat(pg.wiki.sitebase).concat(pg.wiki.botInterfacePath);
pg.wiki.apiwikibase = "".concat(protocol, "//").concat(pg.wiki.sitebase).concat(pg.wiki.APIPath);
pg.wiki.articlebase = "".concat(protocol, "//").concat(pg.wiki.sitebase).concat(pg.wiki.articlePath);
pg.wiki.commonsbase = "".concat(protocol, "//").concat(pg.wiki.commons).concat(pg.wiki.botInterfacePath);
pg.wiki.apicommonsbase = "".concat(protocol, "//").concat(pg.wiki.commons).concat(pg.wiki.APIPath);
pg.re.basenames = new RegExp("^(".concat(map(literalizeRegex, [pg.wiki.titlebase, pg.wiki.articlebase]).join("|"), ")"));
};
const setMainRegex = () => {
const reStart = "[^:]*://";
let preTitles = "".concat(literalizeRegex(mw.config.get("wgScriptPath")), "/(?:index[.]php|wiki[.]phtml)[?]title=");
preTitles += "|".concat(literalizeRegex("".concat(pg.wiki.articlePath, "/")));
const reEnd = "(".concat(preTitles, ")([^&?#]*)[^#]*(?:#(.+))?");
pg.re.main = new RegExp(reStart + literalizeRegex(pg.wiki.sitebase) + reEnd);
};
const buildSpecialPageGroup = (specialPageObj) => {
const variants = [];
variants.push(mw.util.escapeRegExp(specialPageObj.realname), mw.util.escapeRegExp(encodeURI(specialPageObj.realname)));
var _iterator22 = _createForOfIteratorHelper(specialPageObj.aliases), _step22;
try {
for (_iterator22.s(); !(_step22 = _iterator22.n()).done; ) {
const alias = _step22.value;
variants.push(mw.util.escapeRegExp(alias), mw.util.escapeRegExp(encodeURI(alias)));
}
} catch (err) {
_iterator22.e(err);
} finally {
_iterator22.f();
}
return variants.join("|");
};
const setRegexps = () => {
setMainRegex();
const sp = nsRe(pg.nsSpecialId);
pg.re.urlNoPopup = new RegExp("((title=|/)".concat(sp, "(?:%3A|:)|section=[0-9]|^#$)"));
var _iterator23 = _createForOfIteratorHelper(pg.wiki.specialpagealiases), _step23;
try {
for (_iterator23.s(); !(_step23 = _iterator23.n()).done; ) {
const specialpage = _step23.value;
switch (specialpage.realname) {
case "Contributions":
pg.re.contribs = new RegExp("(title=|/)".concat(sp, "(?:%3A|:)(?:").concat(buildSpecialPageGroup(specialpage), ")(&target=|/|/").concat(nsRe(pg.nsUserId), ":)(.*)"), "i");
break;
case "Diff":
pg.re.specialdiff = new RegExp("/".concat(sp, "(?:%3A|:)(?:").concat(buildSpecialPageGroup(specialpage), ")/([^?#]*)"), "i");
break;
case "Emailuser":
pg.re.email = new RegExp("(title=|/)".concat(sp, "(?:%3A|:)(?:").concat(buildSpecialPageGroup(specialpage), ")(&target=|/|/(?:").concat(nsRe(pg.nsUserId), ":)?)(.*)"), "i");
break;
case "Whatlinkshere":
pg.re.backlinks = new RegExp("(title=|/)".concat(sp, "(?:%3A|:)(?:").concat(buildSpecialPageGroup(specialpage), ")(&target=|/)([^&]*)"), "i");
break;
}
}
} catch (err) {
_iterator23.e(err);
} finally {
_iterator23.f();
}
const im = nsReImage();
pg.re.image = new RegExp("(^|\\[\\[)".concat(im, ": *([^|\\]]*[^|\\] ])").concat(String.raw(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["([^0-9]]*([0-9]+) *px)?|(?:\n *[|]?|[|]) *"], ["([^0-9\\]]*([0-9]+) *px)?|(?:\\n *[|]?|[|]) *"]))), "(").concat(getValueOf("popupImageVarsRegexp"), ") *= *(?:\\[\\[ *)?(?:").concat(im, ":)?").concat(String.raw(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["([^|]*?)(?:]])? *[|]? *\n"], ["([^|]*?)(?:\\]\\])? *[|]? *\\n"])))), "img");
pg.re.imageBracketCount = 6;
pg.re.category = new RegExp("\\[\\[".concat(nsRe(pg.nsCategoryId), ": *([^|\\]]*[^|\\] ]) *"), "i");
pg.re.categoryBracketCount = 1;
pg.re.ipUser = /^(?::(?::|(?::[\dA-Fa-f]{1,4}){1,7})|[\dA-Fa-f]{1,4}(?::[\dA-Fa-f]{1,4}){0,6}::|[\dA-Fa-f]{1,4}(?::[\dA-Fa-f]{1,4}){7})|(((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d))$/;
pg.re.stub = new RegExp(getValueOf("popupStubRegexp"), "im");
pg.re.disambig = new RegExp(getValueOf("popupDabRegexp"), "im");
pg.re.oldid = /[&?]oldid=([^&]*)/;
pg.re.diff = /[&?]diff=([^&]*)/;
};
const setupCache = () => {
pg.cache.pages = [];
};
const setMisc = () => {
pg.current.link = null;
pg.current.links = [];
pg.current.linksHash = {};
setupCache();
pg.timer.checkPopupPosition = null;
pg.counter.loop = 0;
pg.idNumber = 0;
pg.misc.decodeExtras = [
{
from: "%2C",
to: ","
},
{
from: "_",
to: " "
},
{
from: "%24",
to: "$"
},
{
from: "%26",
to: "&"
}
// no ,
];
};
const getMwApi = () => {
if (!pg.api.client) {
pg.api.userAgent = "Navigation popups/1.0";
pg.api.client = api;
}
return pg.api.client;
};
const setupPopups = function setupPopups2(callback) {
if (setupPopups2.completed) {
if (typeof callback === "function") {
callback();
}
return;
}
fetchSpecialPageNames().then(() => {
setupDebugging();
setSiteInfo();
setTitleBase();
setOptions();
setUserInfo();
setNamespaces();
setInterwiki();
setRegexps();
setRedirs();
setMisc();
setupLivePreview();
setupTooltips();
log("In setupPopups(), just called setupTooltips()");
Navpopup.tracker.enable();
setupPopups2.completed = true;
if (typeof callback === "function") {
callback();
}
});
};
const defaultNavlinkSpec = () => {
let str = "";
str += "<b><<mainlink|shortcut= >></b>";
if (getValueOf("popupLastEditLink")) {
str += "*<<lastEdit|shortcut=/>>|<<lastContrib>>|<<sinceMe>>if(oldid){|<<oldEdit>>|<<diffCur>>}";
}
str += "if(user){<br><<contribs|shortcut=c>>*<<userlog|shortcut=L|log>>";
str += "if(ipuser){*<<arin>>}if(wikimedia){*<<count|shortcut=#>>}";
str += "if(ipuser){}else{*<<email|shortcut=E>>}if(admin){*<<block|shortcut=b>>|<<blocklog|log>>}}";
const editstr = "<<edit|shortcut=e>>";
const editOldidStr = "if(oldid){<<editOld|shortcut=e>>|<<revert|shortcut=v|rv>>|<<edit|cur>>}else{".concat(editstr, "}");
const historystr = "<<history|shortcut=h>>|<<editors|shortcut=E|>>";
const watchstr = "<<unwatch|unwatchShort>>|<<watch|shortcut=w|watchThingy>>";
str += "<br>if(talk){".concat(editOldidStr, "|<<new|shortcut=+>>*").concat(historystr, "*").concat(watchstr, "*<b><<article|shortcut=a>></b>|<<editArticle|edit>>}else{").concat(
// not a talk page
editOldidStr,
"*"
).concat(historystr, "*").concat(watchstr, "*<b><<talk|shortcut=t>></b>|<<editTalk|edit>>|<<newTalk|shortcut=+|new>>}");
str += "<br><<whatLinksHere|shortcut=l>>*<<relatedChanges|shortcut=r>>*<<move|shortcut=m>>";
str += "if(admin){<br><<unprotect|unprotectShort>>|<<protect|shortcut=p>>|<<protectlog|log>>*<<undelete|undeleteShort>>|<<delete|shortcut=d>>|<<deletelog|log>>}";
return str;
};
const navLinksHTML = (article, _hint, params) => {
const str = '<span class="popupNavLinks">'.concat(defaultNavlinkSpec(), "</span>");
return navlinkStringToHTML(str, article, params);
};
const expandConditionalNavlinkString = function expandConditionalNavlinkString2(s, article, z, recursionCount) {
const {
oldid
} = z;
const {
rcid
} = z;
const {
diff: diff2
} = z;
if (typeof recursionCount !== "number") {
recursionCount = 0;
}
const conditionalSplitRegex = /(;?\s*if\s*\(\s*(\w*)\s*\)\s*{([^{}]*)}(\s*else\s*{([^{}]*?)}|))/i;
const splitted = s.split(conditionalSplitRegex);
const numParens = 5;
let [ret] = splitted;
for (let i = 1; i < splitted.length; i = i + numParens + 1) {
const testString = splitted[i + 2 - 1];
const trueString = splitted[i + 3 - 1];
let falseString = splitted[i + 5 - 1];
if (falseString === void 0 || !falseString) {
falseString = "";
}
let testResult;
switch (testString) {
case "user":
testResult = !!article.userName();
break;
case "talk":
testResult = !article.talkPage();
break;
case "admin":
testResult = !!getValueOf("popupAdminLinks");
break;
case "oldid":
testResult = !!(oldid !== void 0 && oldid);
break;
case "rcid":
testResult = !!(rcid !== void 0 && rcid);
break;
case "ipuser":
testResult = !!article.isIpUser();
break;
case "mainspace_en":
testResult = isInMainNamespace(article) && pg.wiki.hostname === "en.wikipedia.org";
break;
case "wikimedia":
testResult = !!pg.wiki.wikimedia;
break;
case "diff":
testResult = !!(diff2 !== void 0 && diff2);
break;
}
switch (testResult) {
case null:
ret += splitted[i];
break;
case true:
ret += trueString;
break;
case false:
ret += falseString;
break;
}
ret += splitted[i + numParens];
}
if (conditionalSplitRegex.test(ret) && recursionCount < 10) {
return expandConditionalNavlinkString2(ret, article, z, recursionCount + 1);
}
return ret;
};
const navlinkStringToArray = (s, article, params) => {
s = expandConditionalNavlinkString(s, article, params);
const splitted = s.split(/<<(.*?)>>/);
const ret = [];
var _iterator24 = _createForOfIteratorHelper(splitted.entries()), _step24;
try {
for (_iterator24.s(); !(_step24 = _iterator24.n()).done; ) {
const [i, element] = _step24.value;
if (i % 2) {
const t = new navlinkTag();
const ss = element.split("|");
[t.id] = ss;
for (let j = 1; j < ss.length; ++j) {
const sss = ss[j].split("=");
if (sss.length > 1) {
[, t[sss[0]]] = sss;
} else {
t.text = popupString(sss[0]);
}
}
t.article = article;
const {
oldid
} = params;
const {
rcid
} = params;
const {
diff: diff2
} = params;
if (oldid !== void 0 && oldid !== null) {
t.oldid = oldid;
}
if (rcid !== void 0 && rcid !== null) {
t.rcid = rcid;
}
if (diff2 !== void 0 && diff2 !== null) {
t.diff = diff2;
}
if (!t.text && t.id !== "mainlink") {
t.text = popupString(t.id);
}
ret.push(t);
} else {
ret.push(element);
}
}
} catch (err) {
_iterator24.e(err);
} finally {
_iterator24.f();
}
return ret;
};
const navlinkSubstituteHTML = (s) => {
return s.split("*").join(getValueOf("popupNavLinkSeparator")).split("<menurow>").join('<li class="popup_menu_row">').split("</menurow>").join("</li>").split("<menu>").join('<ul class="popup_menu">').split("</menu>").join("</ul>");
};
const navlinkDepth = (magic, s) => {
return s.split("<".concat(magic, ">")).length - s.split("</".concat(magic, ">")).length;
};
const navlinkStringToHTML = (s, article, params) => {
const p = navlinkStringToArray(s, article, params);
let html = "";
let menudepth = 0;
let menurowdepth = 0;
var _iterator25 = _createForOfIteratorHelper(p), _step25;
try {
for (_iterator25.s(); !(_step25 = _iterator25.n()).done; ) {
const element = _step25.value;
if (typeof element === "string") {
html += navlinkSubstituteHTML(element);
menudepth += navlinkDepth("menu", element);
menurowdepth += navlinkDepth("menurow", element);
} else if (element.type !== void 0 && element.type === "navlinkTag") {
html += menudepth > 0 && menurowdepth === 0 ? '<li class="popup_menu_item">'.concat(element.html(), "</li>") : element.html();
}
}
} catch (err) {
_iterator25.e(err);
} finally {
_iterator25.f();
}
return html;
};
class navlinkTag {
constructor() {
this.type = "navlinkTag";
}
html() {
this.getNewWin();
this.getPrintFunction();
let html = "";
let opening;
let closing;
const tagType = "span";
if (tagType) {
opening = "<".concat(tagType, ' class="popup_').concat(this.id, '">');
closing = "</".concat(tagType, ">");
} else {
opening = "";
closing = "";
}
if (typeof this.print === "function") {
html = this.print(this);
if (typeof html !== "string") {
html = "";
} else if (this.shortcut !== void 0) {
html = addPopupShortcut(html, this.shortcut);
}
} else {
errlog("Oh dear - invalid print function for a navlinkTag, id=".concat(this.id));
}
return opening + html + closing;
}
getNewWin() {
getValueOf("popupLinksNewWindow");
if (pg.option.popupLinksNewWindow[this.id] === void 0) {
this.newWin = null;
}
this.newWin = pg.option.popupLinksNewWindow[this.id];
}
getPrintFunction() {
if (typeof this.id !== "string" || typeof this.article !== typeof {}) {
return;
}
this.noPopup = 1;
switch (this.id) {
case "contribs":
case "history":
case "whatLinksHere":
case "userPage":
case "userTalk":
case "talk":
case "article":
case "lastEdit":
this.noPopup = null;
}
switch (this.id) {
case "email":
case "contribs":
case "block":
case "unblock":
case "userlog":
case "userSpace":
case "deletedContribs":
this.article = this.article.userName();
}
switch (this.id) {
case "userTalk":
case "newUserTalk":
case "editUserTalk":
case "userPage":
case "blocklog":
this.article = this.article.userName(true);
case "pagelog":
case "deletelog":
case "protectlog":
delete this.oldid;
}
if (this.id !== "mainlink") {
this.article = this.article.removeAnchor();
}
switch (this.id) {
case "undelete":
this.print = specialLink;
this.specialpage = "Undelete";
this.sep = "/";
break;
case "whatLinksHere":
this.print = specialLink;
this.specialpage = "Whatlinkshere";
break;
case "relatedChanges":
this.print = specialLink;
this.specialpage = "Recentchangeslinked";
break;
case "move":
this.print = specialLink;
this.specialpage = "Movepage";
break;
case "contribs":
this.print = specialLink;
this.specialpage = "Contributions";
break;
case "deletedContribs":
this.print = specialLink;
this.specialpage = "Deletedcontributions";
break;
case "email":
this.print = specialLink;
this.specialpage = "EmailUser";
this.sep = "/";
break;
case "block":
this.print = specialLink;
this.specialpage = "Blockip";
this.sep = "&ip=";
break;
case "unblock":
this.print = specialLink;
this.specialpage = "Ipblocklist";
this.sep = "&action=unblock&ip=";
break;
case "userlog":
this.print = specialLink;
this.specialpage = "Log";
this.sep = "&user=";
break;
case "blocklog":
this.print = specialLink;
this.specialpage = "Log";
this.sep = "&type=block&page=";
break;
case "pagelog":
this.print = specialLink;
this.specialpage = "Log";
this.sep = "&page=";
break;
case "protectlog":
this.print = specialLink;
this.specialpage = "Log";
this.sep = "&type=protect&page=";
break;
case "deletelog":
this.print = specialLink;
this.specialpage = "Log";
this.sep = "&type=delete&page=";
break;
case "userSpace":
this.print = specialLink;
this.specialpage = "PrefixIndex";
this.sep = "&namespace=2&prefix=";
break;
case "search":
this.print = specialLink;
this.specialpage = "Search";
this.sep = "&fulltext=Search&search=";
break;
case "thank":
this.print = specialLink;
this.specialpage = "Thanks";
this.sep = "/";
this.article.value = this.diff === "prev" ? this.oldid : this.diff;
break;
case "unwatch":
case "watch":
this.print = magicWatchLink;
this.action = "".concat(this.id, "&autowatchlist=1&autoimpl=").concat(popupString("autoedit_version"), "&actoken=").concat(autoClickToken());
break;
case "history":
case "historyfeed":
case "unprotect":
case "protect":
this.print = wikiLink;
this.action = this.id;
break;
case "delete":
this.print = wikiLink;
this.action = "delete";
if (this.article.namespaceId() === pg.nsImageId) {
const img = this.article.stripNamespace();
this.action += "&image=".concat(img);
}
break;
case "markpatrolled":
case "edit":
delete this.oldid;
case "view":
case "purge":
case "render":
this.print = wikiLink;
this.action = this.id;
break;
case "raw":
this.print = wikiLink;
this.action = "raw";
break;
case "new":
this.print = wikiLink;
this.action = "edit§ion=new";
break;
case "mainlink":
if (this.text === void 0) {
this.text = this.article.toString().entify();
}
if (getValueOf("popupSimplifyMainLink") && isInStrippableNamespace(this.article)) {
const s = this.text.split("/");
this.text = s.at(-1);
if (this.text === "" && s.length > 1) {
this.text = s.at(-2);
}
}
this.print = titledWikiLink;
if (this.title === void 0 && pg.current.link && pg.current.link.href !== void 0) {
var _pg$current$link$orig;
this.title = safeDecodeURI((_pg$current$link$orig = pg.current.link.originalTitle) !== null && _pg$current$link$orig !== void 0 ? _pg$current$link$orig : this.article);
if (this.oldid !== void 0 && this.oldid) {
this.title = tprintf("Revision %s of %s", [this.oldid, this.title]);
}
}
this.action = "view";
break;
case "userPage":
case "article":
case "editArticle":
delete this.oldid;
this.article = this.article.articleFromTalkOrArticle();
this.print = wikiLink;
this.action = this.id.indexOf("edit") === 0 ? "edit" : "view";
break;
case "userTalk":
case "talk":
this.article = this.article.talkPage();
delete this.oldid;
this.print = wikiLink;
this.action = "view";
break;
case "arin":
this.print = arinLink;
break;
case "count":
this.print = editCounterLink;
break;
case "editors":
this.print = editorListLink;
break;
case "lastEdit":
this.print = titledDiffLink;
this.title = popupString("Show the last edit");
this.from = "prev";
this.to = "cur";
break;
case "oldEdit":
this.print = titledDiffLink;
this.title = "".concat(popupString("Show the edit made to get revision"), " ").concat(this.oldid);
this.from = "prev";
this.to = this.oldid;
break;
case "editOld":
this.print = wikiLink;
this.action = "edit";
break;
case "undo":
this.print = wikiLink;
this.action = "edit&undo=";
break;
case "revert":
this.print = wikiLink;
this.action = "revert";
break;
case "nullEdit":
this.print = wikiLink;
this.action = "nullEdit";
break;
case "diffCur":
this.print = titledDiffLink;
this.title = tprintf("Show changes since revision %s", [this.oldid]);
this.from = this.oldid;
this.to = "cur";
break;
case "editUserTalk":
case "editTalk":
delete this.oldid;
this.article = this.article.talkPage();
this.action = "edit";
this.print = wikiLink;
break;
case "newUserTalk":
case "newTalk":
this.article = this.article.talkPage();
this.action = "edit§ion=new";
this.print = wikiLink;
break;
case "lastContrib":
case "sinceMe":
this.print = magicHistoryLink;
break;
case "togglePreviews":
this.text = popupString(pg.option.simplePopups ? "enable previews" : "disable previews");
case "disablePopups":
case "purgePopups":
this.print = popupMenuLink;
break;
default:
this.print = function() {
return "Unknown navlink type: ".concat(this.id);
};
}
}
}
const popupHandleKeypress = function popupHandleKeypress2(evt) {
var _evt$keyCode;
const keyCode = window.event ? window.event.keyCode : (_evt$keyCode = evt.keyCode) !== null && _evt$keyCode !== void 0 ? _evt$keyCode : evt.which;
if (!keyCode || !pg.current.link || !pg.current.link.navpopup) {
return;
}
if (keyCode === 27) {
killPopup();
return false;
}
const letter = String.fromCodePoint(keyCode);
const links = pg.current.link.navpopup.mainDiv.querySelectorAll("A");
let startLink = 0;
let i;
let j;
if (popupHandleKeypress2.lastPopupLinkSelected) {
for (i = 0; i < links.length; ++i) {
if (links[i] === popupHandleKeypress2.lastPopupLinkSelected) {
startLink = i;
}
}
}
for (j = 0; j < links.length; ++j) {
i = (startLink + j + 1) % links.length;
if (links[i].getAttribute("popupkey") === letter) {
if (evt && evt.preventDefault) {
evt.preventDefault();
}
links[i].focus();
popupHandleKeypress2.lastPopupLinkSelected = links[i];
return false;
}
}
if (document.oldPopupOnkeypress) {
return document.oldPopupOnkeypress(evt);
}
return true;
};
const addPopupShortcuts = () => {
if (document.onkeypress !== popupHandleKeypress) {
document.oldPopupOnkeypress = document.onkeypress;
}
document.onkeypress = popupHandleKeypress;
};
const rmPopupShortcuts = () => {
popupHandleKeypress.lastPopupLinkSelected = null;
try {
if (document.oldPopupOnkeypress && document.oldPopupOnkeypress === popupHandleKeypress) {
document.onkeypress = null;
return;
}
document.onkeypress = document.oldPopupOnkeypress;
} catch {
}
};
const addLinkProperty = (html, property) => {
const i = html.indexOf(">");
if (i < 0) {
return html;
}
return "".concat(html.slice(0, Math.max(0, i)), " ").concat(property).concat(html.slice(Math.max(0, i)));
};
const addPopupShortcut = (html, key) => {
if (!getValueOf("popupShortcutKeys")) {
return html;
}
const ret = addLinkProperty(html, 'popupkey="'.concat(key, '"'));
if (key === " ") {
key = popupString("spacebar");
}
return ret.replace(/^(.*?)(title=")(.*?)(".*)$/i, "$1$2$3 [".concat(key, "]$4"));
};
const loadDiff = (article, oldid, diff2, navpop) => {
navpop.diffData = {
oldRev: {},
newRev: {}
};
const api2 = getMwApi();
const params = {
action: "compare",
prop: ["ids", "title"]
};
if (article.title) {
params.fromtitle = article.title;
}
switch (diff2) {
case "cur":
switch (oldid) {
case null:
case "":
case "prev":
params.torelative = "prev";
break;
default:
params.fromrev = oldid;
params.torelative = "cur";
break;
}
break;
case "prev":
if (oldid) {
params.fromrev = oldid;
}
params.torelative = "prev";
break;
case "next":
params.fromrev = oldid || 0;
params.torelative = "next";
break;
default:
params.fromrev = oldid || 0;
params.torev = diff2 || 0;
break;
}
api2.get(params).then((data) => {
navpop.diffData.oldRev.revid = data.compare.fromrevid;
navpop.diffData.newRev.revid = data.compare.torevid;
addReviewLink(navpop, "popupMiscTools");
const go = () => {
pendingNavpopTask(navpop);
let url = "".concat(pg.wiki.apiwikibase, "?format=json&formatversion=2&action=query&");
url += "revids=".concat(navpop.diffData.oldRev.revid, "|").concat(navpop.diffData.newRev.revid);
url += "&prop=revisions&rvprop=ids|timestamp|content";
getPageWithCaching(url, doneDiff, navpop);
return true;
};
if (navpop.visible || !getValueOf("popupLazyDownloads")) {
go();
} else {
navpop.addHook(go, "unhide", "before", "DOWNLOAD_DIFFS");
}
});
};
const addReviewLink = (navpop, target) => {
if (!pg.user.canReview) {
return;
}
if (navpop.diffData.newRev.revid <= navpop.diffData.oldRev.revid) {
return;
}
const params = {
action: "query",
format: "json",
formatversion: "2",
prop: ["info", "flagged"],
revids: navpop.diffData.oldRev.revid
};
getMwApi().get(params).then((data) => {
const stable_revid = data.query.pages[0].flagged && data.query.pages[0].flagged.stable_revid || 0;
if (stable_revid === navpop.diffData.oldRev.revid) {
const a = document.createElement("a");
a.innerHTML = popupString("mark patrolled");
a.title = popupString("markpatrolledHint");
a.onclick = () => {
const params2 = {
action: "review",
comment: tprintf("defaultpopupReviewedSummary", [navpop.diffData.oldRev.revid, navpop.diffData.newRev.revid]),
revid: navpop.diffData.newRev.revid
};
getMwApi().postWithToken("csrf", params2).done(() => {
a.style.display = "none";
}).fail(() => {
void mw.notify(popupString("Could not marked this edit as patrolled"), {
tag: "popups",
type: "error"
});
});
};
setPopupHTML(a, target, navpop.idNumber, null, true);
}
});
};
const doneDiff = (download) => {
if (!download.owner || !download.owner.diffData) {
return;
}
const navpop = download.owner;
completedNavpopTask(navpop);
let pages;
let revisions = [];
try {
({
pages
} = getJsObj(download.data).query);
var _iterator26 = _createForOfIteratorHelper(pages), _step26;
try {
for (_iterator26.s(); !(_step26 = _iterator26.n()).done; ) {
const page = _step26.value;
revisions = [...revisions, ...page.revisions];
}
} catch (err) {
_iterator26.e(err);
} finally {
_iterator26.f();
}
for (var _i3 = 0, _revisions = revisions; _i3 < _revisions.length; _i3++) {
const revision = _revisions[_i3];
if (revision.revid === navpop.diffData.oldRev.revid) {
navpop.diffData.oldRev.revision = revision;
} else if (revision.revid === navpop.diffData.newRev.revid) {
navpop.diffData.newRev.revision = revision;
}
}
} catch {
errlog("Could not get diff");
}
insertDiff(navpop);
};
const rmBoringLines = (a, b, context) => {
if (context === void 0) {
context = 2;
}
const aa = [];
const aaa = [];
const bb = [];
const bbb = [];
let i;
let j;
for (i = 0; i < a.length; ++i) {
if (!a[i].paired) {
aa[i] = 1;
} else if (countCrossings(b, a, i, true)) {
aa[i] = 1;
bb[a[i].row] = 1;
}
}
for (i = 0; i < b.length; ++i) {
if (bb[i] === 1) {
continue;
}
if (!b[i].paired) {
bb[i] = 1;
}
}
for (i = 0; i < b.length; ++i) {
if (bb[i] === 1) {
for (j = Math.max(0, i - context); j < Math.min(b.length, i + context); ++j) {
if (!bb[j]) {
bb[j] = 1;
aa[b[j].row] = 0.5;
}
}
}
}
for (i = 0; i < a.length; ++i) {
if (aa[i] === 1) {
for (j = Math.max(0, i - context); j < Math.min(a.length, i + context); ++j) {
if (!aa[j]) {
aa[j] = 1;
bb[a[j].row] = 0.5;
}
}
}
}
for (i = 0; i < bb.length; ++i) {
if (bb[i] > 0) {
if (b[i].paired) {
bbb.push(b[i].text);
} else {
bbb.push(b[i]);
}
}
}
for (i = 0; i < aa.length; ++i) {
if (aa[i] > 0) {
if (a[i].paired) {
aaa.push(a[i].text);
} else {
aaa.push(a[i]);
}
}
}
return {
a: aaa,
b: bbb
};
};
const stripOuterCommonLines = (a, b, context) => {
let i = 0;
while (i < a.length && i < b.length && a[i] === b[i]) {
++i;
}
let j = a.length - 1;
let k = b.length - 1;
while (j >= 0 && k >= 0 && a[j] === b[k]) {
--j;
--k;
}
return {
a: a.slice(Math.max(0, i - 1 - context), Math.min(a.length + 1, j + context + 1)),
b: b.slice(Math.max(0, i - 1 - context), Math.min(b.length + 1, k + context + 1))
};
};
const insertDiff = (navpop) => {
let oldlines = navpop.diffData.oldRev.revision.content.split("\n");
let newlines = navpop.diffData.newRev.revision.content.split("\n");
let inner = stripOuterCommonLines(oldlines, newlines, getValueOf("popupDiffContextLines"));
oldlines = inner.a;
newlines = inner.b;
let truncated = false;
getValueOf("popupDiffMaxLines");
if (oldlines.length > pg.option.popupDiffMaxLines || newlines.length > pg.option.popupDiffMaxLines) {
truncated = true;
inner = stripOuterCommonLines(oldlines.slice(0, pg.option.popupDiffMaxLines), newlines.slice(0, pg.option.popupDiffMaxLines), pg.option.popupDiffContextLines);
oldlines = inner.a;
newlines = inner.b;
}
const lineDiff = diff(oldlines, newlines);
const lines2 = rmBoringLines(lineDiff.o, lineDiff.n);
const oldlines2 = lines2.a;
const newlines2 = lines2.b;
let html = "<hr>";
if (getValueOf("popupDiffDates")) {
html += diffDatesTable(navpop);
html += "<hr>";
}
html += shortenDiffString(diffString(oldlines2.join("\n"), newlines2.join("\n")), getValueOf("popupDiffContextCharacters")).join("<hr>");
setPopupTipsAndHTML(html.split("\n").join("<br>") + (truncated ? "<hr><b>".concat(popupString("Diff truncated for performance reasons"), "</b>") : ""), "popupPreview", navpop.idNumber);
};
const diffDatesTable = (navpop) => {
let html = '<table class="popup_diff_dates">';
html += diffDatesTableRow(navpop.diffData.newRev.revision, tprintf("New revision"));
html += diffDatesTableRow(navpop.diffData.oldRev.revision, tprintf("Old revision"));
html += "</table>";
return html;
};
const diffDatesTableRow = (revision, label) => {
let txt = "";
const lastModifiedDate = new Date(revision.timestamp);
txt = formattedDateTime(lastModifiedDate);
const revlink = generalLink({
url: "".concat(mw.config.get("wgScript"), "?oldid=").concat(revision.revid),
text: label,
title: label
});
return simplePrintf("<tr><td>%s</td><td>%s</td></tr>", [revlink, txt]);
};
const titledDiffLink = (l) => {
return titledWikiLink({
article: l.article,
action: "".concat(l.to, "&oldid=").concat(l.from),
newWin: l.newWin,
noPopup: l.noPopup,
text: l.text,
title: l.title,
/* hack: no oldid here */
actionName: "diff"
});
};
const wikiLink = (l) => {
if (!(typeof l.article === typeof {} && typeof l.action === "string" && typeof l.text === "string")) {
return null;
}
if (l.oldid === void 0) {
l.oldid = null;
}
const savedOldid = l.oldid;
if (!/^(edit|view|revert|render)$|^raw/.test(l.action)) {
l.oldid = null;
}
let hint = popupString("".concat(l.action, "Hint"));
const oldidData = [l.oldid, safeDecodeURI(l.article)];
let revisionString = tprintf("revision %s of %s", oldidData);
log("revisionString=".concat(revisionString));
switch (l.action) {
case "edit§ion=new":
hint = popupString("newSectionHint");
break;
case "edit&undo=":
if (l.diff && l.diff !== "prev" && savedOldid) {
l.action += "".concat(l.diff, "&undoafter=").concat(savedOldid);
} else if (savedOldid) {
l.action += savedOldid;
}
hint = popupString("undoHint");
break;
case "raw&ctype=text/css":
hint = popupString("rawHint");
break;
case "revert": {
const p = parseParams(pg.current.link.href);
l.action = "edit&autoclick=wpSave&actoken=".concat(autoClickToken(), "&autoimpl=").concat(popupString("autoedit_version"), "&autosummary=").concat(revertSummary(l.oldid, p.diff));
if (p.diff === "prev") {
l.action += "&direction=prev";
revisionString = tprintf("the revision prior to revision %s of %s", oldidData);
}
if (getValueOf("popupRevertSummaryPrompt")) {
l.action += "&autosummaryprompt=true";
}
if (getValueOf("popupMinorReverts")) {
l.action += "&autominor=true";
}
log("revisionString is now ".concat(revisionString));
break;
}
case "nullEdit":
l.action = "edit&autoclick=wpSave&actoken=".concat(autoClickToken(), "&autoimpl=").concat(popupString("autoedit_version"), "&autosummary=null");
break;
case "historyfeed":
l.action = "history&feed=rss";
break;
case "markpatrolled":
l.action = "markpatrolled&rcid=".concat(l.rcid);
}
if (hint) {
hint = l.oldid ? simplePrintf(hint, [revisionString]) : simplePrintf(hint, [safeDecodeURI(l.article)]);
} else {
hint = safeDecodeURI("".concat(l.article, "&action=").concat(l.action)) + l.oldid ? "&oldid=".concat(l.oldid) : "";
}
return titledWikiLink({
article: l.article,
action: l.action,
text: l.text,
newWin: l.newWin,
title: hint,
oldid: l.oldid,
noPopup: l.noPopup,
onclick: l.onclick
});
};
const revertSummary = (oldid, diff2) => {
let ret = "";
ret = diff2 === "prev" ? getValueOf("popupQueriedRevertToPreviousSummary") : getValueOf("popupQueriedRevertSummary");
return "".concat(ret, "&autorv=").concat(oldid);
};
const titledWikiLink = (l) => {
if (l.article === void 0 || l.action === void 0) {
errlog("got undefined article or action in titledWikiLink");
return null;
}
const base = pg.wiki.titlebase + l.article.urlString();
let url = base;
if (l.actionName === void 0 || !l.actionName) {
l.actionName = "action";
}
if (l.action !== "view") {
url = "".concat(base, "&").concat(l.actionName, "=").concat(l.action);
}
if (l.oldid !== void 0 && l.oldid) {
url += "&oldid=".concat(l.oldid);
}
let cssClass = pg.misc.defaultNavlinkClassname;
if (l.className !== void 0 && l.className) {
cssClass = l.className;
}
return generalNavLink({
url,
newWin: l.newWin,
title: l.title === void 0 ? null : l.title,
text: l.text === void 0 ? null : l.text,
className: cssClass,
noPopup: l.noPopup,
onclick: l.onclick
});
};
pg.fn.getLastContrib = (wikipage, newWin) => {
getHistoryInfo(wikipage, (x) => {
processLastContribInfo(x, {
page: wikipage,
newWin
});
});
};
const processLastContribInfo = (info, stuff) => {
if (!info.edits || info.edits.length === 0) {
void mw.notify("Popups: an odd thing happened. Please retry.", {
tag: "popups",
type: "error"
});
return;
}
if (!info.firstNewEditor) {
void mw.notify(tprintf("Only found one editor: %s made %s edits", [info.edits[0].editor, info.edits.length]), {
tag: "popups",
type: "error"
});
return;
}
const newUrl = "".concat(pg.wiki.titlebase + new Title(stuff.page).urlString(), "&diff=cur&oldid=").concat(info.firstNewEditor.oldid);
displayUrl(newUrl, stuff.newWin);
};
pg.fn.getDiffSinceMyEdit = (wikipage, newWin) => {
getHistoryInfo(wikipage, (x) => {
processDiffSinceMyEdit(x, {
page: wikipage,
newWin
});
});
};
const processDiffSinceMyEdit = (info, stuff) => {
if (!info.edits || info.edits.length === 0) {
void mw.notify("Popups: something fishy happened. Please try again.", {
tag: "popups",
type: "error"
});
return;
}
const friendlyName = stuff.page.split("_").join(" ");
if (!info.myLastEdit) {
void mw.notify(tprintf("Couldn't find an edit by %s\nin the last %s edits to\n%s", [info.userName, getValueOf("popupHistoryLimit"), friendlyName]), {
tag: "popups",
type: "error"
});
return;
}
if (info.myLastEdit.index === 0) {
void mw.notify(tprintf("%s seems to be the last editor to the page %s", [info.userName, friendlyName]), {
type: "error"
});
return;
}
const newUrl = "".concat(pg.wiki.titlebase + new Title(stuff.page).urlString(), "&diff=cur&oldid=").concat(info.myLastEdit.oldid);
displayUrl(newUrl, stuff.newWin);
};
const displayUrl = (url, newWin) => {
if (newWin) {
window.open(url);
} else {
document.location = url;
}
};
pg.fn.purgePopups = () => {
processAllPopups(true);
setupCache();
pg.option = {};
abortAllDownloads();
};
const processAllPopups = (nullify, banish) => {
for (let i = 0; pg.current.links && i < pg.current.links.length; ++i) {
if (!pg.current.links[i].navpopup) {
continue;
}
if (nullify || banish) {
pg.current.links[i].navpopup.banish();
}
pg.current.links[i].simpleNoMore = false;
if (nullify) {
pg.current.links[i].navpopup = null;
}
}
};
pg.fn.disablePopups = () => {
processAllPopups(false, true);
setupTooltips(null, true);
};
pg.fn.togglePreviews = () => {
processAllPopups(true, true);
pg.option.simplePopups = !pg.option.simplePopups;
abortAllDownloads();
};
const magicWatchLink = function magicWatchLink2(l) {
l.onclick = simplePrintf("pg.fn.modifyWatchlist('%s','%s');return false;", [l.article.toString(true).split("\\").join("\\\\").split("'").join(String.raw(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["'"], ["\\'"])))), this.id]);
return wikiLink(l);
};
pg.fn.modifyWatchlist = /* @__PURE__ */ function() {
var _ref = _asyncToGenerator(function* (title, action) {
const reqData = {
action: "watch",
formatversion: "2",
titles: title,
uselang: mw.config.get("wgUserLanguage")
};
if (action === "unwatch") {
reqData.unwatch = true;
}
const mwTitle = mw.Title.newFromText(title);
let messageName;
if (mwTitle && mwTitle.getNamespaceId() > 0 && mwTitle.getNamespaceId() % 2 === 1) {
messageName = action === "watch" ? "addedwatchtext-talk" : "removedwatchtext-talk";
} else {
messageName = action === "watch" ? "addedwatchtext" : "removedwatchtext";
}
yield getMwApi().postWithToken("watch", reqData);
yield getMwApi().loadMessagesIfMissing([messageName]);
void mw.notify(mw.message(messageName, title).parseDom(), {
tag: "popups"
});
});
return function(_x2, _x3) {
return _ref.apply(this, arguments);
};
}();
const magicHistoryLink = (l) => {
let jsUrl = "";
let title = "";
let onClick = "";
switch (l.id) {
case "lastContrib":
onClick = simplePrintf("pg.fn.getLastContrib('%s',%s)", [l.article.toString(true).split("\\").join("\\\\").split("'").join(String.raw(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["'"], ["\\'"])))), l.newWin]);
title = popupString("lastContribHint");
break;
case "sinceMe":
onClick = simplePrintf("pg.fn.getDiffSinceMyEdit('%s',%s)", [l.article.toString(true).split("\\").join("\\\\").split("'").join(String.raw(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["'"], ["\\'"])))), l.newWin]);
title = popupString("sinceMeHint");
break;
}
jsUrl = "javascript:".concat(onClick);
onClick += ";return false;";
return generalNavLink({
url: jsUrl,
newWin: false,
title,
text: l.text,
noPopup: l.noPopup,
onclick: onClick
});
};
const popupMenuLink = (l) => {
const jsUrl = simplePrintf("javascript:pg.fn.%s()", [l.id]);
const title = popupString(simplePrintf("%sHint", [l.id]));
const onClick = simplePrintf("pg.fn.%s();return false;", [l.id]);
return generalNavLink({
url: jsUrl,
newWin: false,
title,
text: l.text,
noPopup: l.noPopup,
onclick: onClick
});
};
const specialLink = (l) => {
var _l$sep;
if (l.specialpage === void 0 || !l.specialpage) {
return null;
}
const base = "".concat(pg.wiki.titlebase + mw.config.get("wgFormattedNamespaces")[pg.nsSpecialId], ":").concat(l.specialpage);
(_l$sep = l.sep) !== null && _l$sep !== void 0 ? _l$sep : l.sep = "&target=";
let article = l.article.urlString({
keepSpaces: l.specialpage === "Search"
});
let hint = popupString("".concat(l.specialpage, "Hint"));
switch (l.specialpage) {
case "Log":
switch (l.sep) {
case "&user=":
hint = popupString("userLogHint");
break;
case "&type=block&page=":
hint = popupString("blockLogHint");
break;
case "&page=":
hint = popupString("pageLogHint");
break;
case "&type=protect&page=":
hint = popupString("protectLogHint");
break;
case "&type=delete&page=":
hint = popupString("deleteLogHint");
break;
default:
log("Unknown log type, sep=".concat(l.sep));
hint = "Missing hint (FIXME)";
}
break;
case "PrefixIndex":
article += "/";
break;
}
hint = hint ? simplePrintf(hint, [safeDecodeURI(l.article)]) : safeDecodeURI("".concat(l.specialpage, ":").concat(l.article));
const url = base + l.sep + article;
return generalNavLink({
url,
title: hint,
text: l.text,
newWin: l.newWin,
noPopup: l.noPopup
});
};
const generalLink = (l) => {
if (l.url === void 0) {
return null;
}
const url = l.url.split('"').join("%22");
let ret = '<a href="'.concat(url, '"');
if (l.title !== void 0 && l.title) {
ret += ' title="'.concat(pg.escapeQuotesHTML(l.title), '"');
}
if (l.onclick !== void 0 && l.onclick) {
ret += ' onclick="'.concat(pg.escapeQuotesHTML(l.onclick), '"');
}
if (l.noPopup) {
ret += " noPopup=1";
}
let newWin;
if (l.newWin === void 0 || l.newWin === null) {
newWin = getValueOf("popupNewWindows");
} else {
({
newWin
} = l);
}
if (newWin) {
ret += ' rel="noopener" target="_blank"';
}
if (l.className !== void 0 && l.className) {
ret += ' class="'.concat(l.className, '"');
}
ret += ">";
if (typeof l.text === "string") {
ret += pg.escapeQuotesHTML(pg.unescapeQuotesHTML(l.text));
}
ret += "</a>";
return ret;
};
const appendParamsToLink = (linkstr, params) => {
const sp = linkstr.split(/(href="[^"]+?)"/i);
if (sp.length < 2) {
return null;
}
let ret = sp.shift() + sp.shift();
ret += "&".concat(params, '"');
ret += sp.join("");
return ret;
};
const changeLinkTargetLink = (x) => {
if (x.newTarget) {
log("changeLinkTargetLink: newTarget=".concat(x.newTarget));
}
if (x.oldTarget !== decodeURIComponent(x.oldTarget)) {
log("This might be an input problem: ".concat(x.oldTarget));
}
const cA = mw.util.escapeRegExp(x.oldTarget);
let chs = cA.charAt(0).toUpperCase();
chs = "[".concat(chs).concat(chs.toLowerCase(), "]");
let currentArticleRegexBit = chs + cA.slice(1);
currentArticleRegexBit = currentArticleRegexBit.split(/[ _]+|%20/g).join("(?:[_ ]+|%20)").split(String.raw(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["("], ["\\("])))).join(String.raw(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["(?:%28|()"], ["(?:%28|\\()"])))).split(String.raw(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral([")"], ["\\)"])))).join(String.raw(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["(?:%29|))"], ["(?:%29|\\))"]))));
currentArticleRegexBit = "\\s*(".concat(currentArticleRegexBit, "(?:#[^\\[\\|]*)?)\\s*");
const title = x.title || mw.config.get("wgPageName").split("_").join(" ");
const lk = titledWikiLink({
article: new Title(title),
newWin: x.newWin,
action: "edit",
text: x.text,
title: x.hint,
className: "popup_change_title_link"
});
let cmd = "";
if (x.newTarget) {
const t = x.newTarget;
const s = mw.util.escapeRegExp(x.newTarget);
if (x.alsoChangeLabel) {
cmd += "s~\\[\\[".concat(currentArticleRegexBit, "\\]\\]~[[").concat(t, "]]~g;");
cmd += "s~\\[\\[".concat(currentArticleRegexBit, "[|]~[[").concat(t, "|~g;");
cmd += "s~\\[\\[".concat(s, "\\|").concat(s, "\\]\\]~[[").concat(t, "]]~g");
} else {
cmd += "s~\\[\\[".concat(currentArticleRegexBit, "\\]\\]~[[").concat(t, "|$1]]~g;");
cmd += "s~\\[\\[".concat(currentArticleRegexBit, "[|]~[[").concat(t, "|~g;");
cmd += "s~\\[\\[".concat(s, "\\|").concat(s, "\\]\\]~[[").concat(t, "]]~g");
}
} else {
cmd += "s~\\[\\[".concat(currentArticleRegexBit, "\\]\\]~$1~g;");
cmd += "s~\\[\\[".concat(currentArticleRegexBit, "[|](.*?)\\]\\]~$2~g");
}
cmd = "autoedit=".concat(encodeURIComponent(cmd));
cmd += "&autoclick=".concat(encodeURIComponent(x.clickButton), "&actoken=").concat(encodeURIComponent(autoClickToken()));
cmd += x.minor === null ? "" : "&autominor=".concat(encodeURIComponent(x.minor));
cmd += x.watch === null ? "" : "&autowatch=".concat(encodeURIComponent(x.watch));
cmd += "&autosummary=".concat(encodeURIComponent(x.summary));
cmd += "&autoimpl=".concat(encodeURIComponent(popupString("autoedit_version")));
return appendParamsToLink(lk, cmd);
};
const redirLink = (redirMatch, article) => {
let ret = "";
if (getValueOf("popupAppendRedirNavLinks") && getValueOf("popupNavLinks")) {
ret += "<hr>";
if (getValueOf("popupFixRedirs") && autoEdit !== void 0 && autoEdit) {
ret += popupString("Redirects to: (Fix ");
log("redirLink: newTarget=".concat(redirMatch));
ret += addPopupShortcut(changeLinkTargetLink({
newTarget: redirMatch,
text: popupString("target"),
hint: popupString("Fix this redirect, changing just the link target"),
summary: simplePrintf(getValueOf("popupFixRedirsSummary"), [article.toString(), redirMatch]),
oldTarget: article.toString(),
clickButton: getValueOf("popupRedirAutoClick"),
minor: true,
watch: getValueOf("popupWatchRedirredPages")
}), "R");
ret += popupString(" or ");
ret += addPopupShortcut(changeLinkTargetLink({
newTarget: redirMatch,
text: popupString("target & label"),
hint: popupString("Fix this redirect, changing the link target and label"),
summary: simplePrintf(getValueOf("popupFixRedirsSummary"), [article.toString(), redirMatch]),
oldTarget: article.toString(),
clickButton: getValueOf("popupRedirAutoClick"),
minor: true,
watch: getValueOf("popupWatchRedirredPages"),
alsoChangeLabel: true
}), "R");
ret += popupString(")");
} else {
ret += popupString("Redirects") + popupString(" to ");
}
return ret;
}
return "<br> ".concat(popupString("Redirects")).concat(popupString(" to ")).concat(titledWikiLink({
article: new Title().fromWikiText(redirMatch),
action: "view",
text: safeDecodeURI(redirMatch),
title: popupString("Bypass redirect")
}));
};
const arinLink = (l) => {
if (!saneLinkCheck(l)) {
return null;
}
if (!l.article.isIpUser() || !pg.wiki.wikimedia) {
return null;
}
const uN = l.article.userName();
return generalNavLink({
url: "http://ws.arin.net/cgi-bin/whois.pl?queryinput=".concat(encodeURIComponent(uN)),
newWin: l.newWin,
title: tprintf("Look up %s in ARIN whois database", [uN]),
text: l.text,
noPopup: 1
});
};
const toolDbName = (cookieStyle) => {
let ret = mw.config.get("wgDBname");
if (!cookieStyle) {
ret += "_p";
}
return ret;
};
const saneLinkCheck = (l) => {
if (typeof l.article !== typeof {} || typeof l.text !== "string") {
return false;
}
return true;
};
const editCounterLink = (l) => {
if (!saneLinkCheck(l)) {
return null;
}
if (!pg.wiki.wikimedia) {
return null;
}
const uN = l.article.userName();
const tool = getValueOf("popupEditCounterTool");
let url;
const defaultToolUrl = "//tools.wmflabs.org/supercount/index.php?user=$1&project=$2.$3";
switch (tool) {
case "custom":
url = simplePrintf(getValueOf("popupEditCounterUrl"), [encodeURIComponent(uN), toolDbName()]);
break;
default: {
const theWiki = pg.wiki.hostname.split(".");
url = simplePrintf(defaultToolUrl, [encodeURIComponent(uN), theWiki[0], theWiki[1]]);
}
}
return generalNavLink({
url,
title: tprintf("editCounterLinkHint", [uN]),
newWin: l.newWin,
text: l.text,
noPopup: 1
});
};
const editorListLink = (l) => {
if (!saneLinkCheck(l)) {
return null;
}
const article = l.article.articleFromTalkPage() || l.article;
const url = "https://xtools.wmflabs.org/articleinfo/".concat(encodeURI(pg.wiki.hostname), "/").concat(article.urlString(), "?uselang=").concat(mw.config.get("wgUserLanguage"));
return generalNavLink({
url,
title: tprintf("editorListHint", [article]),
newWin: l.newWin,
text: l.text,
noPopup: 1
});
};
const generalNavLink = (l) => {
l.className = l.className === null ? "popupNavLink" : l.className;
return generalLink(l);
};
const getHistoryInfo = (wikipage, whatNext) => {
log("getHistoryInfo");
getHistory(wikipage, whatNext ? (d) => {
whatNext(processHistory(d));
} : processHistory);
};
const getHistory = (wikipage, onComplete) => {
log("getHistory");
const url = "".concat(pg.wiki.apiwikibase, "?format=json&formatversion=2&action=query&prop=revisions&titles=").concat(new Title(wikipage).urlString(), "&rvlimit=").concat(getValueOf("popupHistoryLimit"));
log("getHistory: url=".concat(url));
return startDownload(url, "".concat(pg.idNumber, "history"), onComplete);
};
const processHistory = (download) => {
const jsobj = getJsObj(download.data);
try {
const {
revisions
} = anyChild(jsobj.query.pages);
const edits = [];
var _iterator27 = _createForOfIteratorHelper(revisions), _step27;
try {
for (_iterator27.s(); !(_step27 = _iterator27.n()).done; ) {
const revision = _step27.value;
edits.push({
oldid: revision.revid,
editor: revision.user
});
}
} catch (err) {
_iterator27.e(err);
} finally {
_iterator27.f();
}
log("processed ".concat(edits.length, " edits"));
return finishProcessHistory(edits, mw.config.get("wgUserName"));
} catch {
log("Something went wrong with JSON business");
return finishProcessHistory([]);
}
};
const finishProcessHistory = (edits, userName) => {
const histInfo = {};
histInfo.edits = edits;
histInfo.userName = userName;
for (let i = 0; i < edits.length; ++i) {
if (histInfo.myLastEdit === void 0 && userName && edits[i].editor === userName) {
histInfo.myLastEdit = {
index: i,
oldid: edits[i].oldid,
previd: i === 0 ? null : edits[i - 1].oldid
};
}
if (histInfo.firstNewEditor === void 0 && edits[i].editor !== edits[0].editor) {
histInfo.firstNewEditor = {
index: i,
oldid: edits[i].oldid,
previd: i === 0 ? null : edits[i - 1].oldid
};
}
}
return histInfo;
};
const defaultize = (x) => {
var _pg$option, _pg$option$x;
(_pg$option$x = (_pg$option = pg.option)[x]) !== null && _pg$option$x !== void 0 ? _pg$option$x : _pg$option[x] = window[x] === void 0 ? pg.optionDefault[x] : window[x];
};
const newOption = (x, def) => {
pg.optionDefault[x] = def;
};
const setDefault = (x, def) => {
return newOption(x, def);
};
const getValueOf = (varName) => {
defaultize(varName);
return pg.option[varName];
};
const setOptions = () => {
let userIsSysop = false;
if (mw.config.get("wgUserGroups")) {
for (let g = 0; g < mw.config.get("wgUserGroups").length; ++g) {
if (mw.config.get("wgUserGroups")[g] === "sysop") {
userIsSysop = true;
}
if (mw.config.get("wgUserGroups")[g] === "steward") {
userIsSysop = true;
}
}
}
newOption("popupDelay", 0.5);
newOption("popupHideDelay", 0.5);
newOption("simplePopups", false);
newOption("popupStructure", "shortmenus");
newOption("popupActionsMenu", true);
newOption("popupSetupMenu", true);
newOption("popupAdminLinks", userIsSysop);
newOption("popupShortcutKeys", false);
newOption("popupHistoricalLinks", true);
newOption("popupOnlyArticleLinks", true);
newOption("removeTitles", true);
newOption("popupMaxWidth", 350);
newOption("popupSimplifyMainLink", true);
newOption("popupAppendRedirNavLinks", true);
newOption("popupTocLinks", false);
newOption("popupSubpopups", true);
newOption(
"popupDragHandle",
false
/* 'popupTopLinks' */
);
newOption("popupLazyPreviews", true);
newOption("popupLazyDownloads", true);
newOption("popupAllDabsStubs", false);
newOption("popupDebugging", false);
newOption("popupActiveNavlinks", true);
newOption("popupModifier", false);
newOption("popupModifierAction", "enable");
newOption("popupDraggable", true);
newOption("popupReview", false);
newOption("popupLocale", false);
newOption("popupDateTimeFormatterOptions", {
year: "numeric",
month: "long",
day: "numeric",
hour12: false,
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
});
newOption("popupDateFormatterOptions", {
year: "numeric",
month: "long",
day: "numeric"
});
newOption("popupTimeFormatterOptions", {
hour12: false,
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
});
newOption("popupImages", true);
newOption("imagePopupsForImages", true);
newOption("popupNeverGetThumbs", false);
newOption("popupThumbAction", "imagepage");
newOption("popupImageSize", 60);
newOption("popupImageSizeLarge", 200);
newOption("popupFixRedirs", false);
newOption("popupRedirAutoClick", "wpDiff");
newOption("popupFixDabs", false);
newOption("popupDabsAutoClick", "wpDiff");
newOption("popupRevertSummaryPrompt", false);
newOption("popupMinorReverts", false);
newOption("popupRedlinkRemoval", false);
newOption("popupRedlinkAutoClick", "wpDiff");
newOption("popupWatchDisambiggedPages", null);
newOption("popupWatchRedirredPages", null);
newOption("popupDabWiktionary", "last");
newOption("popupNavLinks", true);
newOption("popupNavLinkSeparator", " ⋅ ");
newOption("popupLastEditLink", true);
newOption("popupEditCounterTool", "supercount");
newOption("popupEditCounterUrl", "");
newOption("popupPreviews", true);
newOption("popupSummaryData", true);
newOption("popupMaxPreviewSentences", 5);
newOption("popupMaxPreviewCharacters", 600);
newOption("popupLastModified", true);
newOption("popupPreviewKillTemplates", true);
newOption("popupPreviewRawTemplates", true);
newOption("popupPreviewFirstParOnly", true);
newOption("popupPreviewCutHeadings", true);
newOption("popupPreviewButton", false);
newOption("popupPreviewButtonEvent", "click");
newOption("popupPreviewDiffs", true);
newOption("popupDiffMaxLines", 100);
newOption("popupDiffContextLines", 2);
newOption("popupDiffContextCharacters", 40);
newOption("popupDiffDates", true);
newOption("popupDiffDatePrinter", "toLocaleString");
newOption("popupReviewedSummary", popupString("defaultpopupReviewedSummary"));
newOption("popupFixDabsSummary", popupString("defaultpopupFixDabsSummary"));
newOption("popupExtendedRevertSummary", popupString("defaultpopupExtendedRevertSummary"));
newOption("popupRevertSummary", popupString("defaultpopupRevertSummary"));
newOption("popupRevertToPreviousSummary", popupString("defaultpopupRevertToPreviousSummary"));
newOption("popupQueriedRevertSummary", popupString("defaultpopupQueriedRevertSummary"));
newOption("popupQueriedRevertToPreviousSummary", popupString("defaultpopupQueriedRevertToPreviousSummary"));
newOption("popupFixRedirsSummary", popupString("defaultpopupFixRedirsSummary"));
newOption("popupRedlinkSummary", popupString("defaultpopupRedlinkSummary"));
newOption("popupRmDabLinkSummary", popupString("defaultpopupRmDabLinkSummary"));
newOption("popupHistoryLimit", 50);
newOption("popupFilters", [popupFilterStubDetect, popupFilterDisambigDetect, popupFilterPageSize, popupFilterCountLinks, popupFilterCountImages, popupFilterCountCategories, popupFilterLastModified]);
newOption("extraPopupFilters", []);
newOption("popupOnEditSelection", "cursor");
newOption("popupPreviewHistory", true);
newOption("popupImageLinks", true);
newOption("popupCategoryMembers", true);
newOption("popupUserInfo", true);
newOption("popupHistoryPreviewLimit", 25);
newOption("popupContribsPreviewLimit", 25);
newOption("popupRevDelUrl", "//en.wikipedia.org/wiki/Wikipedia:Revision_deletion");
newOption("popupShowGender", true);
newOption("popupNewWindows", false);
newOption("popupLinksNewWindow", {
lastContrib: true,
sinceMe: true
});
newOption("popupDabRegexp", String.raw(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["{{s*(d(ab|isamb(ig(uation)?)?)|(((geo|hn|road?|school|number)dis)|[234][lc][acw]|(road|ship)index))s*(|[^}]*)?}}|is a .*disambiguation.*page"], ["\\{\\{\\s*(d(ab|isamb(ig(uation)?)?)|(((geo|hn|road?|school|number)dis)|[234][lc][acw]|(road|ship)index))\\s*(\\|[^}]*)?\\}\\}|is a .*disambiguation.*page"]))));
newOption("popupAnchorRegexp", "anchors?");
newOption("popupStubRegexp", "(sect)?stub[}][}]|This .*-related article is a .*stub");
newOption("popupImageVarsRegexp", "image|image_(?:file|skyline|name|flag|seal)|cover|badge|logo");
};
pg.string = {
// summary data, searching etc.
article: "article",
category: "category",
categories: "categories",
image: "image",
images: "images",
stub: "stub",
"section stub": "section stub",
"Empty page": "Empty page",
kB: "kB",
bytes: "bytes",
day: "day",
days: "days",
hour: "hour",
hours: "hours",
minute: "minute",
minutes: "minutes",
second: "second",
seconds: "seconds",
week: "week",
weeks: "weeks",
search: "search",
SearchHint: "Find English Wikipedia articles containing %s",
web: "web",
global: "global",
// article-related actions and info
// (some actions also apply to user pages)
actions: "actions",
popupsMenu: "popups",
togglePreviewsHint: "Toggle preview generation in popups on this page",
"enable previews": "enable previews",
"disable previews": "disable previews",
"toggle previews": "toggle previews",
"show preview": "show preview",
reset: "reset",
"more...": "more...",
disable: "disable popups",
disablePopupsHint: "Disable popups on this page. Reload page to re-enable.",
historyfeedHint: "RSS feed of recent changes to this page",
purgePopupsHint: "Reset popups, clearing all cached popup data.",
PopupsHint: "Reset popups, clearing all cached popup data.",
spacebar: "space",
view: "view",
"view article": "view article",
viewHint: "Go to %s",
talk: "talk",
"talk page": "talk page",
"this revision": "this revision",
"revision %s of %s": "revision %s of %s",
"Revision %s of %s": "Revision %s of %s",
"the revision prior to revision %s of %s": "the revision prior to revision %s of %s",
"Toggle image size": "Click to toggle image size",
del: "del",
delete: "delete",
deleteHint: "Delete %s",
undeleteShort: "un",
UndeleteHint: "Show the deletion history for %s",
protect: "protect",
protectHint: "Restrict editing rights to %s",
unprotectShort: "un",
unprotectHint: "Allow %s to be edited by anyone again",
"send thanks": "send thanks",
ThanksHint: "Send a thank you notification to this user",
move: "move",
"move page": "move page",
MovepageHint: "Change the title of %s",
edit: "edit",
"edit article": "edit article",
editHint: "Change the content of %s",
"edit talk": "edit talk",
new: "new",
"new topic": "new topic",
newSectionHint: "Start a new section on %s",
"null edit": "null edit",
nullEditHint: "Submit an edit to %s, making no changes ",
hist: "hist",
history: "history",
historyHint: "List the changes made to %s",
last: "prev",
lastEdit: "lastEdit",
"mark patrolled": "mark patrolled",
markpatrolledHint: "Mark this edit as patrolled",
"Could not marked this edit as patrolled": "Could not marked this edit as patrolled",
"show last edit": "most recent edit",
"Show the last edit": "Show the effects of the most recent change",
lastContrib: "lastContrib",
"last set of edits": "latest edits",
lastContribHint: "Show the net effect of changes made by the last editor",
cur: "cur",
diffCur: "diffCur",
"Show changes since revision %s": "Show changes since revision %s",
"%s old": "%s old",
oldEdit: "oldEdit",
purge: "purge",
purgeHint: "Demand a fresh copy of %s",
raw: "source",
rawHint: "Download the source of %s",
render: "simple",
renderHint: "Show a plain HTML version of %s",
"Show the edit made to get revision": "Show the edit made to get revision",
sinceMe: "sinceMe",
"changes since mine": "diff my edit",
sinceMeHint: "Show changes since my last edit",
"Couldn't find an edit by %s\nin the last %s edits to\n%s": "Couldn't find an edit by %s\nin the last %s edits to\n%s",
eds: "eds",
editors: "editors",
editorListHint: "List the users who have edited %s",
related: "related",
relatedChanges: "relatedChanges",
"related changes": "related changes",
RecentchangeslinkedHint: "Show changes in articles related to %s",
editOld: "editOld",
rv: "rv",
revert: "revert",
revertHint: "Revert to %s",
defaultpopupReviewedSummary: "Accepted by reviewing the [[Special:diff/%s/%s|difference]] between this version and previously accepted version using [[:enwiki:Wikipedia:Tools/Navigation_popups|popups]]",
defaultpopupRedlinkSummary: "Removing link to empty page [[%s]] using [[:enwiki:Wikipedia:Tools/Navigation_popups|popups]]",
defaultpopupFixDabsSummary: "Disambiguate [[%s]] to [[%s]] using [[:enwiki:Wikipedia:Tools/Navigation_popups|popups]]",
defaultpopupFixRedirsSummary: "Redirect bypass from [[%s]] to [[%s]] using [[:enwiki:Wikipedia:Tools/Navigation_popups|popups]]",
defaultpopupExtendedRevertSummary: "Revert to revision dated %s by %s, oldid %s using [[:enwiki:Wikipedia:Tools/Navigation_popups|popups]]",
defaultpopupRevertToPreviousSummary: "Revert to the revision prior to revision %s using [[:enwiki:Wikipedia:Tools/Navigation_popups|popups]]",
defaultpopupRevertSummary: "Revert to revision %s using [[:enwiki:Wikipedia:Tools/Navigation_popups|popups]]",
defaultpopupQueriedRevertToPreviousSummary: "Revert to the revision prior to revision $1 dated $2 by $3 using [[:enwiki:Wikipedia:Tools/Navigation_popups|popups]]",
defaultpopupQueriedRevertSummary: "Revert to revision $1 dated $2 by $3 using [[:enwiki:Wikipedia:Tools/Navigation_popups|popups]]",
defaultpopupRmDabLinkSummary: "Remove link to dab page [[%s]] using [[:enwiki:Wikipedia:Tools/Navigation_popups|popups]]",
Redirects: "Redirects",
" to ": " to ",
"Bypass redirect": "Bypass redirect",
"Fix this redirect": "Fix this redirect",
disambig: "disambig",
disambigHint: "Disambiguate this link to [[%s]]",
"Click to disambiguate this link to:": "Click to disambiguate this link to:",
"remove this link": "remove this link",
"remove all links to this page from this article": "remove all links to this page from this article",
"remove all links to this disambig page from this article": "remove all links to this disambig page from this article",
mainlink: "mainlink",
wikiLink: "wikiLink",
wikiLinks: "wikiLinks",
"links here": "links here",
whatLinksHere: "whatLinksHere",
"what links here": "what links here",
WhatlinkshereHint: "List the pages that are hyperlinked to %s",
unwatchShort: "un",
watchThingy: "watch",
watchHint: "Add %s to my watchlist",
unwatchHint: "Remove %s from my watchlist",
"Only found one editor: %s made %s edits": "Only found one editor: %s made %s edits",
"%s seems to be the last editor to the page %s": "%s seems to be the last editor to the page %s",
rss: "rss",
// diff previews
"Diff truncated for performance reasons": "Diff truncated for performance reasons",
"Old revision": "Old revision",
"New revision": "New revision",
"Something went wrong :-(": "Something went wrong :-(",
"Empty revision, maybe non-existent": "Empty revision, maybe non-existent",
"Unknown date": "Unknown date",
// other special previews
"Empty category": "Empty category",
"Category members (%s shown)": "Category members (%s shown)",
"No image links found": "No image links found",
"File links": "File links",
"No image found": "No image found",
"Image from Commons": "Image from Commons",
"Description page": "Description page",
"Alt text:": "Alt text:",
revdel: "Hidden revision",
// user-related actions and info
user: "user",
"user page": "user page",
"user talk": "user talk",
"edit user talk": "edit user talk",
"leave comment": "leave comment",
email: "email",
"email user": "email user",
EmailuserHint: "Send an email to %s",
space: "space",
PrefixIndexHint: "Show pages in the userspace of %s",
count: "count",
"edit counter": "edit counter",
editCounterLinkHint: "Count the contributions made by %s",
contribs: "contribs",
contributions: "contributions",
deletedContribs: "deleted contributions",
DeletedcontributionsHint: "List deleted edits made by %s",
ContributionsHint: "List the contributions made by %s",
log: "log",
"user log": "user log",
userLogHint: "Show %s's user log",
arin: "ARIN lookup",
"Look up %s in ARIN whois database": "Look up %s in the ARIN whois database",
unblockShort: "un",
block: "block",
"block user": "block user",
IpblocklistHint: "Unblock %s",
BlockipHint: "Prevent %s from editing",
"block log": "block log",
blockLogHint: "Show the block log for %s",
protectLogHint: "Show the protection log for %s",
pageLogHint: "Show the page log for %s",
deleteLogHint: "Show the deletion log for %s",
"Invalid %s %s": "The option %s is invalid: %s",
"No backlinks found": "No backlinks found",
" and more": " and more",
undo: "undo",
undoHint: "undo this edit",
"Download preview data": "Download preview data",
"Invalid or IP user": "Invalid or IP user",
"Not a registered username": "Not a registered username",
BLOCKED: "BLOCKED",
"Has blocks": "Has blocks",
" edits since: ": " edits since: ",
"last edit on ": "last edit on ",
"he/him": "he/him",
"she/her": "she/her",
// Autoediting
"Enter a non-empty edit summary or press cancel to abort": "Enter a non-empty edit summary or press cancel to abort",
"Failed to get revision information, please edit manually.\n\n": "Failed to get revision information, please edit manually.\n\n",
"The %s button has been automatically clicked. Please wait for the next page to load.": "The %s button has been automatically clicked. Please wait for the next page to load.",
"Could not find button %s. Please check the settings in your javascript file.": "Could not find button %s. Please check the settings in your javascript file.",
// Popups setup
"Open full-size image": "Open full-size image",
autoedit_version: "np20140416"
};
const popupString = (str) => {
if (message !== void 0 && message && message[str]) {
return message[str];
}
if (pg.string[str]) {
return pg.string[str];
}
return str;
};
const tprintf = (str, subs) => {
if (typeof subs !== typeof []) {
subs = [subs];
}
return simplePrintf(popupString(str), subs);
};
if (document.readyState === "complete") {
autoEdit();
} else {
$(window).on("load", autoEdit);
}
(() => {
let once = true;
const dynamicContentHandler = ($content) => {
if ($content.attr("id") === "mw-content-text" && once) {
once = false;
return;
}
const registerHooksForVisibleNavpops = () => {
for (let i = 0; pg.current.links && i < pg.current.links.length; i++) {
const navpop = pg.current.links[i].navpopup;
if (!navpop || !navpop.isVisible()) {
continue;
}
Navpopup.tracker.addHook(posCheckerHook(navpop));
}
};
const doIt = () => {
registerHooksForVisibleNavpops();
$content.each((_index, element) => {
element.ranSetupTooltipsAlready = false;
setupTooltips(element);
});
};
setupPopups(doIt);
};
mw.hook("wikipage.content").add(dynamicContentHandler);
mw.hook("ext.echo.overlay.beforeShowingOverlay").add(($overlay) => {
dynamicContentHandler($overlay.find(".mw-echo-state"));
});
})();
};
//! src/Navigation_popups/Navigation_popups.ts
$(popups);
})();