<style>
    #image-container {position: relative;width: 700px; height: 700px;overflow: hidden;}
    #image-container iframe {position: absolute;top: 0;left: 0;width: 700px;height: 700px;border: none;overflow: hidden;}
</style>
</head>
<body>
    <div id="output"></div>
    <script>
        document.addEventListener('DOMContentLoaded', async () => {
            const initialUrl = 'https://alceawis.de/modelsmine.html';
            try {
                const response = await fetch(initialUrl);
                const htmlContent = await response.text();
                const descriptionDataPattern = /const\s+descriptionData\s*=\s*\{([\s\S]*?)\};/i;
                const descriptionDataMatch = htmlContent.match(descriptionDataPattern);
                if (!descriptionDataMatch) {
                    throw new Error('JavaScript object "descriptionData" not found.');}
                const descriptionDataCode = descriptionDataMatch[1];
                const urlPattern = /"(https:\/\/alcea-wisteria\.de\/PHP\/models\/mine\/[^"]+)"/i;
                const urlMatch = descriptionDataCode.match(urlPattern);
                if (!urlMatch) {throw new Error('No URL found in the descriptionData object.');}
                const firstUrl = urlMatch[1];
                const urlResponse = await fetch(firstUrl);
                const urlContent = await urlResponse.text();
                const lines = urlContent.split('\n');
                let pmxFile = null;
                for (const line of lines) {
                    if (line.includes('.pmx')) {
                        const pmxFilePattern = /([^"\s]+\.pmx)/i;
                        const pmxMatch = line.match(pmxFilePattern);
                        if (pmxMatch) {
                            pmxFile = pmxMatch[1];
                            break;
                        }
                    }
                }

                if (!pmxFile) {
                    throw new Error('No .pmx file reference found in the content of the URL.');
                }

                const pmxFileQuery = pmxFile.startsWith('./') ? pmxFile.slice(2) : pmxFile;
                const queryStringUrl = `https://alcea-wisteria.de/PHP/models/mine/0loader.html?pmx=${encodeURIComponent(pmxFileQuery)}`;
                const imageUrl = `https://alcea-wisteria.de/PHP/models/mine/${pmxFileQuery.replace('.pmx', '.png')}`;

                // Update the DOM
                const outputDiv = document.getElementById('output');
                outputDiv.innerHTML = `
                    <!--<h3>Latest Model:</h3>-->
                    <p>Latest Model: <a href="${queryStringUrl}" target="_blank">${queryStringUrl}</a></p>
                    <div id='image-container'>
                        <img id='model-image' src="${imageUrl}" alt="Model Image" style="max-width: 100%; height: auto; cursor: pointer; display: block;" />
                    </div>
                `;
                document.getElementById('model-image').addEventListener('click', function() {
                    const iframe = document.createElement('iframe');
                    iframe.src = queryStringUrl;
                    iframe.style.width = '720px';
                    iframe.style.height = '720px';
                    iframe.style.border = 'none';
                    iframe.style.overflow = 'hidden';
                    const imageContainer = document.getElementById('image-container');
                    imageContainer.innerHTML = '';
                    imageContainer.appendChild(iframe);
                    setTimeout(() => {
                        const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
                        iframeDoc.body.style.overflow = 'hidden';
                        iframeDoc.documentElement.style.overflow = 'hidden';
                    }, 100);
                    document.body.style.overflow = 'hidden';
                });
                
            } catch (error) {
                console.error(error.message);
                document.getElementById('output').textContent = error.message;
            }
        });
    </script>
</body>
</html>



<!---PHP--ver
<?php
$initialUrl = 'https://alceawis.de/modelsmine.html';
$htmlContent = file_get_contents($initialUrl);
if ($htmlContent === FALSE) {
    die('Failed to retrieve content from ' . $initialUrl);}
$pattern = '/const\s+descriptionData\s*=\s*\{([\s\S]*?)\};/i';
if (preg_match($pattern, $htmlContent, $matches)) {
    $descriptionDataCode = $matches[1];
    $urlPattern = '/"(https:\/\/alcea-wisteria\.de\/PHP\/models\/mine\/[^"]+)"/i';
    if (preg_match($urlPattern, $descriptionDataCode, $urlMatches)) {
        $firstUrl = $urlMatches[1];
        $urlContent = file_get_contents($firstUrl);
        if ($urlContent === FALSE) {
            die('Failed to retrieve content from ' . $firstUrl);}
        $baseImageUrl = 'https://alcea-wisteria.de/PHP/models/mine/';
        $lines = explode("\n", $urlContent);
        $pmxFile = null;
        foreach ($lines as $line) {
            if (stripos($line, '.pmx') !== false) {
                if (preg_match('/([^"\s]+\.pmx)/i', $line, $pmxMatches)) {
                    $pmxFile = $pmxMatches[1];
                    break;
                    }}}
        if ($pmxFile !== null) {
            $pmxFileQuery = ltrim($pmxFile, './');
            $queryStringUrl = 'https://alcea-wisteria.de/PHP/models/mine/0loader.html?pmx=' . urlencode($pmxFileQuery);
            $imageUrl = $baseImageUrl . str_replace('.pmx', '.png', $pmxFileQuery);
            echo "<h3>Latest Model:</h3>";
            echo "<p><a href=\"" . htmlspecialchars($queryStringUrl) . "\" target=\"_blank\">" . htmlspecialchars($queryStringUrl) . "</a></p>";
            echo "<div id='image-container' style='position: relative; width: 700px; height: 700px; overflow: hidden;'>";
            echo "<img id='model-image' src=\"" . htmlspecialchars($imageUrl) . "\" alt=\"Model Image\" style=\"max-width: 100%; height: auto; cursor: pointer; display: block;\" />";
            echo "</div>";
            echo <<<EOD
<style>
    #image-container {position: relative;width: 700px; height: 700px;overflow: hidden;}
    #image-container iframe {position: absolute;top: 0;left: 0;width: 100%;height: 100%;border: none;overflow: hidden;}
</style>
<script>
    document.getElementById('model-image').addEventListener('click', function() {
        var imageContainer = document.getElementById('image-container');
        var iframe = document.createElement('iframe');
        iframe.src = '$queryStringUrl';
        iframe.style.width = '100%'; /* Ensures iframe fits its container */
        iframe.style.height = '100%'; /* Ensures iframe fits its container */
        iframe.style.border = 'none';
        iframe.style.overflow = 'hidden'; /* Ensure no scrollbars on iframe */
        iframe.onload = function() {
            // Ensure iframe content does not overflow
            iframe.contentWindow.document.body.style.overflow = 'hidden';
            iframe.contentWindow.document.documentElement.style.overflow = 'hidden';};
        imageContainer.innerHTML = '';
        imageContainer.appendChild(iframe);
        document.body.style.overflow = 'hidden'; /* Optionally hide scrollbars for the whole page */});
</script>
EOD;
} else {echo 'No .pmx file reference found in the content of the URL.';}
} else {echo 'No URL found in the descriptionData object.';}
} else {echo 'JavaScript object "descriptionData" not found.';}
?>
-->