f #24

Merged
kibi merged 1 commits from master into 98 2026-07-26 20:47:21 +00:00
2 changed files with 28 additions and 4 deletions
Showing only changes of commit 65fb96f675 - Show all commits

View File

@@ -1237,7 +1237,7 @@ html[theme='95'] .item-main-content .metadata {
.notif-count { .notif-count {
position: absolute; position: absolute;
top: 0px; top: -5px;
right: -5px; right: -5px;
background: var(--badge-nsfw); background: var(--badge-nsfw);
color: white; color: white;

View File

@@ -282,11 +282,35 @@ try {
} }
// Called on every gated request — produces a fresh page with unique Ray ID + timestamp // 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) { function buildGatePage(req) {
if (!_cfRender) return nginx502Fallback; 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 // Inject real visitor IP into the footer "Your IP: [Click to reveal]" span
if (req) { if (req) {
@@ -305,7 +329,7 @@ function buildGatePage(req) {
// Patch the <title> to include the domain — matches real Cloudflare behaviour // Patch the <title> to include the domain — matches real Cloudflare behaviour
html = html.replace( html = html.replace(
'<title>502: Bad Gateway</title>', '<title>502: Bad Gateway</title>',
`<title>${cfg.main.url.domain} | 502: Bad gateway</title>` `<title>${reqHost} | 502: Bad gateway</title>`
); );
html = html.replace('</body>', gateLoginInjection + '\n</body>'); html = html.replace('</body>', gateLoginInjection + '\n</body>');
return html; return html;