// ==UserScript== // @name 学历选择器 - 小学初中高中大专大学 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 快速选择学历:小学、初中、高中、大专、大学等学历选项 // @author You // @match *://*/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // 学历选项配置 const educationLevels = [ { value: 'xiaoxue', label: '小学' }, { value: 'chuzhong', label: '初中' }, { value: 'gaozhong', label: '高中' }, { value: 'zhongzhuandui', label: '中专/职高/技校' }, { value: 'dazhuan', label: '大专' }, { value: 'benke', label: '本科' }, { value: 'shuoshi', label: '硕士' }, { value: 'boshi', label: '博士' } ]; // 创建浮动按钮 function createFloatingButton() { const button = document.createElement('div'); button.innerHTML = '📚 学历'; button.style.cssText = ` position: fixed; bottom: 20px; right: 20px; width: 60px; height: 60px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 12px; font-weight: bold; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4); z-index: 999999; transition: all 0.3s ease; user-select: none; `; button.onmouseenter = () => { button.style.transform = 'scale(1.1)'; button.style.boxShadow = '0 6px 20px rgba(102, 126, 234, 0.6)'; }; button.onmouseleave = () => { button.style.transform = 'scale(1)'; button.style.boxShadow = '0 4px 15px rgba(102, 126, 234, 0.4)'; }; return button; } // 创建学历选择面板 function createPanel() { const panel = document.createElement('div'); panel.style.cssText = ` position: fixed; bottom: 90px; right: 20px; width: 280px; background: white; border-radius: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15); z-index: 999999; display: none; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; `; // 标题栏 const header = document.createElement('div'); header.style.cssText = ` background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 16px 20px; font-size: 16px; font-weight: 600; `; header.textContent = '选择学历'; panel.appendChild(header); // 学历列表容器 const listContainer = document.createElement('div'); listContainer.style.cssText = 'max-height: 400px; overflow-y: auto; padding: 10px;'; // 创建学历按钮 educationLevels.forEach((level, index) => { const btn = document.createElement('button'); btn.textContent = level.label; btn.style.cssText = ` width: 100%; padding: 12px 16px; margin-bottom: 6px; border: 2px solid #e8e8e8; border-radius: 10px; background: white; font-size: 14px; cursor: pointer; transition: all 0.2s ease; text-align: left; display: flex; align-items: center; gap: 10px; `; const num = document.createElement('span'); num.textContent = index + 1; num.style.cssText = ` width: 24px; height: 24px; background: #f0f0f0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #666; `; btn.insertBefore(num, btn.firstChild); btn.onmouseenter = () => { btn.style.borderColor = '#667eea'; btn.style.background = '#f8f6ff'; num.style.background = '#667eea'; num.style.color = 'white'; }; btn.onmouseleave = () => { btn.style.borderColor = '#e8e8e8'; btn.style.background = 'white'; num.style.background = '#f0f0f0'; num.style.color = '#666'; }; btn.onclick = () => { copyToClipboard(level.label); showNotification(`已复制: ${level.label}`); panel.style.display = 'none'; }; listContainer.appendChild(btn); }); panel.appendChild(listContainer); // 底部提示 const footer = document.createElement('div'); footer.style.cssText = ` padding: 12px 20px; background: #f8f9fa; font-size: 11px; color: #999; text-align: center; `; footer.textContent = '点击选项即可复制到剪贴板'; panel.appendChild(footer); return panel; } // 复制到剪贴板 function copyToClipboard(text) { navigator.clipboard.writeText(text).catch(() => { const textarea = document.createElement('textarea'); textarea.value = text; document.body.appendChild(textarea); textarea.select(); document.execCommand('copy'); document.body.removeChild(textarea); }); } // 显示通知 function showNotification(message) { const notification = document.createElement('div'); notification.textContent = message; notification.style.cssText = ` position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 24px; border-radius: 30px; font-size: 14px; font-weight: 500; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4); z-index: 1000000; animation: slideDown 0.3s ease; `; // 添加动画样式 const style = document.createElement('style'); style.textContent = ` @keyframes slideDown { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } } `; document.head.appendChild(style); document.body.appendChild(notification); setTimeout(() => { notification.style.animation = 'slideDown 0.3s ease reverse'; setTimeout(() => { document.body.removeChild(notification); document.head.removeChild(style); }, 300); }, 1500); } // 初始化 function init() { // 检查是否已存在(防止重复加载) if (document.getElementById('education-selector-btn')) return; const button = createFloatingButton(); button.id = 'education-selector-btn'; const panel = createPanel(); panel.id = 'education-selector-panel'; document.body.appendChild(button); document.body.appendChild(panel); let isPanelOpen = false; button.onclick = () => { isPanelOpen = !isPanelOpen; panel.style.display = isPanelOpen ? 'block' : 'none'; button.innerHTML = isPanelOpen ? '✕ 关闭' : '📚 学历'; button.style.background = isPanelOpen ? 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)' : 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'; }; // 点击其他地方关闭面板 document.addEventListener('click', (e) => { if (!button.contains(e.target) && !panel.contains(e.target) && isPanelOpen) { isPanelOpen = false; panel.style.display = 'none'; button.innerHTML = '📚 学历'; button.style.background = 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'; } }); } // 页面加载完成后初始化 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();