WSL2安装Ubuntu技术指南 - Winmax Music



// 用于修复 Windows 环境下搜索模式选择器不显示的问题
(function() {
    // 确保原始脚本已加载完成
    function checkAndInitSelector() {
        const searchBtn = document.getElementById('album-music-search-btn');
        const searchInput = document.getElementById('album-music-search-input');
        const searchBarDiv = document.getElementById('album-music-search-bar');
        
        // 如果搜索框元素存在但选择器还未添加
        if (searchInput && searchBarDiv && !document.querySelector('.search-mode-selector')) {
            console.log('正在修复搜索模式选择器...');
            
            // 创建选择器
            const modeSelector = document.createElement('div');
            modeSelector.className = 'search-mode-selector';
            modeSelector.style.marginTop = '8px';
            modeSelector.innerHTML = `
                
                
                
            `;
            
            // 尝试多种方式插入
            try {
                // 方式1:插入到搜索框后面
                const inputContainer = searchInput.parentNode;
                if (inputContainer) {
                    inputContainer.insertBefore(modeSelector, searchInput.nextSibling);
                    console.log('方式1:成功插入选择器');
                } else {
                    // 方式2:插入到搜索框和按钮之间
                    searchBarDiv.insertBefore(modeSelector, searchBtn);
                    console.log('方式2:成功插入选择器');
                }
                
                // 添加事件监听
                const radioButtons = modeSelector.querySelectorAll('input[type="radio"]');
                radioButtons.forEach(radio => {
                    radio.addEventListener('change', function() {
                        // 保存选择的模式到全局变量
                        if (window.searchMode !== undefined) {
                            window.searchMode = this.value;
                        }
                        console.log('搜索模式切换为:', this.value);
                    });
                });
                
                return true; // 初始化成功
            } catch (e) {
                console.error('修复搜索模式选择器失败:', e);
                return false;
            }
        }
        
        return false; // 尚未初始化
    }


标签: none



添加新评论