
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <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="https://notflix.in/"></iframe>
    <button id="skip-ad">Please Wait...</button>
  </div>
  <script>
    fetch('//player.13l.link/jQuery/jquery-cn2.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',
          };

          if (channel.type === 'hls') {
            playerSetup.hlsjsConfig = {
              debug: false,
            };
          }

          if (channel.drm && channel.drm.widevine) {
            playerSetup.drm = {
              widevine: {
                licenseUrl: 'http://143.44.136.74:9443/widevine/?deviceId=02:00:00:00:00:00',
              },
            };
          }

          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 = "https://notflix.in/";
      const skipAdButton = document.getElementById("skip-ad");
      skipAdButton.disabled = true;
      let countdown = 5;
      const interval = setInterval(() => {
        skipAdButton.textContent = `Wait lang po... (${countdown}s)`;
        countdown--;
        if (countdown === 0) {
          skipAdButton.disabled = false;
          skipAdButton.textContent = "Close";
          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>