import React, { useState, useEffect, useCallback, useRef } from 'https://esm.sh/react@19.0.0';
import { createRoot } from 'https://esm.sh/react-dom@19.0.0/client';
/**
* AD CONFIG
* These slots use your Google Ad Manager / AdX network ID: /23334523022/
*/
const MANUAL_ADS = {
HOME_TOP: `
`,
HOME_BOTTOM: `
`,
PLAYER_TOP: `
`,
PLAYER_BOTTOM: `
`,
PAUSE_AD: `
`,
INTERSTITIAL: `
`,
};
const AdSpace = ({ id, htmlContent }) => {
const containerRef = useRef(null);
useEffect(() => {
if (!containerRef.current || !htmlContent) return;
containerRef.current.innerHTML = '';
const range = document.createRange();
range.selectNode(containerRef.current);
const fragment = range.createContextualFragment(htmlContent);
containerRef.current.appendChild(fragment);
}, [htmlContent]);
return (
);
};
const InterstitialOverlay = ({ onComplete }) => {
const [timer, setTimer] = useState(10);
useEffect(() => {
const interval = setInterval(() => {
setTimer((p) => {
if (p <= 1) {
onComplete();
return 0;
}
return p - 1;
});
}, 1000);
return () => clearInterval(interval);
}, [onComplete]);
// 'absolute inset-0' combined with being a child of 'cinema-wrapper'
// ensures this shows on top of the video even in Fullscreen mode.
return (
ADVERTISING BREAK
Your stream resumes in {timer}s
);
};
const App = () => {
const INITIAL_AD_DELAY_MS = 10000;
const RECURRING_AD_INTERVAL_MS = 300000; // EXACTLY 5 MINUTES (300,000ms)
const [urlInput, setUrlInput] = useState('');
const [isActive, setIsActive] = useState(false);
const [embedUrl, setEmbedUrl] = useState('');
const [isPaused, setIsPaused] = useState(false);
const [showInterstitial, setShowInterstitial] = useState(false);
const [showToast, setShowToast] = useState(false);
const [viewCount, setViewCount] = useState(Math.floor(Math.random() * 500) + 1200);
const lastAdTimestamp = useRef(Date.now());
const initialAdDone = useRef(false);
const cleanUrl = useCallback((u) => {
let t = u.trim();
if (t.includes('mega.nz/file/')) return t.replace('mega.nz/file/', 'mega.nz/embed/');
if (t.includes('mega.nz/#!')) return t.replace('mega.nz/#!', 'mega.nz/embed/').replace('!', '#');
if (t.includes('mega.io/file/')) return t.replace('mega.io/file/', 'mega.io/embed/');
return t;
}, []);
useEffect(() => {
const handleHash = () => {
const hash = window.location.hash.substring(1);
if (hash && (hash.includes('mega.nz') || hash.includes('mega.io'))) {
setEmbedUrl(cleanUrl(hash));
setIsActive(true);
} else {
setIsActive(false);
}
};
handleHash();
window.addEventListener('hashchange', handleHash);
return () => window.removeEventListener('hashchange', handleHash);
}, [cleanUrl]);
// THE RECURRING AD ENGINE
useEffect(() => {
const heartbeat = setInterval(() => {
const now = Date.now();
const elapsed = now - lastAdTimestamp.current;
// Rule 1: First ad after 10 seconds of usage
if (!initialAdDone.current && elapsed >= INITIAL_AD_DELAY_MS) {
setShowInterstitial(true);
initialAdDone.current = true;
lastAdTimestamp.current = now;
}
// Rule 2: Recurring ad every 5 minutes (300,000ms)
if (initialAdDone.current && elapsed >= RECURRING_AD_INTERVAL_MS) {
setShowInterstitial(true);
lastAdTimestamp.current = now;
}
}, 1000);
return () => clearInterval(heartbeat);
}, []);
useEffect(() => {
const timer = setInterval(() => {
setViewCount(prev => prev + (Math.random() > 0.5 ? 1 : -1));
}, 3000);
return () => clearInterval(timer);
}, []);
const handleLaunch = () => {
if (!urlInput) return;
window.location.hash = urlInput;
};
const handleShare = () => {
const shareUrl = window.location.href;
navigator.clipboard.writeText(shareUrl).then(() => {
setShowToast(true);
setTimeout(() => setShowToast(false), 2000);
});
};
const toggleFullscreen = () => {
const fsContainer = document.getElementById('cinema-wrapper');
if (fsContainer) {
if (!document.fullscreenElement) {
fsContainer.requestFullscreen().catch(err => console.error(err));
} else {
document.exitFullscreen();
}
}
};
const handleAdComplete = useCallback(() => {
setShowInterstitial(false);
}, []);
if (!isActive) {
return (
Bypass everything.watch anything
Stream movies and series directly on one screen. Zero ads. Zero redirection. Just pure viewing.
setUrlInput(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && handleLaunch()} placeholder="Paste your mega.nz video link here..." className="flex-1 px-8 py-6 bg-transparent text-lg text-white outline-none font-bold" />
Launch Stream
{/* Ad Overlay rendered as child of cinema-wrapper for Fullscreen coverage */}
{showInterstitial &&
}
);
}
return (
{showToast && (
URL Copied to Clipboard
)}
{ window.location.hash = ''; setIsActive(false); }} className="flex items-center gap-4 cursor-pointer group">
MegaStream
{viewCount.toLocaleString()} WATCHING NOW
{isPaused && (
setIsPaused(false)} className="px-14 py-5 bg-red-600 text-white rounded-3xl font-black uppercase tracking-[0.2em] text-[11px] hover:scale-105 transition-all shadow-2xl shadow-red-600/40">Resume Stream
)}
setIsPaused(!isPaused)}
className={`w-14 h-14 rounded-2xl flex items-center justify-center transition-all ${isPaused ? 'bg-white text-black' : 'bg-red-600 text-white'}`}
>
{isPaused ?
:
}
Stream Gateway Active
Premium Node • Encryption 256-Bit
Share Link
{ setIsActive(false); window.location.hash = ''; }}
className="px-8 py-4 bg-slate-800 hover:bg-slate-700 text-white rounded-2xl font-black uppercase text-[10px] tracking-widest transition-all border border-white/10"
>
New Link
{/* Ad Overlay rendered as the absolute LAST child of cinema-wrapper */}
{showInterstitial &&
}
);
};
const rootElement = document.getElementById('root');
if (rootElement) {
createRoot(rootElement).render( );
}