File size: 3,672 Bytes
442bf74
 
 
 
6636e90
 
442bf74
 
 
 
 
 
6636e90
442bf74
 
 
 
 
 
6636e90
 
 
 
 
 
 
 
 
442bf74
 
6636e90
 
 
 
 
 
 
442bf74
 
6636e90
 
 
 
 
 
 
 
 
 
 
 
 
d1b2d13
a8574b2
6636e90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
442bf74
6636e90
 
 
442bf74
6636e90
 
442bf74
 
 
 
 
6636e90
442bf74
6636e90
442bf74
6636e90
 
442bf74
 
6636e90
 
442bf74
 
 
 
ff29a47
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1"><!-- your own page remains responsive -->
  <title>Responsive Gamma Embed</title>
  <style>
    html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
    #custom-iframe { width: 100%; height: 100%; border: none; }
  </style>
</head>
<body>
  <iframe id="custom-iframe" sandbox="allow-scripts allow-same-origin allow-top-navigation-by-user-activation allow-popups"></iframe>
  <script>
  (async function() {
    const targetUrl = 'https://akshay-365-9vx6m3k.gamma.site/';
    const proxyUrl = `https://embed-proxy-prod.gamma-app.workers.dev/?alt_url=${targetUrl}`;

    try {
      // forward your UA so SSR can pick mobile vs desktop
      const res = await fetch(proxyUrl, {
        mode: 'cors',
        headers: {
          'Accept': 'text/html',
          'User-Agent': navigator.userAgent
        }
      });
      if (!res.ok) throw new Error(`Status ${res.status}`);
      let html = await res.text();

      // --- 1) Inject viewport meta if missing ---
      if (!/<meta\s+name=["']viewport["']/i.test(html)) {
        html = html.replace(
          /<head([^>]*)>/i,
          headTag => headTag +
            '\n  <meta name="viewport" content="width=device-width, initial-scale=1">\n'
        );
      }

      // --- 2) Inject your hide-elements script ---
      const scriptContent = `
      (function() {
        try {
          const SELECTORS = [
            '.css-1c6hcbi',
            '.chakra-button__group.css-1ayoy1w'
          ];
          function hideTargets(root = document) {
            if (root.querySelectorAll) {
              SELECTORS.forEach(sel => {
                root.querySelectorAll(sel).forEach(el => el.style.display = 'none');
              });
            }
          }
          function setup() {
            if (!document.body) return setTimeout(setup, 100);
            hideTargets();
            new MutationObserver(muts => {
              muts.forEach(m => {
                if (m.type === 'childList') {
                  m.addedNodes.forEach(n => {
                    if (n.nodeType === Node.ELEMENT_NODE) hideTargets(n);
                  });
                } else if (m.type === 'attributes' && m.target.matches(SELECTORS.join(','))) {
                  m.target.style.display = 'none';
                }
              });
            }).observe(document.body, {
              childList: true,
              subtree: true,
              attributes: true,
              attributeFilter: ['class']
            });
          }
          if (document.readyState !== 'loading') setup();
          else document.addEventListener('DOMContentLoaded', setup);
        } catch (e) {
          console.error('Injected script error:', e);
        }
      })();
      `;
      const injection = `<script>${scriptContent}<\/script>`;

      // add before </head> so responsive CSS & your script both load early
      if (html.match(/<\/head>/i)) {
        html = html.replace(/<\/head>/i, injection + '</head>');
      } else {
        html = injection + html;
      }

      // serve via blob so same-origin + your script can run
      const blob = new Blob([html], { type: 'text/html' });
      const url = URL.createObjectURL(blob);
      const iframe = document.getElementById('custom-iframe');
      iframe.src = url;
      iframe.onload = () => URL.revokeObjectURL(url);

    } catch (err) {
      console.error('Embed error:', err);
      document.body.innerHTML = `<p style="color:red;">Error loading embed: ${err.message}</p>`;
    }
  })();
  </script>
</body>
</html>