MediaWiki:Common.js: Difference between revisions
From VRChat Wiki
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
(() => { | (() => { | ||
var e = Object.defineProperty | var e = Object.defineProperty; | ||
var __esmMin = (e, t) => () => (e && (t = e(e = 0)), t); | |||
var __export = (t, n) => { | |||
let r = {}; | let r = {}; | ||
for (var i in t) e(r, i, { | for (var i in t) { | ||
e(r, i, { | |||
get: t[i], | |||
enumerable: true | |||
}); | |||
} | |||
if (n) { | |||
e(r, Symbol.toStringTag, { value: "Module" }); | |||
} | |||
return r; | |||
}; | }; | ||
function isPage(e) { | function isPage(e) { | ||
const [t, n] = mw.config.get("wgPageName").split("/"); | |||
if (!t || !e.includes(t)) return false; | |||
if (n && mw.config.get("wgPageContentLanguage") != n) return false; | |||
return true; | |||
} | } | ||
[...document.querySelectorAll(".spoiler")].map((e) => { | [...document.querySelectorAll(".spoiler")].map((e) => { | ||
e.querySelector(".spoiler-overlay") | const t = e.querySelector(".spoiler-overlay"); | ||
t === null || t === void 0 || t.addEventListener("click", () => { | |||
e.dataset.open = ""; | e.dataset.open = ""; | ||
}); | }); | ||
}); | }); | ||
function _objectWithoutPropertiesLoose(e, t) { | function _objectWithoutPropertiesLoose(e, t) { | ||
if ( | if (null == e) return {}; | ||
var n = {}; | var n = {}; | ||
for (var r in e) if ({}.hasOwnProperty.call(e, r)) { | for (var r in e) if ({}.hasOwnProperty.call(e, r)) { | ||
| Line 27: | Line 37: | ||
} | } | ||
function _objectWithoutProperties(e, t) { | function _objectWithoutProperties(e, t) { | ||
if ( | if (null == e) return {}; | ||
var n, r, i = _objectWithoutPropertiesLoose(e, t); | var n, r, i = _objectWithoutPropertiesLoose(e, t); | ||
if (Object.getOwnPropertySymbols) { | if (Object.getOwnPropertySymbols) { | ||
| Line 37: | Line 47: | ||
var t = ["videoId"]; | var t = ["videoId"]; | ||
[...document.querySelectorAll(".youtube")].map((e) => { | [...document.querySelectorAll(".youtube")].map((e) => { | ||
const n = e.dataset, { videoId: r } = n, i = _objectWithoutProperties(n, t); | |||
a.setAttribute("width", | const a = document.createElement("iframe"); | ||
a.setAttribute("width", String(560)); | |||
a.setAttribute("height", String(315)); | |||
a.setAttribute("frameborder", String(0)); | |||
a.setAttribute("allow", [ | |||
"accelerometer", | "accelerometer", | ||
"autoplay", | "autoplay", | ||
| Line 46: | Line 60: | ||
"picture-in-picture", | "picture-in-picture", | ||
"web-share" | "web-share" | ||
].join("; ")) | ].join("; ")); | ||
a.setAttribute("referrerpolicy", "strict-origin-when-cross-origin"); | |||
a.setAttribute("allowfullscreen", String(true)); | |||
Object.entries(i).map(([e, t]) => t && a.setAttribute(e, t)); | |||
a.setAttribute("style", e.getAttribute("style") || ""); | |||
a.src = `https://www.youtube-nocookie.com/embed/${r}?rel=0`; | |||
e.replaceWith(a); | |||
}); | }); | ||
let | var n = /* @__PURE__ */ (function detectScriptRel() { | ||
const e = typeof document !== "undefined" && document.createElement("link").relList; | |||
return e && e.supports && e.supports("modulepreload") ? "modulepreload" : "preload"; | |||
})(); | |||
var assetsURL = function(e, t) { | |||
return new URL(e, t).href; | |||
}; | |||
var r = {}; | |||
const i = function preload(e, t, i) { | |||
let a = Promise.resolve(); | |||
if (false && t && t.length > 0) { | |||
const e = document.getElementsByTagName("link"); | |||
const o = document.querySelector("meta[property=csp-nonce]"); | |||
const s = (o === null || o === void 0 ? void 0 : o.nonce) || (o === null || o === void 0 ? void 0 : o.getAttribute("nonce")); | |||
function allSettled(e) { | |||
return Promise.all(e.map((e) => Promise.resolve(e).then((e) => ({ | |||
status: "fulfilled", | |||
value: e | |||
}), (e) => ({ | |||
status: "rejected", | |||
reason: e | |||
})))); | |||
} | |||
a = allSettled(t.map((t) => { | |||
t = assetsURL(t, i); | |||
if (t in r) return; | |||
r[t] = true; | |||
const a = t.endsWith(".css"); | |||
const o = a ? "[rel=\"stylesheet\"]" : ""; | |||
if (!!i) for (let n = e.length - 1; n >= 0; n--) { | |||
const r = e[n]; | |||
if (r.href === t && (!a || r.rel === "stylesheet")) return; | |||
} | |||
else if (document.querySelector(`link[href="${t}"]${o}`)) return; | |||
const c = document.createElement("link"); | |||
c.rel = a ? "stylesheet" : n; | |||
if (!a) c.as = "script"; | |||
c.crossOrigin = ""; | |||
c.href = t; | |||
if (s) c.setAttribute("nonce", s); | |||
document.head.appendChild(c); | |||
if (a) return new Promise((e, n) => { | |||
c.addEventListener("load", e); | |||
c.addEventListener("error", () => n(/* @__PURE__ */ new Error(`Unable to preload CSS for ${t}`))); | |||
}); | |||
})); | |||
} | |||
function handlePreloadError(e) { | function handlePreloadError(e) { | ||
const t = new Event("vite:preloadError", { cancelable: true }); | |||
t.payload = e; | |||
window.dispatchEvent(t); | |||
if (!t.defaultPrevented) throw e; | |||
} | } | ||
return | return a.then((t) => { | ||
for ( | for (const e of t || []) { | ||
if (e.status !== "rejected") continue; | |||
handlePreloadError(e.reason); | |||
} | |||
return e().catch(handlePreloadError); | return e().catch(handlePreloadError); | ||
}); | }); | ||
}; | }; | ||
function getArticleFromElement(e) { | function getArticleFromElement(e) { | ||
const { articleId: t, articleTitle: n, articleContent: r } = e.dataset; | |||
if (!t || !n || !r) return null; | |||
return { | |||
id: t, | id: t, | ||
title: n, | title: n, | ||
| Line 67: | Line 138: | ||
}; | }; | ||
} | } | ||
var ArticleDialog | var ArticleDialog; | ||
var a = __esmMin((() => { | |||
ArticleDialog = class extends OO.ui.ProcessDialog { | ArticleDialog = class extends OO.ui.ProcessDialog { | ||
constructor(e) { | constructor(e) { | ||
| Line 73: | Line 145: | ||
size: "large", | size: "large", | ||
data: { title: e.title } | data: { title: e.title } | ||
}) | }); | ||
this.article = e; | |||
} | } | ||
initialize() { | initialize() { | ||
super.initialize(); | super.initialize(); | ||
const e = new OO.ui.PanelLayout({ | |||
expanded: | expanded: false, | ||
padded: | padded: true, | ||
scrollable: | scrollable: true | ||
}); | }); | ||
e.$element.append(this.article.content); | |||
this.$body.append(e.$element); | |||
return this; | |||
} | } | ||
getActionProcess(e) { | getActionProcess(e) { | ||
| Line 92: | Line 167: | ||
return super.getActionProcess(e); | return super.getActionProcess(e); | ||
} | } | ||
} | }; | ||
ArticleDialog.static.name = ArticleDialog.name; | |||
ArticleDialog.static.actions = [{ | |||
action: "close", | action: "close", | ||
flags: "safe", | flags: "safe", | ||
| Line 98: | Line 175: | ||
label: "Close" | label: "Close" | ||
}]; | }]; | ||
})) | })); | ||
var o = __esmMin((() => {})); | |||
function asyncGeneratorStep(e, t, n, r, i, a, o) { | function asyncGeneratorStep(e, t, n, r, i, a, o) { | ||
try { | try { | ||
| Line 123: | Line 201: | ||
}; | }; | ||
} | } | ||
var | var s = __esmMin((() => {})); | ||
var c = /* @__PURE__ */ __export({}, 1); | |||
for ( | var l, u; | ||
var d = __esmMin((() => { | |||
for ( | a(); | ||
if (e.querySelector("a")) continue; | o(); | ||
s(); | |||
t | l = document.querySelectorAll(".tpl-infopush"); | ||
if (!(yield | console.log({ infopushes: l }); | ||
u = new OO.ui.WindowManager(); | |||
$(document.body).append(u.$element); | |||
for (const e of l) { | |||
const t = e.querySelector(".tpl-infopush-content"); | |||
const n = t.querySelectorAll(".tpl-infopush-item"); | |||
const r = n.length; | |||
for (const e of n) { | |||
if (!!e.querySelector("a")) continue; | |||
const t = getArticleFromElement(e); | |||
if (!t) continue; | |||
e.style.cursor = "pointer"; | |||
e.addEventListener("click", _asyncToGenerator(function* () { | |||
if (!(yield u.getWindow(t.id).then(() => true).catch(() => false))) { | |||
const e = new ArticleDialog(t); | |||
u.addWindows({ [t.id]: e }); | |||
} | } | ||
yield | yield u.openWindow(t.id).opening; | ||
} | })); | ||
} | } | ||
const i = e.querySelector(".tpl-infopush-navigation"); | |||
let a = 0; | |||
function showSlide(e) { | function showSlide(e) { | ||
a = (e + r) % r | a = (e + r) % r; | ||
t.style.transform = `translateX(-${a * 100}%)`; | |||
} | } | ||
let | const o = 5e3; | ||
let s; | |||
function resetAutoAdvance() { | function resetAutoAdvance() { | ||
if (s) clearInterval(s); | |||
s = setInterval(function() { | |||
showSlide(a + 1); | showSlide(a + 1); | ||
}, | }, o); | ||
} | } | ||
i.querySelector(".tpl-infopush-navigation-previous").addEventListener("click", () => { | i.querySelector(".tpl-infopush-navigation-previous").addEventListener("click", () => { | ||
showSlide(a - 1) | showSlide(a - 1); | ||
}) | resetAutoAdvance(); | ||
showSlide(a + 1) | }); | ||
}) | i.querySelector(".tpl-infopush-navigation-next").addEventListener("click", () => { | ||
showSlide(a + 1); | |||
resetAutoAdvance(); | |||
}); | |||
resetAutoAdvance(); | |||
showSlide(0); | |||
} | } | ||
})); | })); | ||
isPage(["Template:MainPageInfopush", "Main_Page"]) | if (isPage(["Template:MainPageInfopush", "Main_Page"])) mw.loader.using(["oojs-ui-core", "oojs-ui-windows"]).then(() => i(() => Promise.resolve().then(() => (d(), c)), void 0, {}.url)); | ||
var | var f = document.createElement("script"); | ||
f.setAttribute("defer", "defer"); | |||
var | f.setAttribute("data-domain", "wiki.vrchat.com"); | ||
f.setAttribute("event-page-name", mw.config.get("wgTitle")); | |||
var | f.setAttribute("event-page-language", mw.config.get("wgPageContentLanguage")); | ||
var p = mw.config.get("wgFormattedNamespaces"); | |||
f.setAttribute("event-page-namespace", p[mw.config.get("wgNamespaceNumber")]); | |||
f.setAttribute("event-theme", mw.config.get("skin")); | |||
f.setAttribute("event-action", mw.config.get("wgAction")); | |||
f.setAttribute("event-is-logged-in", String(mw.config.get("wgUserName") !== null)); | |||
var m = mw.config.get("wgUserGroups"); | |||
var h = m.includes("community-mod") || m.includes("moderator") || m.includes("sysop"); | |||
f.setAttribute("event-is-maintainer", String(h)); | |||
f.src = "https://plausible.io/js/script.pageview-props.outbound-links.js"; | |||
document.head.appendChild(f); | |||
})(); | })(); | ||
Revision as of 14:15, 13 December 2025
(() => {
var e = Object.defineProperty;
var __esmMin = (e, t) => () => (e && (t = e(e = 0)), t);
var __export = (t, n) => {
let r = {};
for (var i in t) {
e(r, i, {
get: t[i],
enumerable: true
});
}
if (n) {
e(r, Symbol.toStringTag, { value: "Module" });
}
return r;
};
function isPage(e) {
const [t, n] = mw.config.get("wgPageName").split("/");
if (!t || !e.includes(t)) return false;
if (n && mw.config.get("wgPageContentLanguage") != n) return false;
return true;
}
[...document.querySelectorAll(".spoiler")].map((e) => {
const t = e.querySelector(".spoiler-overlay");
t === null || t === void 0 || t.addEventListener("click", () => {
e.dataset.open = "";
});
});
function _objectWithoutPropertiesLoose(e, t) {
if (null == e) return {};
var n = {};
for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
if (t.includes(r)) continue;
n[r] = e[r];
}
return n;
}
function _objectWithoutProperties(e, t) {
if (null == e) return {};
var n, r, i = _objectWithoutPropertiesLoose(e, t);
if (Object.getOwnPropertySymbols) {
var a = Object.getOwnPropertySymbols(e);
for (r = 0; r < a.length; r++) n = a[r], t.includes(n) || {}.propertyIsEnumerable.call(e, n) && (i[n] = e[n]);
}
return i;
}
var t = ["videoId"];
[...document.querySelectorAll(".youtube")].map((e) => {
const n = e.dataset, { videoId: r } = n, i = _objectWithoutProperties(n, t);
const a = document.createElement("iframe");
a.setAttribute("width", String(560));
a.setAttribute("height", String(315));
a.setAttribute("frameborder", String(0));
a.setAttribute("allow", [
"accelerometer",
"autoplay",
"clipboard-write",
"encrypted-media",
"gyroscope",
"picture-in-picture",
"web-share"
].join("; "));
a.setAttribute("referrerpolicy", "strict-origin-when-cross-origin");
a.setAttribute("allowfullscreen", String(true));
Object.entries(i).map(([e, t]) => t && a.setAttribute(e, t));
a.setAttribute("style", e.getAttribute("style") || "");
a.src = `https://www.youtube-nocookie.com/embed/${r}?rel=0`;
e.replaceWith(a);
});
var n = /* @__PURE__ */ (function detectScriptRel() {
const e = typeof document !== "undefined" && document.createElement("link").relList;
return e && e.supports && e.supports("modulepreload") ? "modulepreload" : "preload";
})();
var assetsURL = function(e, t) {
return new URL(e, t).href;
};
var r = {};
const i = function preload(e, t, i) {
let a = Promise.resolve();
if (false && t && t.length > 0) {
const e = document.getElementsByTagName("link");
const o = document.querySelector("meta[property=csp-nonce]");
const s = (o === null || o === void 0 ? void 0 : o.nonce) || (o === null || o === void 0 ? void 0 : o.getAttribute("nonce"));
function allSettled(e) {
return Promise.all(e.map((e) => Promise.resolve(e).then((e) => ({
status: "fulfilled",
value: e
}), (e) => ({
status: "rejected",
reason: e
}))));
}
a = allSettled(t.map((t) => {
t = assetsURL(t, i);
if (t in r) return;
r[t] = true;
const a = t.endsWith(".css");
const o = a ? "[rel=\"stylesheet\"]" : "";
if (!!i) for (let n = e.length - 1; n >= 0; n--) {
const r = e[n];
if (r.href === t && (!a || r.rel === "stylesheet")) return;
}
else if (document.querySelector(`link[href="${t}"]${o}`)) return;
const c = document.createElement("link");
c.rel = a ? "stylesheet" : n;
if (!a) c.as = "script";
c.crossOrigin = "";
c.href = t;
if (s) c.setAttribute("nonce", s);
document.head.appendChild(c);
if (a) return new Promise((e, n) => {
c.addEventListener("load", e);
c.addEventListener("error", () => n(/* @__PURE__ */ new Error(`Unable to preload CSS for ${t}`)));
});
}));
}
function handlePreloadError(e) {
const t = new Event("vite:preloadError", { cancelable: true });
t.payload = e;
window.dispatchEvent(t);
if (!t.defaultPrevented) throw e;
}
return a.then((t) => {
for (const e of t || []) {
if (e.status !== "rejected") continue;
handlePreloadError(e.reason);
}
return e().catch(handlePreloadError);
});
};
function getArticleFromElement(e) {
const { articleId: t, articleTitle: n, articleContent: r } = e.dataset;
if (!t || !n || !r) return null;
return {
id: t,
title: n,
content: atob(r)
};
}
var ArticleDialog;
var a = __esmMin((() => {
ArticleDialog = class extends OO.ui.ProcessDialog {
constructor(e) {
super({
size: "large",
data: { title: e.title }
});
this.article = e;
}
initialize() {
super.initialize();
const e = new OO.ui.PanelLayout({
expanded: false,
padded: true,
scrollable: true
});
e.$element.append(this.article.content);
this.$body.append(e.$element);
return this;
}
getActionProcess(e) {
switch (e) {
case "close": return new OO.ui.Process(() => {
this.close({ action: "close" });
});
}
return super.getActionProcess(e);
}
};
ArticleDialog.static.name = ArticleDialog.name;
ArticleDialog.static.actions = [{
action: "close",
flags: "safe",
icon: "close",
label: "Close"
}];
}));
var o = __esmMin((() => {}));
function asyncGeneratorStep(e, t, n, r, i, a, o) {
try {
var s = e[a](o), c = s.value;
} catch (e) {
n(e);
return;
}
s.done ? t(c) : Promise.resolve(c).then(r, i);
}
function _asyncToGenerator(e) {
return function() {
var t = this, n = arguments;
return new Promise(function(r, i) {
var a = e.apply(t, n);
function _next(e) {
asyncGeneratorStep(a, r, i, _next, _throw, "next", e);
}
function _throw(e) {
asyncGeneratorStep(a, r, i, _next, _throw, "throw", e);
}
_next(void 0);
});
};
}
var s = __esmMin((() => {}));
var c = /* @__PURE__ */ __export({}, 1);
var l, u;
var d = __esmMin((() => {
a();
o();
s();
l = document.querySelectorAll(".tpl-infopush");
console.log({ infopushes: l });
u = new OO.ui.WindowManager();
$(document.body).append(u.$element);
for (const e of l) {
const t = e.querySelector(".tpl-infopush-content");
const n = t.querySelectorAll(".tpl-infopush-item");
const r = n.length;
for (const e of n) {
if (!!e.querySelector("a")) continue;
const t = getArticleFromElement(e);
if (!t) continue;
e.style.cursor = "pointer";
e.addEventListener("click", _asyncToGenerator(function* () {
if (!(yield u.getWindow(t.id).then(() => true).catch(() => false))) {
const e = new ArticleDialog(t);
u.addWindows({ [t.id]: e });
}
yield u.openWindow(t.id).opening;
}));
}
const i = e.querySelector(".tpl-infopush-navigation");
let a = 0;
function showSlide(e) {
a = (e + r) % r;
t.style.transform = `translateX(-${a * 100}%)`;
}
const o = 5e3;
let s;
function resetAutoAdvance() {
if (s) clearInterval(s);
s = setInterval(function() {
showSlide(a + 1);
}, o);
}
i.querySelector(".tpl-infopush-navigation-previous").addEventListener("click", () => {
showSlide(a - 1);
resetAutoAdvance();
});
i.querySelector(".tpl-infopush-navigation-next").addEventListener("click", () => {
showSlide(a + 1);
resetAutoAdvance();
});
resetAutoAdvance();
showSlide(0);
}
}));
if (isPage(["Template:MainPageInfopush", "Main_Page"])) mw.loader.using(["oojs-ui-core", "oojs-ui-windows"]).then(() => i(() => Promise.resolve().then(() => (d(), c)), void 0, {}.url));
var f = document.createElement("script");
f.setAttribute("defer", "defer");
f.setAttribute("data-domain", "wiki.vrchat.com");
f.setAttribute("event-page-name", mw.config.get("wgTitle"));
f.setAttribute("event-page-language", mw.config.get("wgPageContentLanguage"));
var p = mw.config.get("wgFormattedNamespaces");
f.setAttribute("event-page-namespace", p[mw.config.get("wgNamespaceNumber")]);
f.setAttribute("event-theme", mw.config.get("skin"));
f.setAttribute("event-action", mw.config.get("wgAction"));
f.setAttribute("event-is-logged-in", String(mw.config.get("wgUserName") !== null));
var m = mw.config.get("wgUserGroups");
var h = m.includes("community-mod") || m.includes("moderator") || m.includes("sysop");
f.setAttribute("event-is-maintainer", String(h));
f.src = "https://plausible.io/js/script.pageview-props.outbound-links.js";
document.head.appendChild(f);
})();