MediaWiki:Gadget-ShortURL.js:修订间差异

删除的内容 添加的内容
portletId 优先使用 #p-tb(工具菜单),解决匿名用户看不到的问题
标签手工回退
ShortURL: remove numbering from label
 
(未显示2个用户的8个中间版本)
第6行:
* @author 安忆 <i@anyi.in>; WaitSpring <me@waitspring.com>
* @license GPL-3.0-or-later {@link https://www.qiuwenbaike.cn/wiki/H:GPL-3.0}
* 移植至 中医百科 (test.zybkcn.com)
*/
 
第223行 ⟶ 第222行:
let portletLink = document.querySelector("#t-shortlink");
if (!portletLink) {
const portletId = document.querySelector("#p-tbcactions") ? "p-tbcactions" : "p-cactionstb";
portletLink = mw.util.addPortletLink(portletId, "#", getMessage("Share URL for the page"), "t-shortlink", getMessage("Show URL"));
}
第249行 ⟶ 第248行:
}).$element
);
// 【原】if (wgUserName) { 以下内容 — 仅登录显示短链接 }
// 【新】匿名也可复制短链接
var _iterator2 = _createForOfIteratorHelper(domains.entries()), _step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
const [i, domain] = _step2.value;
const [i, $elementdomain] = _step2.append(value;
$element.append(
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
new mw.widgets.CopyTextLayout({
label: "".concat(getMessage("Short URL")).concat(i + 1),
titlelabel: "".concat(getMessage("Short URL")).concat(i + 1),
aligntitle: getMessage("topShort URL"),
copyTextalign: "https://top".concat(domain).concat(link),
}copyText: "https://".concat(domain).$elementconcat(link)
});.$element
});
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
void OO.ui.alert($element, {
第292行 ⟶ 第291行:
if (!headerLink) {
headerLink = /* @__PURE__ */ import_ext_gadget3.default.createElement("a", {
// 【原】"aria-label": wgUserName ? getMessage("Short URL") : getMessage("Share URL for the page"),
// 【新】匿名统一显示"短链接"
"aria-label": "".concat(getMessage("Short URL")).concat(i + 1),
href: "#"
}, /* @__PURE__ */ import_ext_gadget3.default.createElement("span", {
className: "gadget-short-link__icon"
},// 【原】wgUserName ? getMessage("Short URL")... : getMessage("Share URL for the page")));...
// 【新】匿名统一
}, getMessage("Short URL")));
(0, import_ext_gadget5.tippy)(headerLink, {
arrow: true,
// 【原】content: wgUserName ? getMessage("Short URL")... : getMessage("Share URL for the page"),...
// 【新】匿名统一
content: getMessage("Short URL"),
placement: "bottom"
});
第308行 ⟶ 第313行:
$headerElement.prependTo(".mw-indicators");
}
// 【原】const fullLink = wgUserName ? "https://".concat(domains[0]).concat(link) : "https://".concat(location.host).concat(permaLink);
// 【新】匿名也可用短链接
const fullLink = domains.length ? "https://".concat(domains[0]).concat(link) : "https://".concat(location.host).concat(permaLink);
const $notifyElement = $(/* @__PURE__ */ import_ext_gadget3.default.createElement("span", null, getMessage("URL copied to clipboard"), /* @__PURE__ */ import_ext_gadget3.default.createElement("br", null), /* @__PURE__ */ import_ext_gadget3.default.createElement("a", {
href: "#",
第365行 ⟶ 第372行:
var _ref = _asyncToGenerator(function* (diffId) {
try {
return yield api.get(Object.assign({}, parameters, {
...parameters,
fromrev: diffId
}));
} catch (error) {
console.error("[ShortURL] Ajax error:", error);
第426行 ⟶ 第432行:
}
if (wgAction === "view" && wgArticleId) {
mw.hook("wikipage.content").add(const runProcess = ($content) => {
if ($content.attr("id") !== "mw-content-text") {
return;
第437行 ⟶ 第443行:
revisionId: mw.config.get("wgRevisionId")
});
});
const $content = $("#mw-content-text");
if ($content.length) {
runProcess($content);
}
mw.hook("wikipage.content").add(runProcess);
}
})();