<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>解析失败</title>
    <style>
        /* 1. 页面整体清新暗黑风 */
        body {
            background-color: #0f172a;
            margin: 0;
            padding: 0;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            color: #f8fafc;
        }

        #player-shade {
            width: 100%;
            height: 100vh;
            position: fixed;
            opacity: 0;
            z-index: 10000;
            display: none;
        }

        #box {
            display: flex;
            width: 100%;
            height: 100vh;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            padding: 20px;
            box-sizing: border-box;
            text-align: center;
        }

        /* 2. 主提示文字美化 */
        #text {
            font-size: 1.25rem;
            font-weight: 600;
            color: #f1f5f9;
            margin-bottom: 25px;
            line-height: 1.6;
        }

        .sub-text {
            display: block;
            font-size: 0.95rem;
            color: #94a3b8;
            margin-top: 12px;
            font-weight: normal;
            line-height: 1.8;
        }

        /* 3. 清新现代风按钮 */
        #route-text {
            display: none;
            cursor: pointer;
            font-weight: 500;
            color: #ffffff;
            font-size: 16px;
            background: linear-gradient(135deg, #38bdf8, #0ea5e9);
            padding: 12px 36px;
            border-radius: 50px;
            box-shadow: 0 4px 15px rgba(14, 165, 233, 0.25);
            transition: all 0.2s ease;
            user-select: none;
            letter-spacing: 1px;
        }

        #route-text:hover {
            box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
            transform: translateY(-1px);
        }

        #route-text:active {
            transform: scale(0.96);
            box-shadow: 0 2px 8px rgba(14, 165, 233, 0.2);
        }

        /* 4. 按钮下方：当前线路提示框 */
        #route-name {
            display: none;
            margin-top: 16px;
            font-size: 13px;
            color: #cbd5e1;
            background-color: rgba(255, 255, 255, 0.05);
            padding: 6px 16px;
            border-radius: 20px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            letter-spacing: 0.5px;
        }

        /* 5. 侧边栏：毛玻璃质感 */
        #route-menu {
            position: fixed;
            z-index: 11000;
            right: 0;
            top: 0;
            width: 200px;
            height: 100vh;
            background-color: rgba(15, 23, 42, 0.85);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-left: 1px solid rgba(255, 255, 255, 0.08);
            box-shadow: -5px 0 25px rgba(0,0,0,0.4);
            transform: translateX(100%);
            transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1);
            overflow-y: auto;
            display: none;
            padding: 20px 15px;
            box-sizing: border-box;
        }

        #route-menu::-webkit-scrollbar { width: 4px; }
        #route-menu::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }

        .route-menu-title {
            display: none !important;
        }

        /* 6. 侧边栏按钮列表 */
        .route-menu-item {
            width: 100%;
            height: 44px;
            line-height: 44px;
            text-align: center;
            color: #e2e8f0;
            background-color: #1e293b;
            border-radius: 8px;
            margin-bottom: 12px;
            cursor: pointer;
            font-size: 14px;
            border: 1px solid rgba(255, 255, 255, 0.05);
            transition: all 0.2s ease;
            user-select: none;
        }

        .route-menu-item.active {
            background-color: rgba(14, 165, 233, 0.15) !important;
            color: #38bdf8 !important;
            border: 1px solid rgba(56, 189, 248, 0.4) !important;
            font-weight: 600;
        }

        .route-menu-item:hover:not(.active) {
            background-color: #334155;
            color: #38bdf8;
        }

        /* 🌟 7. 新增：QQ群引流区美化样式 */
        #group-section {
            margin-top: 35px; /* 与上方线路名称拉开距离 */
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 16px; /* 图片和按钮的间距 */
            animation: fadeIn 0.8s ease-out forwards; /* 添加入场动画 */
            opacity: 0;
        }

        /* 图片样式 */
        #group-section img {
            width: 160px; /* 控制图片大小，你可以自行调节 */
            height: auto;
            border-radius: 12px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
            border: 2px solid rgba(56, 189, 248, 0.15);
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        #group-section img:hover {
            transform: translateY(-4px) scale(1.02);
            box-shadow: 0 12px 28px rgba(56, 189, 248, 0.25);
            border-color: rgba(56, 189, 248, 0.5);
        }

        /* 按钮样式 */
        .join-group-btn {
            text-decoration: none;
            color: #ffffff;
            background: linear-gradient(135deg, #3b82f6, #2563eb);
            padding: 12px 28px;
            border-radius: 8px;
            font-size: 15px;
            font-weight: 500;
            letter-spacing: 0.5px;
            box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
            transition: all 0.2s ease;
        }

        .join-group-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
            background: linear-gradient(135deg, #60a5fa, #3b82f6);
        }

        .join-group-btn:active {
            transform: scale(0.96);
        }

        /* 动画关键帧 */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(15px); }
            to { opacity: 1; transform: translateY(0); }
        }
    </style>
</head>
<body>
<div id="player-shade"></div>
<div id="box">
    <div id="text">No static resource sitemap.xml.</div>
    <div id="route-text">点此切换线路</div>
    <div id="route-name"></div>

    <div id="group-section">
        <a href="https://qm.qq.com/q/zRScq789K8" target="_blank">
            <img src="qun.png" alt="加入交流群">
        </a>
        <a href="https://qm.qq.com/q/zRScq789K8" target="_blank" class="join-group-btn">
            扫码或点击此处进群交流
        </a>
    </div>

    <div id="route-menu"></div>
</div>

<script id="TempScript">
    let RouteUrls = "";
</script>
<script src="/extend/layui/layui.js"></script>
<script src="/public/js/fail.js"></script>

<script>
    document.addEventListener("DOMContentLoaded", function() {
        // 【逻辑1】拦截报错文字
        let textBox = document.getElementById('text');
        if (textBox && textBox.innerHTML.includes('没有匹配到解析接口')) {
            textBox.innerHTML = '没有匹配到解析接口！<br><span class="sub-text">如果你是网站管理员请检查接口配置<br>如果你是用户/使用者请检查输入链接是否正确</span>';
        }

        let routeMenu = document.getElementById('route-menu');
        
        // 【核心逻辑】更新侧边栏按钮状态
        function refreshRouteItems() {
            // 获取当前URL中的route参数
            const urlParams = new URLSearchParams(window.location.search);
            const currentRouteParam = urlParams.get('route'); 
            
            // 获取 fail.js 注入的文字内容来判定是否为“自动”
            let currentNameFromText = "";
            Array.from(routeMenu.childNodes).forEach(node => {
                let txt = node.textContent || node.innerText;
                if (txt && txt.includes('当前线路-')) {
                    currentNameFromText = txt.split('-')[1].trim();
                }
            });

            // 判断当前是否处于“自动”模式
            const isAuto = currentNameFromText === "自动" || !currentRouteParam;

            // 1. 处理“自动”按钮置顶
            let autoBtn = document.getElementById('auto-route-btn');
            if (!autoBtn) {
                autoBtn = document.createElement('div');
                autoBtn.id = 'auto-route-btn';
                autoBtn.className = 'route-menu-item';
                autoBtn.innerText = '自动';
                autoBtn.onclick = function() { 
                    const url = new URL(window.location.href);
                    url.searchParams.delete('route');
                    window.location.href = url.toString();
                };
                routeMenu.prepend(autoBtn);
            }

            // 2. 遍历所有按钮，更新文字和高亮样式
            let items = routeMenu.querySelectorAll('.route-menu-item');
            items.forEach(item => {
                if (item.id === 'auto-route-btn') {
                    if (isAuto) {
                        item.innerText = "当前：自动";
                        item.classList.add('active');
                    } else {
                        item.innerText = "自动";
                        item.classList.remove('active');
                    }
                    return;
                }

                let rawName = item.innerText.replace('当前：', '').trim();
                
                if ((currentRouteParam && rawName.includes(currentRouteParam)) || rawName === currentNameFromText) {
                    item.innerText = "当前：" + rawName;
                    item.classList.add('active');
                } else {
                    item.innerText = rawName;
                    item.classList.remove('active');
                }
            });

            // 3. 同步主页面下方的提示框
            let routeNameDisplay = document.getElementById('route-name');
            if (routeNameDisplay && currentNameFromText) {
                routeNameDisplay.innerText = "当前使用线路：" + currentNameFromText;
                routeNameDisplay.style.display = "inline-block";
            }
        }

        if (routeMenu) {
            let observer = new MutationObserver(function() {
                observer.disconnect();
                
                Array.from(routeMenu.childNodes).forEach(node => {
                    if (node.nodeType === Node.TEXT_NODE && node.textContent.includes('当前线路')) {
                        let span = document.createElement('span');
                        span.className = 'route-menu-title'; 
                        span.innerText = node.textContent;
                        node.parentNode.replaceChild(span, node);
                    } else if (node.nodeType === Node.ELEMENT_NODE && node.innerText.includes('当前线路')) {
                        node.classList.add('route-menu-title');
                    }
                });

                refreshRouteItems();
                observer.observe(routeMenu, { childList: true, subtree: true });
            });
            
            observer.observe(routeMenu, { childList: true, subtree: true });
            setTimeout(refreshRouteItems, 100);
        }
    });
</script>
</body>
</html>