From 65fb96f67567d80112e2d3ea4c57dd064d60afc2 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Sun, 26 Jul 2026 22:38:10 +0200 Subject: [PATCH] f --- public/s/css/f0ckm.css | 2 +- src/index.mjs | 30 +++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/public/s/css/f0ckm.css b/public/s/css/f0ckm.css index 7669e5c..df2cbd2 100644 --- a/public/s/css/f0ckm.css +++ b/public/s/css/f0ckm.css @@ -1237,7 +1237,7 @@ html[theme='95'] .item-main-content .metadata { .notif-count { position: absolute; - top: 0px; + top: -5px; right: -5px; background: var(--badge-nsfw); color: white; diff --git a/src/index.mjs b/src/index.mjs index 9f17528..970015e 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -282,11 +282,35 @@ try { } // Called on every gated request — produces a fresh page with unique Ray ID + timestamp -// Accepts an optional request object to inject the visitor's real IP into the footer reveal. +// Accepts an optional request object to inject the visitor's real IP into the footer reveal and dynamic host into page text/title. function buildGatePage(req) { if (!_cfRender) return nginx502Fallback; - let html = _cfRender({ ...gateOptions, what_can_i_do: gateSignInButton }); + let reqHost = cfg.main.url.domain; + if (req && req.headers) { + const rawHost = req.headers['x-forwarded-host'] || req.headers['host']; + if (rawHost) { + const firstHost = rawHost.split(',')[0].trim(); + if (firstHost.startsWith('[')) { + const closeBracket = firstHost.indexOf(']'); + reqHost = closeBracket !== -1 ? firstHost.substring(1, closeBracket) : firstHost; + } else { + reqHost = firstHost.split(':')[0].trim(); + } + } + } + if (!reqHost) reqHost = cfg.main.url.domain; + + const currentGateOptions = { + ...gateOptions, + host_status: { + ...gateOptions.host_status, + location: reqHost, + }, + what_can_i_do: gateSignInButton, + }; + + let html = _cfRender(currentGateOptions); // Inject real visitor IP into the footer "Your IP: [Click to reveal]" span if (req) { @@ -305,7 +329,7 @@ function buildGatePage(req) { // Patch the to include the domain — matches real Cloudflare behaviour html = html.replace( '<title>502: Bad Gateway', - `${cfg.main.url.domain} | 502: Bad gateway` + `${reqHost} | 502: Bad gateway` ); html = html.replace('', gateLoginInjection + '\n'); return html;