// ==UserScript== // @name 切换搜索引擎 // @description 在搜索引擎之间快速切换搜索内容 // @author Jack back // @namespace search-engine-switcher // @license GPL-3.0 // @include https://www.baidu.com/* // @include *.bing.com/* // @include /^https?://[a-z]+\.google\.[a-z,\.]+/.+$/ // @include https://www.zhihu.com/search* // @include https://www.bilibili.com/search* // @include https://www.xiaohongshu.com/search* // @include https://www.youtube.com/results* // @include https://metaso.cn/* // @run-at document_body // @version 1.1.3 // @downloadURL https://update.greasyfork.icu/scripts/533395/%E5%88%87%E6%8D%A2%E6%90%9C%E7%B4%A2%E5%BC%95%E6%93%8E.user.js // @updateURL https://update.greasyfork.icu/scripts/533395/%E5%88%87%E6%8D%A2%E6%90%9C%E7%B4%A2%E5%BC%95%E6%93%8E.meta.js // ==/UserScript== (function () { 'use strict'; let sites = [ { name: "百度", host: "baidu.com", link: "https://www.baidu.com/s", key: "wd", hide: false, }, { name: "必应", host: "bing.com", link: "https://bing.com/search", key: "q", hide: false, }, { name: "谷歌", host: "google.com", link: "https://www.google.com.hk/search", key: "q", hide: false, }, { name: "知乎", host: "zhihu.com", link: "https://www.zhihu.com/search", key: "q", hide: false, }, { name: "B站", host: "bilibili.com", link: "https://www.bilibili.com/search", key: "keyword", hide: false, }, { name: "小红书", host: "xiaohongshu.com", link: "https://www.xiaohongshu.com/search", key: "keyword", hide: false, }, { name: "YouTube", host: "youtube.com", link: "https://www.youtube.com/results", key: "search_query", hide: false, }, { name: "秘塔", host: "metaso.cn", link: "https://metaso.cn/", key: "q", hide: false, }, { name: "GitHub", host: "github.com", link: "https://github.com/search", key: "q", hide: false, }, ]; const css = ` /* 全局字体优化 */ * { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; } .search-switcher { position: fixed; opacity: 0.12; top: 50%; transform: translateY(-50%); left: -100px; z-index: 9999999; transition: all 800ms cubic-bezier(0.19, 1, 0.22, 1); filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.2)); } .search-switcher:hover { left: 0; opacity: 1; filter: drop-shadow(0 0 30px rgba(0, 0, 0, 0.25)); } .search-list { display: flex; flex-direction: column; gap: 7px; background: rgba(23, 23, 33, 0.92); backdrop-filter: blur(20px) saturate(180%) brightness(95%); -webkit-backdrop-filter: blur(20px) saturate(180%) brightness(95%); border-radius: 0 18px 18px 0; padding: 12px 10px; box-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1) inset, 0 0 0 1px rgba(255, 255, 255, 0.05); width: 100px; position: relative; overflow: hidden; } .search-list::before { content: ''; position: absolute; inset: 0; background: linear-gradient( 135deg, rgba(255, 255, 255, 0.03) 0%, transparent 50% ), radial-gradient( circle at top right, rgba(255, 255, 255, 0.12), transparent 80% ); z-index: 0; } .search-list a { color: rgba(255, 255, 255, 0.85); text-decoration: none; padding: 9px 14px; border-radius: 9px; transition: all 500ms cubic-bezier(0.19, 1, 0.22, 1); font-size: 13px; font-weight: 600; letter-spacing: 0.3px; text-align: center; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08); position: relative; overflow: hidden; z-index: 1; backdrop-filter: blur(4px); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); } .search-list a:hover { color: #ffffff; background: rgba(255, 255, 255, 0.1); transform: translateX(3px) scale(1.02); letter-spacing: 0.5px; text-shadow: 0 2px 20px rgba(255, 255, 255, 0.4); border-color: rgba(255, 255, 255, 0.2); box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.15) inset, 0 0 20px rgba(255, 255, 255, 0.06); } @keyframes glow { 0% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.1); } 50% { box-shadow: 0 0 20px rgba(255, 255, 255, 0.2); } 100% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.1); } } .search-switcher:hover .search-list { animation: glow 2s infinite; } @media (prefers-reduced-motion) { .search-switcher, .search-list a { transition: none; } } @supports not (backdrop-filter: blur(12px)) { .search-list { background: rgba(28, 28, 35, 0.95); } } /* 齿轮图标样式 */ .settings-gear { width: 20px; height: 20px; padding: 4px; margin: 4px auto 0; cursor: pointer; opacity: 0.6; transition: all 0.3s ease; } .settings-gear:hover { opacity: 1; transform: rotate(45deg); } /* 弹窗样式优化 */ .modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.2); backdrop-filter: blur(8px) saturate(180%); -webkit-backdrop-filter: blur(8px) saturate(180%); display: none; justify-content: center; align-items: center; z-index: 10000000; animation: modalFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1); } @keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } } .modal-content { background: linear-gradient( 135deg, rgba(35, 35, 45, 0.85) 0%, rgba(23, 23, 33, 0.9) 100% ); backdrop-filter: blur(25px) saturate(180%); padding: 32px; border-radius: 24px; min-width: 360px; box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1) inset, 0 0 0 1px rgba(255, 255, 255, 0.05); transform: scale(0.95); animation: modalPop 0.6s cubic-bezier(0.19, 1, 0.22, 1) forwards; border: 1px solid rgba(255, 255, 255, 0.08); } .modal-buttons { display: flex; gap: 12px; margin-bottom: 20px; } .modal-btn { flex: 1; padding: 13px 20px; border: none; border-radius: 12px; background: linear-gradient( 135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03) ); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.06) inset; color: white; font-weight: 600; cursor: pointer; transition: all 500ms cubic-bezier(0.19, 1, 0.22, 1); position: relative; overflow: hidden; backdrop-filter: blur(4px); font-size: 13.5px; letter-spacing: 0.3px; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); } .modal-btn:hover { background: linear-gradient( 135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06) ); transform: translateY(-2px); box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset; } .modal-btn:active { transform: translateY(0); } .add-form { display: flex; flex-direction: column; gap: 15px; animation: formSlideIn 0.3s ease-out; } @keyframes formSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } .add-form > div:first-child { color: rgba(255, 255, 255, 0.9); font-size: 14px; margin-bottom: 5px; font-weight: 550; letter-spacing: 0.2px; text-shadow: 0 0 1px rgba(255, 255, 255, 0.1); } /* 设置表单标签样式 */ .add-form > div { color: #ffffff; font-size: 16px; margin-bottom: 5px; font-weight: 700; letter-spacing: 0.3px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); } .add-form input { padding: 14px 18px; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 12px; background: rgba(0, 0, 0, 0.2); color: white; font-size: 13.5px; font-weight: 500; letter-spacing: 0.3px; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); width: 100%; backdrop-filter: blur(4px); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.05) inset; } .add-form input:focus { outline: none; border-color: rgba(255, 255, 255, 0.2); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1), 0 0 30px rgba(255, 255, 255, 0.1); background: rgba(0, 0, 0, 0.25); } .add-form input::placeholder { color: rgba(255, 255, 255, 0.4); } .delete-list { max-height: 300px; overflow-y: auto; margin-top: 10px; padding-right: 10px; } .delete-list::-webkit-scrollbar { width: 6px; } .delete-list::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 3px; } .delete-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 3px; } .delete-item { display: flex; justify-content: space-between; align-items: center; padding: 15px; border-radius: 14px; margin-bottom: 8px; background: rgba(255, 255, 255, 0.04); transition: all 500ms cubic-bezier(0.19, 1, 0.22, 1); border: 1px solid rgba(255, 255, 255, 0.06); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); } .delete-item:hover { background: rgba(255, 255, 255, 0.06); transform: translateX(3px); border-color: rgba(255, 255, 255, 0.1); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.08) inset; } .delete-item span { color: rgba(255, 255, 255, 0.9); font-size: 13.5px; font-weight: 500; letter-spacing: 0.2px; text-shadow: 0 0 1px rgba(255, 255, 255, 0.1); } .delete-btn { padding: 7px 14px; background: linear-gradient( 135deg, rgba(255, 59, 48, 0.12), rgba(255, 59, 48, 0.08) ); color: #ff3b30; border: 1px solid rgba(255, 59, 48, 0.15); border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600; letter-spacing: 0.2px; transition: all 500ms cubic-bezier(0.19, 1, 0.22, 1); backdrop-filter: blur(4px); box-shadow: 0 2px 5px rgba(255, 59, 48, 0.1), 0 0 0 1px rgba(255, 59, 48, 0.05) inset; } .delete-btn:hover { background: linear-gradient( 135deg, rgba(255, 59, 48, 0.18), rgba(255, 59, 48, 0.12) ); transform: translateX(2px); box-shadow: 0 4px 15px rgba(255, 59, 48, 0.15), 0 0 0 1px rgba(255, 59, 48, 0.1) inset; } #confirmAdd { margin-top: 15px; padding: 12px; width: 100%; background: rgba(255, 255, 255, 0.15); color: white; border: none; border-radius: 8px; font-weight: 500; cursor: pointer; transition: all 0.3s ease; } #confirmAdd:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(255, 255, 255, 0.4); } #confirmAdd:active { transform: translateY(0); } .settings-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, 0.1); } .settings-section h3 { color: rgba(255, 255, 255, 0.9); font-size: 14px; margin-bottom: 15px; font-weight: 500; } `; // 添加本地存储功能 function saveCustomSites() { try { localStorage.setItem('customSites', JSON.stringify(sites)); return true; } catch (e) { console.error('保存站点数据失败:', e); return false; } } function loadCustomSites() { try { const saved = localStorage.getItem('customSites'); if (saved) { try { const loadedSites = JSON.parse(saved); if (Array.isArray(loadedSites) && loadedSites.length > 0) { // 验证站点数据的有效性 const validSites = loadedSites.filter(site => site && typeof site === 'object' && site.name && site.host && site.link && site.key !== undefined ); if (validSites.length > 0) { sites = validSites; console.log(`成功加载${validSites.length}个自定义站点`); return true; } else { console.warn('加载的站点数据无效'); } } } catch (e) { console.error('无法解析保存的站点数据', e); } } return false; } catch (e) { console.error('读取本地存储失败:', e); return false; } } // 修改创建弹窗的HTML结构 function createSettingsModal() { const modal = document.createElement('div'); modal.className = 'modal-overlay'; modal.innerHTML = `
`; document.body.appendChild(modal); // 绑定按钮事件 document.getElementById('addSiteBtn').addEventListener('click', () => { const container = document.getElementById('settingsContainer'); container.innerHTML = `