show captcha correctly if page unloads

This commit is contained in:
Cadence Ember
2025-11-13 01:06:32 +13:00
parent b2fe4ec61a
commit f4907a7b77
2 changed files with 18 additions and 15 deletions

View File

@@ -92,21 +92,21 @@
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "internal.css")))) (link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "internal.css"))))
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css")))) (link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
(link (@ (rel "icon") (href ,(head-data^-icon-url head-data-default)))) (link (@ (rel "icon") (href ,(head-data^-icon-url head-data-default))))
(script (@ (defer) (src ,(get-static-url "captcha.js")))) (script (@ (defer) (src ,(get-static-url "captcha.js")))))
(body (@ (class "skin-fandomdesktop theme-fandomdesktop-light internal")) (body (@ (class "skin-fandomdesktop theme-fandomdesktop-light internal"))
(div (@ (class "main-container")) (div (@ (class "main-container"))
(div (@ (class "fandom-community-header__background tileBoth header"))) (div (@ (class "fandom-community-header__background tileBoth header")))
(div (@ (class "page")) (div (@ (class "page"))
(main (@ (class "page__main")) (main (@ (class "page__main"))
(div (@ (class "custom-top")) (div (@ (class "custom-top"))
(h1 (@ (class "page-title")) (h1 (@ (class "page-title"))
"Checking you're not a bot...")) "Checking you're not a bot..."))
(div (@ (id "content") #;(class "page-content")) (div (@ (id "content") #;(class "page-content"))
(div (@ (id "mw-content-text")) (div (@ (id "mw-content-text"))
(p "To confirm, please click directly in the circle, or hold down the " ,(~a (get-key-solution req)) " key on your keyboard.") (p "To confirm, please click directly in the circle, or hold down the " ,(~a (get-key-solution req)) " key on your keyboard.")
(noscript (p "JavaScript is required for the captcha. Sorry!")) (noscript (p "JavaScript is required for the captcha. Sorry!"))
(div (@ (id "captcha-area"))))) (div (@ (id "captcha-area")))))
,(application-footer #f))))))))) ,(application-footer #f))))))))
(when (config-true? 'debug) (when (config-true? 'debug)
(xexp->html body)) (xexp->html body))
(response/output (response/output

View File

@@ -88,7 +88,10 @@ async function cont() {
xhr.addEventListener("load", () => { xhr.addEventListener("load", () => {
console.log(xhr) console.log(xhr)
// check for errors
if (xhr.status === 500) return fetch(pkg.url, pkg.init).then(res => res.text()).then(error) if (xhr.status === 500) return fetch(pkg.url, pkg.init).then(res => res.text()).then(error)
// check for captcha screen
if (xhr.responseXML.head.querySelector('script[src*="captcha.js"]')) return location.reload()
// page -> #content // page -> #content
const imported = document.importNode(xhr.responseXML.getElementById("content"), true) const imported = document.importNode(xhr.responseXML.getElementById("content"), true)
document.getElementById("content").replaceWith(imported) document.getElementById("content").replaceWith(imported)