Update index.js
Browse files
index.js
CHANGED
@@ -14,61 +14,56 @@ app.get('/', (req, res) => {
|
|
14 |
const options = { weekday: 'short', hour: '2-digit', minute: '2-digit' };
|
15 |
const timeString = now.toLocaleDateString(undefined, options);
|
16 |
|
17 |
-
// Generate random visitor count
|
18 |
const visitorCount = Math.floor(Math.random() * 30) + 15;
|
19 |
|
20 |
const html = `
|
21 |
<!DOCTYPE html>
|
22 |
<html>
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
const options = { weekday: 'short', hour: '2-digit', minute: '2-digit' };
|
33 |
-
const timeString = now.toLocaleDateString(undefined, options);
|
34 |
-
|
35 |
-
// Get IP (without external API - this is a simple approach)
|
36 |
-
if(!window.myIpAddress) {
|
37 |
-
// Create connection to STUN server to get IP
|
38 |
-
const pc = new RTCPeerConnection({iceServers: [{urls: "stun:stun.l.google.com:19302"}]});
|
39 |
-
pc.createDataChannel("");
|
40 |
-
pc.onicecandidate = function(e) {
|
41 |
-
if(!e.candidate) return;
|
42 |
-
// Extract IP address
|
43 |
-
const ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3})/;
|
44 |
-
const ipMatch = ipRegex.exec(e.candidate.candidate);
|
45 |
-
if(ipMatch) {
|
46 |
-
window.myIpAddress = ipMatch[1];
|
47 |
-
document.getElementById('datetime-ip-info').innerHTML =
|
48 |
-
`${timeString} • IP: ${window.myIpAddress}`;
|
49 |
-
}
|
50 |
-
};
|
51 |
-
pc.createOffer().then(offer => pc.setLocalDescription(offer));
|
52 |
-
|
53 |
-
// Fallback if IP detection fails
|
54 |
-
setTimeout(() => {
|
55 |
-
if(!window.myIpAddress) {
|
56 |
-
document.getElementById('datetime-ip-info').innerHTML =
|
57 |
-
`${timeString} • IP: Unavailable`;
|
58 |
-
}
|
59 |
-
}, 1000);
|
60 |
-
} else {
|
61 |
-
document.getElementById('datetime-ip-info').innerHTML =
|
62 |
-
`${timeString} • IP: ${window.myIpAddress}`;
|
63 |
}
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
</html>
|
73 |
`;
|
74 |
|
|
|
14 |
const options = { weekday: 'short', hour: '2-digit', minute: '2-digit' };
|
15 |
const timeString = now.toLocaleDateString(undefined, options);
|
16 |
|
17 |
+
// Generate random visitor count
|
18 |
const visitorCount = Math.floor(Math.random() * 30) + 15;
|
19 |
|
20 |
const html = `
|
21 |
<!DOCTYPE html>
|
22 |
<html>
|
23 |
+
<head>
|
24 |
+
<meta charset="UTF-8">
|
25 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
26 |
+
<style>
|
27 |
+
body, html {
|
28 |
+
margin: 0;
|
29 |
+
padding: 0;
|
30 |
+
height: 100%;
|
31 |
+
font-family: Arial, sans-serif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
+
.container {
|
34 |
+
display: flex;
|
35 |
+
align-items: center;
|
36 |
+
padding: 8px 12px;
|
37 |
+
background: linear-gradient(135deg, #ff0844 0%, #8000ff 50%, #0061ff 100%);
|
38 |
+
border-radius: 6px;
|
39 |
+
color: white;
|
40 |
+
height: 100%;
|
41 |
+
box-sizing: border-box;
|
42 |
+
}
|
43 |
+
.clock-emoji {
|
44 |
+
margin-right: 8px;
|
45 |
+
font-size: 16px;
|
46 |
+
}
|
47 |
+
.info-text {
|
48 |
+
font-size: 14px;
|
49 |
+
white-space: nowrap;
|
50 |
+
overflow: hidden;
|
51 |
+
text-overflow: ellipsis;
|
52 |
+
}
|
53 |
+
</style>
|
54 |
+
</head>
|
55 |
+
<body>
|
56 |
+
<div class="container">
|
57 |
+
<span class="clock-emoji">🕒</span>
|
58 |
+
<span class="info-text">${timeString} • Online: ${visitorCount} • IP: ${clientIp}</span>
|
59 |
+
</div>
|
60 |
+
<script>
|
61 |
+
// Reload the page every minute to update time
|
62 |
+
setTimeout(() => {
|
63 |
+
window.location.reload();
|
64 |
+
}, 60000);
|
65 |
+
</script>
|
66 |
+
</body>
|
67 |
</html>
|
68 |
`;
|
69 |
|