File size: 1,876 Bytes
d8d87c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
How does this work

<!doctype html>
<html>
<head>
  <meta charset="utf-8" />
  <title>Capture tgWebAppData</title>
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <style>
    body { font-family: system-ui, Arial; padding: 18px; background:#0f0f10; color:#eaeaea; }
    textarea { width:100%; height:160px; background:#111; color:#eaeaea; border:1px solid #333; padding:8px; }
    button { padding:10px 14px; margin:8px 6px 0 0; }
    .note { color:#aaa; font-size:0.9rem; margin-top:8px }
  </style>
</head>
<body>
  <h3>Capture tgWebAppData</h3>
  <p>When opened in Telegram, this page will show the full URL (including <code>#tgWebAppData=…</code>).</p>
  <textarea id="out" readonly>Waiting for fragment…</textarea>
  <div>
    <button id="copy">Copy URL</button>
    <button id="continue">Continue to target</button>
  </div>
  <p class="note">Privacy: this page does NOT send data anywhere unless you add that behavior. The user should only share this URL if they consent.</p>

<script>
(async function(){
  const out = document.getElementById('out');
  const copyBtn = document.getElementById('copy');
  const cont = document.getElementById('continue');

  // show full href (includes fragment if present)
  const full = location.href;
  out.value = full;

  copyBtn.addEventListener('click', async () => {
    try {
      await navigator.clipboard.writeText(out.value);
      alert('URL copied to clipboard');
    } catch(e) {
      prompt('Copy this URL', out.value);
    }
  });

  cont.addEventListener('click', () => {
    const qs = new URLSearchParams(location.search);
    const target = qs.get('target') || '';
    if (!target) {
      alert('No target specified in ?target=...');
      return;
    }
    // preserve same fragment when forwarding
    location.replace(target + location.hash);
  });
})();
</script>
</body>
</html>