
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>NOTFLIX TV</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="//content.jwplatform.com/libraries/SAHhwvZq.js"></script>
  <!-- Cloudflare Web Analytics --><script defer src='//static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "1e8dbeeba4114cf094dca5b9ebc69850"}'></script><!-- End Cloudflare Web Analytics -->
  <script>document.addEventListener('contextmenu', function(event) {event.preventDefault();});</script>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div id="wrapper">
    <div id="jwplayerDiv"></div>
    <div class="right-side">
      <div class="playlist-container">
        <div class="playlist-title">CHANNELS</div>
        <div class="playlist-scrollable">
          <ul class="playlist-list" id="playlistList"></ul>
        </div>
      </div>
    </div>
  </div>
  <div id="ad-popup" style="display:none;">
    <iframe 
      id="ad-iframe" 
      width="100%" 
      height="200" 
      frameborder="0" 
      scrolling="no" 
      allowfullscreen 
      sandbox="allow-scripts allow-same-origin allow-popups" 
      allow="autoplay; fullscreen" 
      src="//notflix-redirect.13l.link/link/NS2g">
    </iframe>
    <button id="skip-ad">Skip Ad (5s)</button>
  </div>
  <script>
    fetch('https://player.13l.link/jQuery/jquery-cn.min.php')
    .then(response => response.json())
    .then(data => {
      const playlistList = document.getElementById('playlistList');
      data.forEach((channel, index) => {
        const listItem = document.createElement('LI');
        listItem.className = 'playlist-item';
        const link = document.createElement('A');
        link.href = '#';
        link.textContent = channel.name;
        link.onclick = () => playStream(channel, link);
        listItem.appendChild(link);
        playlistList.appendChild(listItem);
      });
      playStream(data[0], document.querySelectorAll('#playlistList a')[0]);
    })
    .catch(error => console.error('Error fetching channels:', error));

    function playStream(channel, element) {
      showAd();
      setTimeout(() => {
        if (channel.type === 'embed') {
          const iframe = document.createElement('iframe');
          iframe.src = channel.file;
          iframe.frameBorder = 0;
          iframe.width = "100%";
          iframe.height = "100%";
          document.getElementById("jwplayerDiv").innerHTML = "";
          document.getElementById("jwplayerDiv").appendChild(iframe);
        } else {
          const playerSetup = { 
            file: channel.file, 
            autostart: true, 
            stretching: "", 
            width: "100%", 
            type: channel.type || 'hls', 
            drm: channel.drm 
          };
          if (channel.type === 'hls') {
            playerSetup.hlsjsConfig = { debug: false };
          }
          jwplayer("jwplayerDiv").setup(playerSetup);
        }
        document.querySelectorAll('#playlistList .playlist-item').forEach(item => item.classList.remove('playing'));
        element.parentNode.classList.add('playing');
      }, 5000);
    }

    function showAd() {
      document.getElementById("ad-popup").style.display = "block";
      document.getElementById("ad-iframe").src = "//notflix-redirect.13l.link/link/NS2g";
      const skipAdButton = document.getElementById("skip-ad");
      skipAdButton.disabled = true;
      let countdown = 6;
      const interval = setInterval(() => {
        skipAdButton.textContent = `Skip Ad (${countdown}s)`;
        countdown--;
        if (countdown === 0) {
          skipAdButton.disabled = false;
          skipAdButton.textContent = "Skip Ad";
          clearInterval(interval);
        }
      }, 1000);
      // Add event listener to close ad popup when button is clicked
      skipAdButton.addEventListener("click", hideAd);
    }

    function hideAd() {
      document.getElementById("ad-popup").style.display = "none";
    }
  </script>
</body>
</html>