No edit summary |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
(function () { | (function () { | ||
const libQR = document.createElement("script"); | const libQR = document.createElement("script"); | ||
libQR.addEventListener("load", function () { | libQR.addEventListener("load", function () { | ||
const dark = document.documentElement.classList.contains("skin-citizen-dark"); | |||
QRCode.toDataURL(location.href).then(function (url) { | QRCode.toDataURL(location.href).then(function (url) { | ||
const img = document.createElement("img"); | const img = document.createElement("img"); | ||
img.src = url; | img.src = url; | ||
img.alt = "QR code"; | |||
const label = document.createElement("div"); | const label = document.createElement("div"); |
Latest revision as of 17:15, 22 May 2024
/* Any JavaScript here will be loaded for all users on every page load. */
(function () {
const libQR = document.createElement("script");
libQR.addEventListener("load", function () {
const dark = document.documentElement.classList.contains("skin-citizen-dark");
QRCode.toDataURL(location.href).then(function (url) {
const img = document.createElement("img");
img.src = url;
img.alt = "QR code";
const label = document.createElement("div");
label.className = "page-info__label";
label.textContent = "QR code for this page";
const wrapper = document.createElement("div");
wrapper.className = "page-info__text";
wrapper.appendChild(img);
const section = document.createElement("section");
section.className = "page-info__item";
section.append(label, wrapper);
const footer = document.querySelector(".mw-body-footer > .page-info");
footer.appendChild(section);
}).catch(console.error);
});
libQR.src = "https://cdn.jsdelivr.net/npm/qrcode@1.4.4/build/qrcode.min.js";
document.body.appendChild(libQR);
})();