diff --git a/homepage/static/assets/js/captcha_refresh.js b/homepage/static/assets/js/captcha_refresh.js index dc2a7b9..47dcbc2 100644 --- a/homepage/static/assets/js/captcha_refresh.js +++ b/homepage/static/assets/js/captcha_refresh.js @@ -5,11 +5,15 @@ const captcha_hidden_field = document.forms[0].children[4].children[0]; let g_captcha_timeout_remain = g_captcha_timeout_seconds; let g_current_captcha_id = captcha_hidden_field.value; +function getColorScheme() { + return window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark"; +} + async function getNewCaptcha() { const id = await fetch("/captcha/").then(r => r.text()); g_current_captcha_id = id; captcha_hidden_field.value = id; - setTimeout(() => { captcha_img.src = `/captcha/${id}/image` }, 600); + setTimeout(() => { captcha_img.src = `/captcha/${id}/image?style=${getColorScheme()}` }, 600); g_captcha_timeout_remain = g_captcha_timeout_seconds; }