iframe.src-blobUrl / index.html
AstraOS's picture
Update index.html
4ceca70 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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-popups allow-forms Access-Control-Allow-Origin allow-top-navigation-by-user-activation"></iframe>
<script>
const loadUrlIntoIframe = async (url) => {
try {
const res = await fetch(url, {
mode: 'cors',
headers: {
'Accept': 'text/html',
'User-Agent': navigator.userAgent
}
});
if (!res.ok) throw new Error(`Status ${res.status}`);
let html = await res.text();
// Inject override.js into the page
const overrideScript = await fetch('override.js').then(r => r.text());
const injection = `<script>${overrideScript}<\/script>`;
html = html.replace(/<\/head>/i, injection + '</head>');
// Serve as blob so it runs in same origin context
const blob = new Blob([html], { type: 'text/html' });
const blobUrl = URL.createObjectURL(blob);
const iframe = document.getElementById('custom-iframe');
iframe.src = blobUrl;
iframe.onload = () => URL.revokeObjectURL(blobUrl);
} catch (err) {
console.error('Embed error:', err);
document.body.innerHTML = `<p style="color:red;">Error loading embed: ${err.message}</p>`;
}
};
const default_url = 'https://www.example.com/'
// Initial page load
const targetUrl = default_url;
const initialUrl = `https://embed-proxy-prod.gamma-app.workers.dev/?alt_url=${targetUrl}`;
// const initialUrl = `https://888cfbae6aba7e08f9611637801ab91ec9bd3a08-m.proxy1.startpage.com/npd/fftzep/ST/mKNLdLUFGhRSP6lcQQfhPfTcQ//////////SURFLYROOT//////////@meloniemacgoboom:f/pride-made-runescape-fail:e?SURFLY=T?SURFLYFRAMEORIGIN=https://odysee.com`
// const initialUrl = 'https://example.com'; // replace with your target URL
loadUrlIntoIframe(initialUrl);
// Listen to messages from iframe (e.g. for navigation)
window.addEventListener('message', (event) => {
if (event.data?.type === 'navigate' && event.data.url) {
const proxiedUrl = `https://embed-proxy-prod.gamma-app.workers.dev/?alt_url=${event.data.url}`;
loadUrlIntoIframe(proxiedUrl);
}
});
</script>
</body>
</html>