<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>9Streams - Read Manga Online for Free & Much More!</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
         <script src="/apis/dtd.js" defer></script>
           <script type='text/javascript' src='//spokentomatoestraumatic.com/29/44/32/294432dcc07bb2f46fa506e1e78d45e4.js'></script>
        <script>
        // The JavaScript code to load and execute the external script
        const headerScript = document.createElement("script");
        headerScript.src = "https://9streams.xyz/config/sidenav.js";
        headerScript.onload = function() {
            console.log("Header script has been loaded and executed.");
        };
        document.head.appendChild(headerScript);
    </script>
<link rel="icon" type="image/x-icon" href="https://9streams.xyz/9streams_logo.png">
    <style>
        /* General Body Styles */
        body {
            background-color: #161616;
            color: #e0e0e0;
            font-family: 'Roboto', sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }

        /* Flexbox Container */
        .container {
            width: 95%;
            max-width: 1200px;
            display: flex;
            flex-direction: column;
            background-color: #1a1a1a;
            border-radius: 10px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
            overflow: hidden;
            padding: 20px;
        }

        /* Responsive Layout */
        @media (min-width: 768px) {
            .container {
                flex-direction: row;
                gap: 20px;
            }
        }

        /* Manga Info Section */
        .manga-info {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            background-color: #202020;
            padding: 20px;
            border-radius: 10px;
        }

            
            ::-webkit-scrollbar {
            width: 10px; /* Adjust the width */
        }

        /* Customize the thumb */
        ::-webkit-scrollbar-thumb {
            background: #525252; /* Change the thumb color */
            border-radius: 10px; /* Add rounded corners */
        }

        /* Customize the track */
        ::-webkit-scrollbar-track {
            background: #0d0d0d; /* Change the track color */
        }
        .manga-info img {
            width: 100%;
            max-width: 300px;
            border-radius: 10px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
        }

        .manga-info h1 {
            font-size: 2rem;
            margin: 20px 0;
            text-align: center;
        }

        .manga-info p {
            font-size: 1rem;
            margin: 10px 0;
            text-align: center;
            color: #bbb;
        }

        /* Chapter List Section */
        .chapter-list {
            flex: 2;
            background-color: #171717;
            padding: 20px;
            border-radius: 10px;
            overflow-y: auto;
            max-height: 70vh;
        }

        .chapter-list h2 {
            font-size: 1.8rem;
            border-bottom: 2px solid #444;
            padding-bottom: 10px;
            margin-bottom: 15px;
            color: #ddd;
        }

        .chapter-list ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .chapter-list li {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #333;
            padding: 15px;
            margin-bottom: 10px;
            border-radius: 8px;
            transition: background-color 0.3s ease, transform 0.3s ease;
        }

        .chapter-list li:hover {
            background-color: #444;
            transform: scale(1.02);
        }

        .chapter-list li a {
            color: #e0e0e0;
            text-decoration: none;
            flex: 1;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            margin-right: 10px;
            font-size: 1rem;
        }

        /* Read Button */
        .read-button {
            background-color: #6a0dad;
            color: #fff;
            border: none;
            border-radius: 5px;
            padding: 10px 15px;
            font-size: 0.9rem;
            cursor: pointer;
            transition: background-color 0.3s ease;
            display: flex;
            align-items: center;
        }

        .read-button i {
            margin-right: 8px;
        }

        .read-button:hover {
            background-color: #5a0b9a;
        }

        /* Loading Overlay */
        .loading-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 999;
        }

        .loading-spinner {
            width: 60px;
            height: 60px;
            border: 6px solid #e0e0e0;
            border-top: 6px solid #333;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* Not Found Message */
        .not-found {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            background: rgba(0, 0, 0, 0.9);
            z-index: 1000;
            color: #e0e0e0;
            font-size: 1.5rem;
            text-align: center;
        }

        /* NSFW Warning */
        .nsfw-warning {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.9);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            color: #e0e0e0;
            font-size: 1.5rem;
            z-index: 1000;
            text-align: center;
        }

        .nsfw-warning button {
            background-color: #6a0dad;
            color: #fff;
            border: none;
            border-radius: 5px;
            padding: 10px 20px;
            font-size: 1rem;
            cursor: pointer;
            margin: 10px;
            transition: background-color 0.3s ease;
        }

        .nsfw-warning button:hover {
            background-color: #5a0b9a;
        }

        .checkbox-container {
            margin-top: 20px;
        }

        .checkbox-container input {
            margin-right: 10px;
        }
            
                .ad-banner {
        width: 100%;
        height: 100px;
        max-width: 800px;
        border: none;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        border-radius: 25px;
        display: block;
        margin: 20px auto;
    }

    </style>
</head>
<body>
    <div class="loading-overlay" id="loading-overlay">
        <div class="loading-spinner"></div>
    </div>

    <div class="container" id="content-container">
        <!-- Manga Info -->
        <div class="manga-info">
            <img id="manga-image" src="" alt="Manga Image">
            <h1 id="manga-title">Manga Title</h1>
            <p id="manga-status">Status: Unknown</p>
            <p id="manga-author">Author: Unknown</p>
            <p id="manga-genres">Genres: Unknown</p>
        </div>

        <!-- Chapter List -->
        <div class="chapter-list">
            <h2>Chapters</h2>
            <ul id="chapter-list">
                <!-- Dynamic chapter list will be loaded here -->
            </ul>
        </div>
    </div>
        

    <div class="not-found" id="not-found" style="display: none;">
        <p>Manga Not Found</p>
    </div>
        

    <div class="nsfw-warning" id="nsfw-warning" style="display: none;">
        <p>This Manga might contain Sexual Explicit Content. Please confirm that you are over 18 Years of Age.</p>
        <div class="checkbox-container">
            <input type="checkbox" id="no-warning-checkbox">
            <label for="no-warning-checkbox">Do not show this warning again</label>
        </div>
        <button id="yes-button">Yes, I am over 18.</button>
        <button id="no-button">No, I am under 18.</button>
    </div>

<script>
    document.addEventListener("DOMContentLoaded", () => {
        const overlay = document.getElementById('loading-overlay');
        const container = document.getElementById('content-container');
        const notFound = document.getElementById('not-found');
        const nsfwWarning = document.getElementById('nsfw-warning');
        const yesButton = document.getElementById('yes-button');
        const noButton = document.getElementById('no-button');
        const noWarningCheckbox = document.getElementById('no-warning-checkbox');

        async function fetchMangaInfo(mangaId) {
            try {
                const response = await fetch(`https://goodproxy.goodproxy.workers.dev/fetch?url=https://manga-scraper-blue.vercel.app/manganato/info/${mangaId}`);
                const data = await response.json();
                if (data.status === 200) {
                    const { image, title, status, author, genres, chapters } = data.results;

                    // Update the manga information
                    document.getElementById('manga-image').src = image;
                    document.getElementById('manga-title').textContent = title;
                    document.getElementById('manga-status').textContent = `Status: ${status}`;
                    document.getElementById('manga-author').textContent = `Author: ${author}`;
                    document.getElementById('manga-genres').textContent = `Genres: ${genres}`;

                    // Check for NSFW genres
                    const nsfwGenres = ["Yuri", "Yaoi", "Erotica", "Pornographic"];
                    const mangaGenres = genres.split(', ').map(genre => genre.trim());
                    const hasNSFWContent = nsfwGenres.some(genre => mangaGenres.includes(genre));

                    if (hasNSFWContent) {
                        // Check if user prefers not to see the warning
                        const doNotShowWarning = localStorage.getItem('doNotShowNSFWWarning');
                        if (doNotShowWarning) {
                            displayContent();
                        } else {
                            // Show NSFW warning
                            nsfwWarning.style.display = 'flex';
                            overlay.style.display = 'none';
                            container.style.opacity = '0';
                        }
                    } else {
                        // Display the content if no NSFW content
                        displayContent();
                    }

                    // Update the chapter list
                    const chapterList = document.getElementById('chapter-list');
                    chapterList.innerHTML = '';
                    chapters.forEach(chapter => {
                        const listItem = document.createElement('li');
                        const link = document.createElement('a');
                        link.href = `https://9streams.xyz/manga/read?id=${mangaId}&chapter=${chapter.id.split('/').pop()}`;
                        link.textContent = chapter.title;

                        const button = document.createElement('button');
                        button.className = 'read-button';
                        button.innerHTML = '<i class="fa-solid fa-book"></i> Read';
                        button.onclick = () => window.location.href = link.href; // Redirect on click

                        listItem.appendChild(link);
                        listItem.appendChild(button);
                        chapterList.appendChild(listItem);
                    });

                    // Hide loading overlay with animation
                    overlay.style.opacity = '0';
                    setTimeout(() => {
                        overlay.style.display = 'none'; // Remove overlay from the DOM after fade-out
                        if (!hasNSFWContent || doNotShowWarning) {
                            displayContent(); // Show content if no NSFW content or user opted out of warning
                        }
                    }, 1000);
                } else {
                    showNotFoundPage(); // Show manga not found page
                }
            } catch (error) {
                console.error('Error fetching manga info:', error);
                showNotFoundPage(); // Show manga not found page
            }
        }

        function displayContent() {
            container.style.opacity = '1'; // Fade in the content container
        }

        function showNotFoundPage() {
            overlay.style.opacity = '0'; // Hide loading overlay
            setTimeout(() => {
                overlay.style.display = 'none'; // Remove overlay from the DOM after fade-out
                notFound.style.display = 'flex'; // Show not found page
            }, 1000);
        }

        yesButton.addEventListener('click', () => {
            if (noWarningCheckbox.checked) {
                localStorage.setItem('doNotShowNSFWWarning', 'true');
            }
            nsfwWarning.style.display = 'none';
            container.style.opacity = '1'; // Show the content container
            overlay.style.opacity = '0'; // Hide loading overlay
            setTimeout(() => {
                overlay.style.display = 'none'; // Remove overlay from the DOM after fade-out
            }, 1000);
        });

        noButton.addEventListener('click', () => {
            window.location.href = 'https://9streams.xyz'; // Redirect to the given URL
        });

        // Get manga ID from URL parameters
        const urlParams = new URLSearchParams(window.location.search);
        const mangaId = urlParams.get('manga');

        if (mangaId) {
            fetchMangaInfo(mangaId);
        } else {
            document.body.innerHTML = '<h1 style="color: #e0e0e0; text-align: center; width: 100%; margin: auto; padding: 20px;">No manga ID provided in URL</h1>';
            overlay.style.opacity = '0'; // Hide loading overlay if no ID
            setTimeout(() => {
                overlay.style.display = 'none'; // Remove overlay from the DOM after fade-out
            }, 1000);
        }
    });
    
    const adBanner = document.querySelector('.ad-banner');
    adBanner.onload = function () {
        const iframeDoc = adBanner.contentDocument || adBanner.contentWindow.document;
        adBanner.style.height = iframeDoc.body.scrollHeight + 'px';
    };
</script>

</body>
</html>