Spaces:
Running
Running
Upload 2 files
Browse files- index.html +64 -19
- override.js +23 -0
index.html
CHANGED
|
@@ -1,19 +1,64 @@
|
|
| 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">
|
| 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-popups allow-forms Access-Control-Allow-Origin"></iframe>
|
| 14 |
+
|
| 15 |
+
<script>
|
| 16 |
+
const loadUrlIntoIframe = async (url) => {
|
| 17 |
+
try {
|
| 18 |
+
const res = await fetch(url, {
|
| 19 |
+
mode: 'cors',
|
| 20 |
+
headers: {
|
| 21 |
+
'Accept': 'text/html',
|
| 22 |
+
'User-Agent': navigator.userAgent
|
| 23 |
+
}
|
| 24 |
+
});
|
| 25 |
+
if (!res.ok) throw new Error(`Status ${res.status}`);
|
| 26 |
+
let html = await res.text();
|
| 27 |
+
|
| 28 |
+
// Inject override.js into the page
|
| 29 |
+
const overrideScript = await fetch('override.js').then(r => r.text());
|
| 30 |
+
const injection = `<script>${overrideScript}<\/script>`;
|
| 31 |
+
html = html.replace(/<\/head>/i, injection + '</head>');
|
| 32 |
+
|
| 33 |
+
// Serve as blob so it runs in same origin context
|
| 34 |
+
const blob = new Blob([html], { type: 'text/html' });
|
| 35 |
+
const blobUrl = URL.createObjectURL(blob);
|
| 36 |
+
|
| 37 |
+
const iframe = document.getElementById('custom-iframe');
|
| 38 |
+
iframe.src = blobUrl;
|
| 39 |
+
iframe.onload = () => URL.revokeObjectURL(blobUrl);
|
| 40 |
+
} catch (err) {
|
| 41 |
+
console.error('Embed error:', err);
|
| 42 |
+
document.body.innerHTML = `<p style="color:red;">Error loading embed: ${err.message}</p>`;
|
| 43 |
+
}
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
const default_url = 'https://www.example.com/'
|
| 47 |
+
// Initial page load
|
| 48 |
+
const targetUrl = default_url;
|
| 49 |
+
const initialUrl = `https://embed-proxy-prod.gamma-app.workers.dev/?alt_url=${targetUrl}`;
|
| 50 |
+
// 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`
|
| 51 |
+
|
| 52 |
+
// const initialUrl = 'https://example.com'; // replace with your target URL
|
| 53 |
+
loadUrlIntoIframe(initialUrl);
|
| 54 |
+
|
| 55 |
+
// Listen to messages from iframe (e.g. for navigation)
|
| 56 |
+
window.addEventListener('message', (event) => {
|
| 57 |
+
if (event.data?.type === 'navigate' && event.data.url) {
|
| 58 |
+
const proxiedUrl = `https://embed-proxy-prod.gamma-app.workers.dev/?alt_url=${event.data.url}`;
|
| 59 |
+
loadUrlIntoIframe(proxiedUrl);
|
| 60 |
+
}
|
| 61 |
+
});
|
| 62 |
+
</script>
|
| 63 |
+
</body>
|
| 64 |
+
</html>
|
override.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function () {
|
| 2 |
+
function overrideContent() {
|
| 3 |
+
// Style overrides
|
| 4 |
+
document.querySelectorAll('h1').forEach(h => h.style.color = 'red');
|
| 5 |
+
document.querySelectorAll('p').forEach(p => p.style.color = 'coral');
|
| 6 |
+
document.body.style.backgroundColor = 'green';
|
| 7 |
+
|
| 8 |
+
// Intercept <a> tag clicks to trigger dynamic loading
|
| 9 |
+
document.querySelectorAll('a').forEach(a => {
|
| 10 |
+
a.addEventListener('click', function (e) {
|
| 11 |
+
e.preventDefault();
|
| 12 |
+
const targetUrl = this.href;
|
| 13 |
+
window.parent.postMessage({ type: 'navigate', url: targetUrl }, '*');
|
| 14 |
+
});
|
| 15 |
+
});
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
if (document.readyState !== 'loading') {
|
| 19 |
+
overrideContent();
|
| 20 |
+
} else {
|
| 21 |
+
document.addEventListener('DOMContentLoaded', overrideContent);
|
| 22 |
+
}
|
| 23 |
+
})();
|