Fix
This commit is contained in:
@@ -45,13 +45,24 @@ data:
|
||||
# Replace default Dynmap title with custom server name
|
||||
sub_filter 'Minecraft Dynamic Map' "Hexor's MC server";
|
||||
|
||||
# Inject all custom content before closing body tag (single replacement)
|
||||
sub_filter "</body>" '<script>function getUsername(){var headers=document.querySelectorAll("meta");for(var i=0;i<headers.length;i++){if(headers[i].getAttribute("name")==="remote-user"){return headers[i].getAttribute("content");}}var jwt=document.cookie.split("; ").find(row=>row.startsWith("authentik_session="));if(jwt){try{var token=jwt.split("=")[1];var payload=JSON.parse(atob(token.split(".")[1]));return payload.sub||payload.username||"web-user";}catch(e){}}return "web-user";}var username=getUsername();console.log("Username found:", username);if(username && username!=="web-user" && window.location.search.indexOf("playername=")===-1){var currentUrl=new URL(window.location.href);currentUrl.searchParams.set("playername",username);console.log("Redirecting to:", currentUrl.href);window.location.href=currentUrl.href;}document.addEventListener("DOMContentLoaded",function(){var userBlock=document.createElement("div");userBlock.style.cssText="background-color: #CEC6CB; color: black; padding: 8px; text-align: center; font-size: medium; border-radius: 4px; position: absolute; top: 10px; right: 150px; max-width: 200px;";userBlock.innerHTML="Logged in as: <b>"+username+"</b>";document.body.appendChild(userBlock);});</script><p style="background-color: #CEC6CB; color: black; padding: 10px 10px; text-align: center; font-size: large; text-decoration: none; display: inline-block; border-radius: 4px; position: absolute; top: 10px; left: 150px;">GEYMERSKIY SOYUZ Server <br>Get <a href="https://github.com/PrismLauncher/PrismLauncher/releases/tag/8.4" >Prism Launcher</a> and <a href="/clients/1.12.2.zip" >client.zip</a> for this server. Server address <b>minecraft.hexor.cy:30565</b><br>Requires <a href="https://www.java.com/en/download/manual.jsp">Java 8</a><br><br><a href="#" onclick="showInstallModal(); return false;" style="color: black; text-decoration: underline;">Windows Install Script</a></p><div id="installModal" style="display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5);"><div style="background-color: #CEC6CB; margin: 15% auto; padding: 10px; border-radius: 4px; width: 70%; max-width: 500px; text-align: center; color: black; font-size: large;"><h3 style="margin-top: 0; color: black;">Windows Installation</h3><p style="color: black;">Copy and paste this command into PowerShell:</p><textarea id="scriptCommand" readonly style="width: 90%; height: 60px; font-family: monospace; padding: 8px; border: 1px solid #888; border-radius: 4px; resize: none; background-color: white; color: black;"></textarea><br><br><button id="copyButton" onclick="copyToClipboard()" style="background-color: #CEC6CB; color: black; padding: 10px 15px; border: 1px solid #888; border-radius: 4px; cursor: pointer; margin-right: 10px; font-size: large; text-decoration: none;">Copy</button><button onclick="closeInstallModal()" style="background-color: #CEC6CB; color: black; padding: 10px 15px; border: 1px solid #888; border-radius: 4px; cursor: pointer; font-size: large; text-decoration: none;">Close</button></div></div><script>function showInstallModal() { document.getElementById("installModal").style.display = "block"; var d=String.fromCharCode(36);var q=String.fromCharCode(39);var cmd=d+"f="+String.fromCharCode(34)+d+"env:TEMP\\mc-install.ps1"+String.fromCharCode(34)+"; iwr -useb https://minecraft.hexor.cy/clients/win-install.ps1 -OutFile "+d+"f; & "+d+"f -Username "+q+username+q+"; Remove-Item "+d+"f"; document.getElementById("scriptCommand").value=cmd; } function closeInstallModal() { document.getElementById("installModal").style.display = "none"; } function copyToClipboard() { var textarea = document.getElementById("scriptCommand"); textarea.select(); textarea.setSelectionRange(0, 99999); if (document.execCommand("copy")) { var button = document.getElementById("copyButton"); button.style.borderColor = "#4CAF50"; setTimeout(function() { button.style.borderColor = "#888"; }, 2000); } } window.onclick = function(event) { var modal = document.getElementById("installModal"); if (event.target == modal) { closeInstallModal(); } }</script></body>';
|
||||
# Inject custom script before closing body tag
|
||||
sub_filter "</body>" '<script src="/clients/inject.js"></script></body>';
|
||||
|
||||
# Apply sub_filter replacements globally (not just once)
|
||||
sub_filter_once off;
|
||||
}
|
||||
|
||||
# Serve inject.js and .ps1 scripts inline (no forced download)
|
||||
location = /clients/inject.js {
|
||||
alias /mc/clients/inject.js;
|
||||
default_type application/javascript;
|
||||
}
|
||||
|
||||
location ~ ^/clients/(.+\.ps1)$ {
|
||||
alias /mc/clients/$1;
|
||||
default_type text/plain;
|
||||
}
|
||||
|
||||
# Static file serving for client downloads
|
||||
location /clients/ {
|
||||
alias /mc/clients/;
|
||||
@@ -68,9 +79,110 @@ data:
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: win-install-script
|
||||
name: client-scripts
|
||||
namespace: minecraft
|
||||
data:
|
||||
inject.js: |
|
||||
(function() {
|
||||
function getUsername() {
|
||||
var metas = document.querySelectorAll("meta");
|
||||
for (var i = 0; i < metas.length; i++) {
|
||||
if (metas[i].getAttribute("name") === "remote-user") {
|
||||
return metas[i].getAttribute("content");
|
||||
}
|
||||
}
|
||||
var jwt = document.cookie.split("; ").find(function(row) {
|
||||
return row.startsWith("authentik_session=");
|
||||
});
|
||||
if (jwt) {
|
||||
try {
|
||||
var token = jwt.split("=")[1];
|
||||
var payload = JSON.parse(atob(token.split(".")[1]));
|
||||
return payload.sub || payload.username || "web-user";
|
||||
} catch(e) {}
|
||||
}
|
||||
return "web-user";
|
||||
}
|
||||
|
||||
var username = getUsername();
|
||||
console.log("Username found:", username);
|
||||
|
||||
if (username && username !== "web-user" &&
|
||||
window.location.search.indexOf("playername=") === -1) {
|
||||
var currentUrl = new URL(window.location.href);
|
||||
currentUrl.searchParams.set("playername", username);
|
||||
console.log("Redirecting to:", currentUrl.href);
|
||||
window.location.href = currentUrl.href;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// User block
|
||||
var userBlock = document.createElement("div");
|
||||
userBlock.style.cssText = "background-color:#CEC6CB;color:black;padding:8px;text-align:center;font-size:medium;border-radius:4px;position:absolute;top:10px;right:150px;max-width:200px;";
|
||||
userBlock.innerHTML = "Logged in as: <b>" + username + "</b>";
|
||||
document.body.appendChild(userBlock);
|
||||
|
||||
// Info block
|
||||
var infoBlock = document.createElement("p");
|
||||
infoBlock.style.cssText = "background-color:#CEC6CB;color:black;padding:10px;text-align:center;font-size:large;display:inline-block;border-radius:4px;position:absolute;top:10px;left:150px;";
|
||||
infoBlock.innerHTML = 'GEYMERSKIY SOYUZ Server<br>'
|
||||
+ 'Get <a href="https://github.com/PrismLauncher/PrismLauncher/releases/tag/8.4">Prism Launcher</a> '
|
||||
+ 'and <a href="/clients/1.12.2.zip">client.zip</a> for this server. '
|
||||
+ 'Server address <b>minecraft.hexor.cy:30565</b><br>'
|
||||
+ 'Requires <a href="https://www.java.com/en/download/manual.jsp">Java 8</a><br><br>'
|
||||
+ '<a href="#" id="showInstallBtn" style="color:black;text-decoration:underline;">Windows Install Script</a>';
|
||||
document.body.appendChild(infoBlock);
|
||||
|
||||
// Modal
|
||||
var modal = document.createElement("div");
|
||||
modal.id = "installModal";
|
||||
modal.style.cssText = "display:none;position:fixed;z-index:1000;left:0;top:0;width:100%;height:100%;background-color:rgba(0,0,0,0.5);";
|
||||
modal.innerHTML = '<div style="background-color:#CEC6CB;margin:15% auto;padding:10px;border-radius:4px;width:70%;max-width:500px;text-align:center;color:black;font-size:large;">'
|
||||
+ '<h3 style="margin-top:0;color:black;">Windows Installation</h3>'
|
||||
+ '<p style="color:black;">Copy and paste this command into PowerShell:</p>'
|
||||
+ '<textarea id="scriptCommand" readonly style="width:90%;height:60px;font-family:monospace;padding:8px;border:1px solid #888;border-radius:4px;resize:none;background-color:white;color:black;"></textarea>'
|
||||
+ '<br><br>'
|
||||
+ '<button id="copyButton" style="background-color:#CEC6CB;color:black;padding:10px 15px;border:1px solid #888;border-radius:4px;cursor:pointer;margin-right:10px;font-size:large;">Copy</button>'
|
||||
+ '<button id="closeButton" style="background-color:#CEC6CB;color:black;padding:10px 15px;border:1px solid #888;border-radius:4px;cursor:pointer;font-size:large;">Close</button>'
|
||||
+ '</div>';
|
||||
document.body.appendChild(modal);
|
||||
|
||||
// Generate PowerShell command with username
|
||||
function buildPsCommand() {
|
||||
var d = "$";
|
||||
var q = "'";
|
||||
return d + 'f="' + d + 'env:TEMP\\mc-install.ps1"; iwr -useb https://minecraft.hexor.cy/clients/win-install.ps1 -OutFile '
|
||||
+ d + 'f; & ' + d + 'f -Username ' + q + username + q + '; Remove-Item ' + d + 'f';
|
||||
}
|
||||
|
||||
document.getElementById("showInstallBtn").addEventListener("click", function(e) {
|
||||
e.preventDefault();
|
||||
modal.style.display = "block";
|
||||
document.getElementById("scriptCommand").value = buildPsCommand();
|
||||
});
|
||||
|
||||
document.getElementById("closeButton").addEventListener("click", function() {
|
||||
modal.style.display = "none";
|
||||
});
|
||||
|
||||
document.getElementById("copyButton").addEventListener("click", function() {
|
||||
var textarea = document.getElementById("scriptCommand");
|
||||
textarea.select();
|
||||
textarea.setSelectionRange(0, 99999);
|
||||
document.execCommand("copy");
|
||||
var btn = document.getElementById("copyButton");
|
||||
btn.style.borderColor = "#4CAF50";
|
||||
setTimeout(function() { btn.style.borderColor = "#888"; }, 2000);
|
||||
});
|
||||
|
||||
modal.addEventListener("click", function(event) {
|
||||
if (event.target === modal) {
|
||||
modal.style.display = "none";
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
win-install.ps1: |
|
||||
# Game Setup Script for PrismLauncher and Minecraft Client
|
||||
# This script downloads and configures PrismLauncher with Hexor client
|
||||
|
||||
@@ -28,9 +28,9 @@ spec:
|
||||
- name: nginx-config
|
||||
configMap:
|
||||
name: nginx-config
|
||||
- name: win-install-script
|
||||
- name: client-scripts
|
||||
configMap:
|
||||
name: win-install-script
|
||||
name: client-scripts
|
||||
|
||||
terminationGracePeriodSeconds: 10
|
||||
containers:
|
||||
@@ -115,9 +115,12 @@ spec:
|
||||
subPath: nginx.conf
|
||||
- name: storage
|
||||
mountPath: /mc
|
||||
- name: win-install-script
|
||||
- name: client-scripts
|
||||
mountPath: /mc/clients/win-install.ps1
|
||||
subPath: win-install.ps1
|
||||
- name: client-scripts
|
||||
mountPath: /mc/clients/inject.js
|
||||
subPath: inject.js
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
|
||||
Reference in New Issue
Block a user