Upload index.html
Browse files- index.html +105 -19
index.html
CHANGED
|
@@ -1,19 +1,105 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1"><!-- your own page remains responsive -->
|
| 6 |
+
<title>Responsive Gamma Embed</title>
|
| 7 |
+
<style>
|
| 8 |
+
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
|
| 9 |
+
#custom-iframe { width: 100%; height: 100%; border: none; }
|
| 10 |
+
</style>
|
| 11 |
+
</head>
|
| 12 |
+
<body>
|
| 13 |
+
<iframe id="custom-iframe" sandbox="allow-scripts allow-same-origin allow-top-navigation-by-user-activation allow-popups"></iframe>
|
| 14 |
+
<script>
|
| 15 |
+
(async function() {
|
| 16 |
+
const targetUrl = 'https://scriptfunctionconst-sele-aijki1r.gamma.site/';
|
| 17 |
+
const proxyUrl = `https://embed-proxy-prod.gamma-app.workers.dev/?alt_url=${targetUrl}`;
|
| 18 |
+
|
| 19 |
+
try {
|
| 20 |
+
// forward your UA so SSR can pick mobile vs desktop
|
| 21 |
+
const res = await fetch(proxyUrl, {
|
| 22 |
+
mode: 'cors',
|
| 23 |
+
headers: {
|
| 24 |
+
'Accept': 'text/html',
|
| 25 |
+
'User-Agent': navigator.userAgent
|
| 26 |
+
}
|
| 27 |
+
});
|
| 28 |
+
if (!res.ok) throw new Error(`Status ${res.status}`);
|
| 29 |
+
let html = await res.text();
|
| 30 |
+
|
| 31 |
+
// --- 1) Inject viewport meta if missing ---
|
| 32 |
+
if (!/<meta\s+name=["']viewport["']/i.test(html)) {
|
| 33 |
+
html = html.replace(
|
| 34 |
+
/<head([^>]*)>/i,
|
| 35 |
+
headTag => headTag +
|
| 36 |
+
'\n <meta name="viewport" content="width=device-width, initial-scale=1">\n'
|
| 37 |
+
);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// --- 2) Inject your hide-elements script ---
|
| 41 |
+
const scriptContent = `
|
| 42 |
+
(function() {
|
| 43 |
+
try {
|
| 44 |
+
const SELECTORS = [
|
| 45 |
+
'.css-1c6hcbi',
|
| 46 |
+
'.chakra-button__group.css-1ayoy1w'
|
| 47 |
+
];
|
| 48 |
+
function hideTargets(root = document) {
|
| 49 |
+
if (root.querySelectorAll) {
|
| 50 |
+
SELECTORS.forEach(sel => {
|
| 51 |
+
root.querySelectorAll(sel).forEach(el => el.style.display = 'none');
|
| 52 |
+
});
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
function setup() {
|
| 56 |
+
if (!document.body) return setTimeout(setup, 100);
|
| 57 |
+
hideTargets();
|
| 58 |
+
new MutationObserver(muts => {
|
| 59 |
+
muts.forEach(m => {
|
| 60 |
+
if (m.type === 'childList') {
|
| 61 |
+
m.addedNodes.forEach(n => {
|
| 62 |
+
if (n.nodeType === Node.ELEMENT_NODE) hideTargets(n);
|
| 63 |
+
});
|
| 64 |
+
} else if (m.type === 'attributes' && m.target.matches(SELECTORS.join(','))) {
|
| 65 |
+
m.target.style.display = 'none';
|
| 66 |
+
}
|
| 67 |
+
});
|
| 68 |
+
}).observe(document.body, {
|
| 69 |
+
childList: true,
|
| 70 |
+
subtree: true,
|
| 71 |
+
attributes: true,
|
| 72 |
+
attributeFilter: ['class']
|
| 73 |
+
});
|
| 74 |
+
}
|
| 75 |
+
if (document.readyState !== 'loading') setup();
|
| 76 |
+
else document.addEventListener('DOMContentLoaded', setup);
|
| 77 |
+
} catch (e) {
|
| 78 |
+
console.error('Injected script error:', e);
|
| 79 |
+
}
|
| 80 |
+
})();
|
| 81 |
+
`;
|
| 82 |
+
const injection = `<script>${scriptContent}<\/script>`;
|
| 83 |
+
|
| 84 |
+
// add before </head> so responsive CSS & your script both load early
|
| 85 |
+
if (html.match(/<\/head>/i)) {
|
| 86 |
+
html = html.replace(/<\/head>/i, injection + '</head>');
|
| 87 |
+
} else {
|
| 88 |
+
html = injection + html;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
// serve via blob so same-origin + your script can run
|
| 92 |
+
const blob = new Blob([html], { type: 'text/html' });
|
| 93 |
+
const url = URL.createObjectURL(blob);
|
| 94 |
+
const iframe = document.getElementById('custom-iframe');
|
| 95 |
+
iframe.src = url;
|
| 96 |
+
iframe.onload = () => URL.revokeObjectURL(url);
|
| 97 |
+
|
| 98 |
+
} catch (err) {
|
| 99 |
+
console.error('Embed error:', err);
|
| 100 |
+
document.body.innerHTML = `<p style="color:red;">Error loading embed: ${err.message}</p>`;
|
| 101 |
+
}
|
| 102 |
+
})();
|
| 103 |
+
</script>
|
| 104 |
+
</body>
|
| 105 |
+
</html>
|