Update index.html
Browse files- index.html +131 -131
index.html
CHANGED
|
@@ -1,132 +1,132 @@
|
|
| 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">
|
| 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://
|
| 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>
|
|
|
|
| 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">
|
| 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://akshay-365-9vx6m3k.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>
|