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';
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 fragment = document.createRange().createContextualFragment(htmlContent);
containerRef.current.appendChild(fragment);
}, [htmlContent]);
return (
);
};
const InterstitialOverlay = ({ onComplete, isFullPage }) => {
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]);
const classes = isFullPage
? "fixed inset-0 z-[1000000] bg-[#020617] flex flex-col items-center justify-center p-6"
: "absolute inset-0 z-[999999] bg-[#020617] flex flex-col items-center justify-center p-6";
return (
ADVERTISING BREAK
Your stream resumes in {timer}s
);
};
const App = () => {
const RECURRING_AD_INTERVAL_MS = 300000;
const [urlInput, setUrlInput] = useState('');
const [isActive, setIsActive] = useState(false);
const [embedUrl, setEmbedUrl] = useState('');
const [isPaused, setIsPaused] = useState(false);
const [showInterstitial, setShowInterstitial] = useState(false);
const [isFullPageAd, setIsFullPageAd] = useState(false);
const [isStreamReady, setIsStreamReady] = useState(false);
const [viewCount, setViewCount] = useState(Math.floor(Math.random() * 500) + 1200);
const [liked, setLiked] = useState(false);
const lastAdTimestamp = useRef(Date.now());
const initialAdDone = useRef(false);
const cleanUrl = useCallback((u) => {
let t = u.trim();
if (t.includes('mega.nz/file/')) t = t.replace('mega.nz/file/', 'mega.nz/embed/');
if (t.includes('mega.nz/#!')) t = t.replace('mega.nz/#!', 'mega.nz/embed/').replace('!', '#');
if (t.includes('mega.io/file/')) t = 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); setIsStreamReady(false); }
};
handleHash();
window.addEventListener('hashchange', handleHash);
return () => window.removeEventListener('hashchange', handleHash);
}, [cleanUrl]);
useEffect(() => {
const heartbeat = setInterval(() => {
const now = Date.now();
const elapsed = now - lastAdTimestamp.current;
if (!initialAdDone.current && elapsed >= 10000) {
setIsFullPageAd(true);
setShowInterstitial(true);
initialAdDone.current = true;
lastAdTimestamp.current = now;
} else if (initialAdDone.current && elapsed >= RECURRING_AD_INTERVAL_MS) {
setIsFullPageAd(false);
setShowInterstitial(true);
lastAdTimestamp.current = now;
if (window.googletag?.pubads) { googletag.cmd.push(() => googletag.pubads().refresh()); }
}
}, 1000);
return () => clearInterval(heartbeat);
}, []);
const toggleFullscreen = () => {
const container = document.getElementById('player-container');
if (!document.fullscreenElement) {
container.requestFullscreen().catch(() => {
const frame = document.querySelector('iframe');
if (frame?.webkitEnterFullscreen) frame.webkitEnterFullscreen();
});
} else { document.exitFullscreen(); }
};
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' && (window.location.hash = urlInput)} placeholder="Paste your mega.nz video link here..." className="flex-1 px-6 md:px-8 py-4 md:py-6 bg-transparent text-base md:text-lg text-white outline-none font-bold" />
{showInterstitial && isFullPageAd &&
setShowInterstitial(false)} />}
);
}
return (
{isStreamReady ? (
) : (
Ready to Stream
Satisfy security node initialization
)}
{isPaused && (
)}
{showInterstitial && !isFullPageAd &&
setShowInterstitial(false)} />}
Stream Active
Encrypted 256-Bit Node
{showInterstitial && isFullPageAd &&
setShowInterstitial(false)} />}
);
};
const rootElement = document.getElementById('root');
if (rootElement) { createRoot(rootElement).render(); }