From ee662f2b5627eb683975587dde80da51f065b8ec Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Fri, 29 Aug 2025 19:22:34 +0000 Subject: [PATCH] fix(challenges/xeact): add noscript warning Signed-off-by: Xe Iaso --- lib/challenge/preact/js/xeact.js | 9 +++++++++ lib/challenge/preact/preact.templ | 3 +++ lib/challenge/preact/preact_templ.go | 15 ++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/challenge/preact/js/xeact.js b/lib/challenge/preact/js/xeact.js index 2cbcf4cb..cf4a102e 100644 --- a/lib/challenge/preact/js/xeact.js +++ b/lib/challenge/preact/js/xeact.js @@ -115,6 +115,15 @@ const d = (ms) => { }; }; +/** + * Parse the contents of a given HTML page element as JSON and + * return the results. + * + * This is useful when using templ to pass complicated data from + * the server to the client via HTML[1]. + * + * [1]: https://templ.guide/syntax-and-usage/script-templates/#pass-server-side-data-to-the-client-in-a-html-attribute + */ const j = (id) => JSON.parse(g(id).textContent); export { h, t, x, g, j, c, n, u, s, r, useState, d }; diff --git a/lib/challenge/preact/preact.templ b/lib/challenge/preact/preact.templ index b3db0c75..5323ad7e 100644 --- a/lib/challenge/preact/preact.templ +++ b/lib/challenge/preact/preact.templ @@ -17,5 +17,8 @@ templ page(redir, challenge string, difficulty int, loc *localization.SimpleLoca "pensive_url": anubis.BasePrefix + "/.within.website/x/cmd/anubis/static/img/pensive.webp?cacheBuster=" + anubis.Version, }) @templ.ComponentFunc(renderAppJS) + } diff --git a/lib/challenge/preact/preact_templ.go b/lib/challenge/preact/preact_templ.go index ac23af9b..7e683843 100644 --- a/lib/challenge/preact/preact_templ.go +++ b/lib/challenge/preact/preact_templ.go @@ -53,7 +53,20 @@ func page(redir, challenge string, difficulty int, loc *localization.SimpleLocal if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }