jump to fragment

This commit is contained in:
Cadence Ember
2025-11-15 14:28:09 +13:00
parent 94cb54a712
commit 7b2f96eb03

View File

@@ -34,20 +34,6 @@ window.proxy = new Proxy(jsonpData, {
}
})
// *** Page theme
// Try to make it a bit more accurate. Normally this is done server-side by sending a `theme=x` cookie with the parse request. But that's not possible in jsonp mode, and there's no equivalent URL query string to set the theme.
// Helps on Minecraft wiki. Might not be complete on some wikis.
cookieStore.get("theme").then(cookie => {
if (cookie && cookie.value !== "default") {
document.body.classList.remove("theme-fandomdesktop-light")
document.body.classList.remove("theme-fandomdesktop-dark")
document.body.removeAttribute("data-theme")
document.body.classList.add(`theme-fandomdesktop-${cookie.value}`)
document.body.setAttribute("data-theme", cookie.value)
}
})
// *** Data upload and download
async function cont() {
@@ -95,8 +81,21 @@ async function cont() {
// page -> #content
const imported = document.importNode(xhr.responseXML.getElementById("content"), true)
document.getElementById("content").replaceWith(imported)
// page theme
// Try to make it a bit more accurate. Normally this is done server-side by sending a `theme=x` cookie with the parse request. But that's not possible in jsonp mode, and there's no equivalent URL query string to set the theme.
// Helps on Minecraft wiki. Might not be complete on some wikis.
cookieStore.get("theme").then(cookie => {
if (cookie && cookie.value !== "default") {
document.body.classList.remove("theme-fandomdesktop-light")
document.body.classList.remove("theme-fandomdesktop-dark")
document.body.removeAttribute("data-theme")
document.body.classList.add(`theme-fandomdesktop-${cookie.value}`)
document.body.setAttribute("data-theme", cookie.value)
}
})
// <head>
document.title = xhr.responseXML.title
document.body.className = xhr.responseXML.body.className
for (const e of xhr.responseXML.head.children) {
const alreadyImported = [...document.querySelectorAll("link[href]")].map(e => e.href)
if (e.tagName === "LINK" && !alreadyImported.includes(e.href)) {
@@ -104,7 +103,11 @@ async function cont() {
document.head.appendChild(imported)
}
}
// Redirects
// scroll
if (location.hash) {
document.getElementById(location.hash.slice(1)).scrollIntoView({behavior: "instant"})
}
// redirects
const redirectTo = document.querySelector("#content .redirectMsg a")
if (redirectTo) {
redirectTo.click()