| <!DOCTYPE html>
|
| <html lang="en">
|
| <head>
|
| <meta charset="utf-8">
|
| <meta name="viewport" content="width=device-width, initial-scale=1">
|
| <title>Custom Embed for Gamma Site</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"></iframe>
|
| <script>
|
| (async function() {
|
| const targetUrl = 'https://meager-insect-x9oto7l.gamma.site/';
|
| const proxyUrl = `https://embed-proxy-prod.gamma-app.workers.dev/?alt_url=${targetUrl}`;
|
|
|
| try {
|
| console.log('Fetching proxy URL:', proxyUrl);
|
| const res = await fetch(proxyUrl, { mode: 'cors' });
|
| if (!res.ok) {
|
| const errorText = await res.text().catch(() => 'No response text');
|
| throw new Error(`Fetch failed with status ${res.status}: ${errorText}`);
|
| }
|
| let html = await res.text();
|
| console.log('Fetched HTML length:', html.length);
|
|
|
|
|
| const scriptContent = `
|
| (function() {
|
| try {
|
| console.log('Custom embed script loaded in iframe');
|
|
|
| const SELECTORS = [
|
| '.css-1c6hcbi',
|
| '.chakra-button__group.css-1ayoy1w'
|
| ];
|
|
|
| function hideTargets(root = document) {
|
| // Make sure root is an Element or Document before calling querySelectorAll
|
| if (root.querySelectorAll) {
|
| SELECTORS.forEach(selector => {
|
| root.querySelectorAll(selector).forEach(el => {
|
| console.log('Hiding element:', el);
|
| el.style.display = 'none';
|
| });
|
| });
|
| }
|
| }
|
|
|
| function setupObserver() {
|
| if (!document.body) {
|
| console.warn('Body not ready, retrying in 100ms...');
|
| return setTimeout(setupObserver, 100);
|
| }
|
|
|
| hideTargets();
|
|
|
| const observer = new MutationObserver(mutations => {
|
| for (const mutation of mutations) {
|
| if (mutation.type === 'childList') {
|
| mutation.addedNodes.forEach(node => {
|
| if (node.nodeType === Node.ELEMENT_NODE) {
|
| hideTargets(node);
|
| }
|
| });
|
| } else if (mutation.type === 'attributes') {
|
| if (mutation.target.matches(SELECTORS.join(','))) {
|
| console.log('Hiding updated element:', mutation.target);
|
| mutation.target.style.display = 'none';
|
| }
|
| }
|
| }
|
| });
|
|
|
| observer.observe(document.body, {
|
| childList: true,
|
| subtree: true,
|
| attributes: true,
|
| attributeFilter: ['class']
|
| });
|
|
|
| console.log('MutationObserver set up!');
|
| }
|
|
|
| if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
| setupObserver();
|
| } else {
|
| document.addEventListener('DOMContentLoaded', setupObserver);
|
| }
|
| } catch (err) {
|
| console.error('Error in injected script:', err);
|
| }
|
| })();
|
| `;
|
|
|
| const injection = `<script>${scriptContent}<\/script>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| if (html.includes('</head>')) {
|
| html = html.replace(/<\/head>/i, injection + '</head>');
|
| } else {
|
| console.warn('No </head> tag found, prepending script');
|
| html = injection + html;
|
| }
|
|
|
|
|
| const blob = new Blob([html], { type: 'text/html' });
|
| const blobUrl = URL.createObjectURL(blob);
|
|
|
| const iframe = document.getElementById('custom-iframe');
|
| iframe.src = blobUrl;
|
|
|
|
|
| iframe.onload = () => {
|
| console.log('Iframe loaded');
|
| URL.revokeObjectURL(blobUrl);
|
| };
|
|
|
| } catch (err) {
|
| console.error('Error in fetch or injection:', err);
|
| document.body.innerHTML = `<p style="color:red;">Error loading content: ${err.message}</p>`;
|
| }
|
| })();
|
| </script>
|
| </body>
|
| </html> |