Upload index.html
Browse files- index.html +96 -69
index.html
CHANGED
|
@@ -2,104 +2,131 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1"
|
| 6 |
-
<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
|
| 14 |
<script>
|
| 15 |
(async function() {
|
| 16 |
-
const targetUrl = 'https://
|
| 17 |
const proxyUrl = `https://embed-proxy-prod.gamma-app.workers.dev/?alt_url=${targetUrl}`;
|
| 18 |
|
| 19 |
try {
|
| 20 |
-
|
| 21 |
-
const res = await fetch(proxyUrl, {
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
}
|
| 27 |
-
});
|
| 28 |
-
if (!res.ok) throw new Error(`Status ${res.status}`);
|
| 29 |
let html = await res.text();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
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 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
html = html.replace(/<\/head>/i, injection + '</head>');
|
| 87 |
} else {
|
|
|
|
| 88 |
html = injection + html;
|
| 89 |
}
|
| 90 |
|
| 91 |
-
//
|
| 92 |
const blob = new Blob([html], { type: 'text/html' });
|
| 93 |
-
const
|
|
|
|
| 94 |
const iframe = document.getElementById('custom-iframe');
|
| 95 |
-
iframe.src =
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
} catch (err) {
|
| 99 |
-
console.error('
|
| 100 |
-
document.body.innerHTML = `<p style="color:red;">Error loading
|
| 101 |
}
|
| 102 |
})();
|
| 103 |
</script>
|
| 104 |
</body>
|
| 105 |
-
</html>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>Custom Embed for Gamma Site</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"></iframe>
|
| 14 |
<script>
|
| 15 |
(async function() {
|
| 16 |
+
const targetUrl = 'https://meager-insect-x9oto7l.gamma.site/';
|
| 17 |
const proxyUrl = `https://embed-proxy-prod.gamma-app.workers.dev/?alt_url=${targetUrl}`;
|
| 18 |
|
| 19 |
try {
|
| 20 |
+
console.log('Fetching proxy URL:', proxyUrl);
|
| 21 |
+
const res = await fetch(proxyUrl, { mode: 'cors' });
|
| 22 |
+
if (!res.ok) {
|
| 23 |
+
const errorText = await res.text().catch(() => 'No response text');
|
| 24 |
+
throw new Error(`Fetch failed with status ${res.status}: ${errorText}`);
|
| 25 |
+
}
|
|
|
|
|
|
|
|
|
|
| 26 |
let html = await res.text();
|
| 27 |
+
console.log('Fetched HTML length:', html.length);
|
| 28 |
+
|
| 29 |
+
// Injection payload: custom script to hide elements
|
| 30 |
+
const scriptContent = `
|
| 31 |
+
(function() {
|
| 32 |
+
try {
|
| 33 |
+
console.log('Custom embed script loaded in iframe');
|
| 34 |
|
| 35 |
+
const SELECTORS = [
|
| 36 |
+
'.css-1c6hcbi',
|
| 37 |
+
'.chakra-button__group.css-1ayoy1w'
|
| 38 |
+
];
|
| 39 |
+
|
| 40 |
+
function hideTargets(root = document) {
|
| 41 |
+
// Make sure root is an Element or Document before calling querySelectorAll
|
| 42 |
+
if (root.querySelectorAll) {
|
| 43 |
+
SELECTORS.forEach(selector => {
|
| 44 |
+
root.querySelectorAll(selector).forEach(el => {
|
| 45 |
+
console.log('Hiding element:', el);
|
| 46 |
+
el.style.display = 'none';
|
| 47 |
+
});
|
| 48 |
+
});
|
| 49 |
}
|
| 50 |
+
}
|
| 51 |
|
| 52 |
+
function setupObserver() {
|
| 53 |
+
if (!document.body) {
|
| 54 |
+
console.warn('Body not ready, retrying in 100ms...');
|
| 55 |
+
return setTimeout(setupObserver, 100);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
hideTargets();
|
| 59 |
+
|
| 60 |
+
const observer = new MutationObserver(mutations => {
|
| 61 |
+
for (const mutation of mutations) {
|
| 62 |
+
if (mutation.type === 'childList') {
|
| 63 |
+
mutation.addedNodes.forEach(node => {
|
| 64 |
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
| 65 |
+
hideTargets(node);
|
| 66 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
});
|
| 68 |
+
} else if (mutation.type === 'attributes') {
|
| 69 |
+
if (mutation.target.matches(SELECTORS.join(','))) {
|
| 70 |
+
console.log('Hiding updated element:', mutation.target);
|
| 71 |
+
mutation.target.style.display = 'none';
|
| 72 |
+
}
|
| 73 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
}
|
| 75 |
+
});
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
observer.observe(document.body, {
|
| 78 |
+
childList: true,
|
| 79 |
+
subtree: true,
|
| 80 |
+
attributes: true,
|
| 81 |
+
attributeFilter: ['class']
|
| 82 |
+
});
|
| 83 |
+
|
| 84 |
+
console.log('MutationObserver set up!');
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
| 88 |
+
setupObserver();
|
| 89 |
+
} else {
|
| 90 |
+
document.addEventListener('DOMContentLoaded', setupObserver);
|
| 91 |
+
}
|
| 92 |
+
} catch (err) {
|
| 93 |
+
console.error('Error in injected script:', err);
|
| 94 |
+
}
|
| 95 |
+
})();
|
| 96 |
+
`;
|
| 97 |
+
|
| 98 |
+
const injection = `<script>${scriptContent}<\/script>`;
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
// Inject script into <head> to avoid breaking body scripts
|
| 105 |
+
if (html.includes('</head>')) {
|
| 106 |
html = html.replace(/<\/head>/i, injection + '</head>');
|
| 107 |
} else {
|
| 108 |
+
console.warn('No </head> tag found, prepending script');
|
| 109 |
html = injection + html;
|
| 110 |
}
|
| 111 |
|
| 112 |
+
// Create Blob for same-origin iframe
|
| 113 |
const blob = new Blob([html], { type: 'text/html' });
|
| 114 |
+
const blobUrl = URL.createObjectURL(blob);
|
| 115 |
+
|
| 116 |
const iframe = document.getElementById('custom-iframe');
|
| 117 |
+
iframe.src = blobUrl;
|
| 118 |
+
|
| 119 |
+
// Clean up Blob URL after load
|
| 120 |
+
iframe.onload = () => {
|
| 121 |
+
console.log('Iframe loaded');
|
| 122 |
+
URL.revokeObjectURL(blobUrl);
|
| 123 |
+
};
|
| 124 |
|
| 125 |
} catch (err) {
|
| 126 |
+
console.error('Error in fetch or injection:', err);
|
| 127 |
+
document.body.innerHTML = `<p style="color:red;">Error loading content: ${err.message}</p>`;
|
| 128 |
}
|
| 129 |
})();
|
| 130 |
</script>
|
| 131 |
</body>
|
| 132 |
+
</html>
|