chb2025 commited on
Commit
f50c7ba
·
verified ·
1 Parent(s): 6f95258

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +44 -49
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 (more realistic for Hugging Face)
18
  const visitorCount = Math.floor(Math.random() * 30) + 15;
19
 
20
  const html = `
21
  <!DOCTYPE html>
22
  <html>
23
- <div style="display: flex; align-items: center; padding: 6px 10px; background: linear-gradient(to right, rgba(24,144,255,0.15), rgba(24,144,255,0.05)); border-radius: 6px; font-size: 13px; color: #1890ff; margin: 5px 0;">
24
- <span style="margin-right: 6px;">🕒</span>
25
- <div id="datetime-ip-info">Loading...</div>
26
- </div>
27
-
28
- <script>
29
- function updateInfo() {
30
- // Get current date and time
31
- const now = new Date();
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
- setTimeout(updateInfo, 60000); // Update every minute
66
- }
67
-
68
- // Run immediately when loaded
69
- updateInfo();
70
- </script>
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