v1.0
-
作者:@vernal_blossom
-
更新时间:2025-7-25
-
更新内容:
- 将本插件成功地写出来
-
Code
JavaScript // ==UserScript== // @name CatOJ美化 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 为号家军OJ添加美化效果,优化性能和视觉体验 // @author vernal_blossom // @match https://oj.hjjoi.com/* // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @run-at document-start // ==/UserScript== (function() { 'use strict'; // 添加全局样式 - 优化性能和视觉效果 GM_addStyle(` /* 优化动画性能 */ * { will-change: transform, opacity; backface-visibility: hidden; } /* ==== 修复hljs代码块纯白背景问题 ==== */ .hljs { background-color: rgba(15, 25, 45, 0.7) !important; border: 1px solid rgba(64, 128, 255, 0.25) !important; border-radius: 12px !important; padding: 15px !important; margin: 15px 0 !important; overflow: auto; box-shadow: 0 4px 12px rgba(0, 20, 60, 0.3) !important; } .hljs code { background: transparent !important; color: #e0f7ff !important; } .hljs-keyword, .hljs-selector-tag, .hljs-literal { color: #ff79c6 !important; /* 粉色 */ } .hljs-number, .hljs-string, .hljs-meta .hljs-string { color: #f1fa8c !important; /* 黄色 */ } .hljs-comment { color: #6272a4 !important; /* 灰色蓝 */ font-style: italic; } .hljs-title, .hljs-section { color: #50fa7b !important; /* 绿色 */ } .hljs-built_in, .hljs-name { color: #8be9fd !important; /* 青色 */ } /* ==== 全局字体颜色设置 ==== */ body, body *, .ant-typography, .description-content, .ant-select-selection-item, .ant-btn, .loginstatus-username, .avatarname-username, .ant-page-header-heading-title, .ant-layout-footer, .ant-menu-title-content, .ant-menu-item-icon svg, .anticon svg, .ant-dropdown-trigger, .bg-toggle-btn, .particles-toggle-btn, .ant-dropdown-menu-item, .ant-dropdown-menu-title-content, .ant-table-cell, .ant-tag, .ant-list-item, .ant-alert-message, .ant-statistic-content, .ant-input, .ant-input-number-input, .ant-radio-wrapper, .ant-checkbox-wrapper, .ant-form-item-label > label, .ant-tabs-tab, .ant-tabs-tab-btn, .ant-result-title, .ant-result-subtitle, .ant-comment-content-author-name, .ant-comment-content-detail { color: #e0f7ff !important; /* 所有文字使用浅色 */ } /* ==== 特定元素颜色定制 ==== */ /* 空间项使用浅绿色 */ .ant-space-item { color: #7df9ff !important; /* 浅绿色 */ } /* 标签使用绿色 */ .ant-tag.css-bzolti.css-var { color: #00ff7f !important; /* 亮绿色 */ border-color: #00ff7f !important; background: rgba(0, 255, 127, 0.1) !important; box-shadow: 0 0 8px rgba(0, 255, 127, 0.5) !important; } /* 内容区域使用浅蓝色 */ .ant-layout-content.app-content.css-bzolti.css-var, .app-content.css-bzolti.css-var, .ant-layout-content.css-bzolti.css-var { color: #7df9ff !important; /* 浅蓝色 */ } /* 修复所有白色背景问题 */ body, .ant-layout, .css-bzolti, .ant-card, .app-content, .ant-select-selector, .ant-page-header, .ant-space-item, .ant-divider, .ant-btn-default, .loginstatus-dropdown, .avatarname-username, .ant-tag, .ant-input, .ant-input-affix-wrapper, .ant-alert, .ant-list-item, .ant-table-cell, .ant-popover-inner, .ant-modal-content { background: transparent !important; } /* 修复表格表头透明 */ .ant-table-thead > tr > th { background: rgba(15, 25, 45, 0.5) !important; backdrop-filter: blur(12px) saturate(180%) !important; -webkit-backdrop-filter: blur(12px) saturate(180%) !important; border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important; } /* 修复表格行透明 */ .ant-table-tbody > tr > td { background: rgba(15, 25, 45, 0.3) !important; border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important; } /* 表格行悬停效果 */ .ant-table-tbody > tr:hover > td { background: rgba(64, 128, 255, 0.2) !important; } /* 修复头像用户名背景问题 */ .avatarname-username, .loginstatus-username { background: transparent !important; text-shadow: 0 0 5px rgba(0, 0, 0, 0.5) !important; } /* 修复边框颜色问题 */ .ant-card, .app-content, .ant-select-selector, .ant-divider, .ant-btn-default, .ant-input, .ant-input-affix-wrapper, .ant-tag { border-color: rgba(255, 255, 255, 0.15) !important; } /* 渐变背景 */ body::before { content: ""; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, #0f1a3d, #2a0b3a, #0d2b4e); background-size: 400% 400%; animation: gradientBG 15s ease infinite; z-index: -3; opacity: 1; transition: opacity 0.5s ease; } /* 图片背景 */ body::after { content: ""; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: url('https://t.alcy.cc/fj') center/cover no-repeat; z-index: -4; opacity: 0; transition: opacity 0.5s ease; } /* 图片背景激活状态 */ body.image-bg::after { opacity: 1; } /* 禁用彩色背景 */ body.image-bg::before { opacity: 0; } /* 背景动画 */ @keyframes gradientBG { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } /* 亚克力效果 - 导航栏 */ .app-header { background: rgba(15, 25, 45, 0.7) !important; backdrop-filter: blur(12px) saturate(180%) !important; -webkit-backdrop-filter: blur(12px) saturate(180%) !important; border: 1px solid rgba(64, 128, 255, 0.25) !important; box-shadow: 0 8px 32px rgba(0, 20, 60, 0.3) !important; border-radius: 12px !important; margin: 15px !important; padding: 12px 25px !important; display: flex; justify-content: space-between; align-items: center; } /* 修复导航栏布局 */ .app-logo { color: #4fc3f7 !important; font-size: 1.8rem !important; font-weight: bold !important; text-shadow: 0 0 10px rgba(79, 195, 247, 0.5) !important; } .app-menu { background: transparent !important; backdrop-filter: none !important; border: none !important; box-shadow: none !important; } .ant-menu-overflow-item.ant-menu-item { font-weight: 500; font-size: 1.1rem; padding: 8px 15px !important; border-radius: 8px !important; transition: all 0.3s ease !important; } .ant-menu-overflow-item.ant-menu-item:hover { background: rgba(64, 128, 255, 0.25) !important; transform: translateY(-2px); text-shadow: 0 0 5px white; } .ant-menu-item-icon { margin-right: 8px !important; color: #4fc3f7 !important; } /* 用户区域移到最右侧 */ .user-area-container { display: flex; align-items: center; margin-left: auto; /* 关键:推到最右边 */ gap: 15px; } /* 设置按钮样式 */ .bg-toggle-btn, .particles-toggle-btn { background: rgba(64, 128, 255, 0.25) !important; border: none !important; border-radius: 20px !important; padding: 8px 15px !important; cursor: pointer; transition: all 0.3s ease; display: flex; align-items: center; gap: 8px; font-size: 0.95rem; font-weight: 500; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); } .bg-toggle-btn:hover, .particles-toggle-btn:hover { background: rgba(79, 195, 247, 0.4) !important; transform: scale(1.05); box-shadow: 0 0 15px rgba(79, 195, 247, 0.7); } /* 按钮图标样式 */ .bg-toggle-btn svg, .particles-toggle-btn svg { width: 18px; height: 18px; } /* 亚克力效果 - 卡片 */ .ant-card { background: rgba(15, 25, 45, 0.5) !important; backdrop-filter: blur(12px) saturate(180%) !important; -webkit-backdrop-filter: blur(12px) saturate(180%) !important; border: 1px solid rgba(64, 128, 255, 0.25) !important; box-shadow: 0 8px 32px rgba(0, 20, 60, 0.3) !important; border-radius: 20px !important; margin-top: 15px !important; padding: 20px !important; } /* 亚克力效果 - 内容区域 */ .app-content { background: rgba(15, 25, 45, 0.5) !important; backdrop-filter: blur(12px) saturate(180%) !important; -webkit-backdrop-filter: blur(12px) saturate(180%) !important; border: 1px solid rgba(64, 128, 255, 0.25) !important; box-shadow: 0 8px 32px rgba(0, 20, 60, 0.3) !important; border-radius: 20px !important; margin: 15px !important; padding: 25px !important; } /* 头像展开效果 - 高度优化 */ .loginstatus-dropdown { display: flex !important; align-items: center !important; transition: all 0.4s ease !important; padding: 5px 10px !important; border-radius: 30px !important; background: rgba(25, 45, 75, 0.5) !important; height: 36px !important; margin-left: auto; /* 确保在容器内靠右 */ } .loginstatus-username { max-width: 0 !important; opacity: 0 !important; overflow: hidden !important; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; margin-left: 0 !important; font-weight: bold !important; font-size: 1rem !important; text-shadow: 0 0 5px rgba(0,0,0,0.5) !important; } .loginstatus-dropdown:hover .loginstatus-username { max-width: 200px !important; opacity: 1 !important; margin-left: 10px !important; } .loginstatus-avatar { transition: transform 0.3s ease !important; border: 2px solid rgba(79, 195, 247, 0.5); width: 26px !important; height: 26px !important; } .loginstatus-dropdown:hover .loginstatus-avatar { transform: scale(1.15) !important; box-shadow: 0 0 15px rgba(79, 195, 247, 0.6) !important; } /* 修复下拉箭头颜色 */ .anticon-down svg { fill: #e0f7ff !important; } .loginstatus-dropdown:hover .anticon-down svg { fill: #4fc3f7 !important; } /* 按钮美化 */ .ant-btn { transition: all 0.3s ease !important; border-radius: 8px !important; font-weight: 500 !important; } .ant-btn-primary { background: linear-gradient(45deg, #1e88e5, #0d47a1) !important; border: none !important; box-shadow: 0 4px 15px rgba(30, 136, 229, 0.4) !important; } .ant-btn-primary:hover { transform: translateY(-3px) !important; box-shadow: 0 6px 20px rgba(30, 136, 229, 0.6) !important; background: linear-gradient(45deg, #2196f3, #1565c0) !important; } /* 标题美化 */ .ant-page-header-heading-title { color: #4fc3f7 !important; font-size: 2rem !important; text-shadow: 0 0 15px rgba(79, 195, 247, 0.5) !important; } /* 页脚美化 */ .ant-layout-footer { background: rgba(15, 25, 45, 0.7) !important; padding: 20px !important; text-align: center !important; border-top: 1px solid rgba(64, 128, 255, 0.25) !important; border-radius: 12px !important; margin: 15px !important; backdrop-filter: blur(5px); } .ant-layout-footer a { color: #4fc3f7 !important; text-decoration: none; transition: all 0.3s ease; } .ant-layout-footer a:hover { color: #81d4fa !important; text-shadow: 0 0 5px rgba(129, 212, 250, 0.5); } /* 粒子画布 */ #particles-canvas { position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; z-index: -1 !important; } /* 快速提交区域美化 */ #quick-submit-file { background: rgba(25, 45, 75, 0.5) !important; border-radius: 8px !important; padding: 10px !important; border: 1px solid rgba(64, 128, 255, 0.25) !important; width: 100% !important; margin-top: 10px !important; transition: all 0.3s ease; } #quick-submit-file:hover { background: rgba(35, 65, 105, 0.6) !important; border-color: rgba(79, 195, 247, 0.5) !important; } /* 右下角按钮美化 */ .ant-btn-circle.ant-btn-lg { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3) !important; transition: all 0.3s ease !important; background: linear-gradient(45极光效果, #1e88e5, #0d47a1) !important; border: none !important; } .ant-btn-circle.ant-btn-lg:hover { transform: scale(1.1) rotate(10deg) !important; box-shadow: 0 8px 20px rgba(30, 136, 229, 0.6) !important; background: linear-gradient(45deg, #2196f3, #1565c0) !important; } /* 修复选择框文本颜色 */ .ant-select-selection-item { color: #e0f7ff !important; } /* 修复所有图标颜色 */ .anticon svg { fill: #e0f7ff !important; } .ant-menu-item:hover .anticon svg { fill: #4fc3f7 !important; } /* 修复分隔线颜色 */ .ant-divider { background: rgba(64, 128, 255, 0.25) !important; } `); // 创建粒子效果画布 const canvas = document.createElement('canvas'); canvas.id = 'particles-canvas'; document.body.appendChild(canvas); // 粒子系统 - 增强效果 const initParticles = function() { const ctx = canvas.getContext('2d'); canvas.width = window.innerWidth; canvas.height = window.innerHeight; // 根据屏幕大小调整粒子数量(性能优化) const particleCount = Math.min(250, Math.floor((window.innerWidth * window.innerHeight) / 5000)); const particles = []; // 创建粒子 for (let i = 0; i < particleCount; i++) { particles.push({ x: Math.random() * canvas.width, y: Math.random() * canvas.height, radius: Math.random() * 5 + 3, // 增大粒子尺寸 speedX: (Math.random() - 0.5) * 1.2, // 提高速度 speedY: (Math.random() - 0.5) * 1.2, color: `rgba(79, 195, 247, ${Math.random() * 0.6 + 0.4})` // 提高透明度 }); } let animationId = null; let isRunning = true; let lastTime = 0; const frameRate = 30; // 限制帧率提高性能 const frameInterval = 1000 / frameRate; // 绘制粒子 function draw(timestamp) { if (!lastTime) last极光效果 = timestamp; const deltaTime = timestamp - lastTime; if (deltaTime > frameInterval) { lastTime = timestamp - (deltaTime % frameInterval); ctx.clearRect(0, 0, canvas.width, canvas.height); // 绘制连接线 for (let i = 0; i < particles.length; i++) { for (let j = i + 1; j < particles.length; j++) { const dx = particles[i].x - particles[j].x; const dy = particles[i].y - particles[j].y; const distance = Math.sqrt(dx * dx + dy * dy); if (distance < 180) { // 增大连接距离 ctx.beginPath(); ctx.strokeStyle = `rgba(79, 195, 247, ${0.5 * (1 - distance/180)})`; // 提高透明度 ctx.lineWidth = 1.0; // 加粗线条 ctx.moveTo(particles[i].x, particles[i].y); ctx.lineTo(particles[j].x, particles[j].y); ctx.stroke(); } } } // 绘制粒子 particles.forEach(p => { ctx.beginPath(); ctx.arc(p.x, p.y, p.radius, 0, Math.PI * 2); // 添加发光效果 const gradient = ctx.createRadialGradient( p.x, p.y, 0, p.x, p.y, p.radius ); gradient.addColorStop(0, `rgba(79, 195, 247, 1)`); gradient.addColorStop(0.7, `rgba(79, 195, 247, 0.5)`); gradient.addColorStop(1, `rgba(79, 195, 247, 0.2)`); ctx.fillStyle = gradient; ctx.fill(); // 更新位置 p.x += p.speedX; p.y += p.speedY; // 边界检查 if (p.x < 0 || p.x > canvas.width) p.speedX *= -1; if (p.y < 0 || p.y > canvas.height) p.speedY *= -1; }); } if (isRunning) { animationId = requestAnimationFrame(draw); } } draw(); // 控制函数 return { start: function() { if (!isRunning) { isRunning = true; canvas.style.display = 'block'; lastTime = 0; draw(); } }, stop: function() { if (isRunning) { isRunning = false; if (animationId) { cancelAnimationFrame(animationId); animationId = null; } canvas.style.display = 'none'; } }, toggle: function() { if (isRunning) { this.stop(); } else { this.start(); } return isRunning; } }; }; let particlesControl = null; // 背景切换功能 function initBackgroundToggle() { // 创建背景切换按钮 const bgToggleBtn = document.createElement('button'); bgToggleBtn.className = 'bg-toggle-btn'; bgToggleBtn.innerHTML = ` <svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"> <path d="M12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 Z M12,4 C16.418278,4 20,7.581722 20,12 C20,16.418278 16.418278,20 12,20 C7.581722,20 4,16.418278 4,12 C4,7.581722 7.581722,4 12,4 Z M12,6 C8.6862915,6 6,8.6862915 6,12 C6,15.3137085 8.6862915,18 12,18 C15.3137085,18 18,15.3137085 18,12 C18,8.6862915 15.3137085,6 12,6 Z M12,8 C14.209139,8 16,9.790861 16,12 C16,14.209139 14.209139,16 12,16 C9.790861,16 8,14.209139 8,12 C8,9.790861 9.790861,8 12,8 Z"></path> </svg> 背景切换 `; // 切换背景函数 function toggleBackground() { const isImageBg = document.body.classList.toggle('image-bg'); GM_setValue('useImageBackground', isImageBg); bgToggleBtn.innerHTML = ` <svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"> <path d="${isImageBg ? 'M12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 Z M12,4 C16.418278,4 20,7.581722 20,12 C20,16.418278 16.418278,20 12,20 C7.581722,20 4,16.418278 4,12 C4,7.581722 7.581722,4 12,4 Z M12,6 C8.6862915,6 6,8.6862915 6,12 C6,15.3137085 8.6862915,18 12,18 C15.3137085,18 18,15.3137085 18,12 C18,8.6862915 15.3137085,6 12,6 Z' : 'M12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 Z M12,4 C16.418278,4 20,7.581722 20,12 C20,16.418278 16.418278,20 12,20 C7.581722,20 4,16.418278 4,12 C4,7.581722 7.581722,4 12,4 Z M12,6 C8.6862915,6 6,8.6862915 6,12 C6,15.3137085 8.6862915,18 12,18 C15.3137085,18 18,15.3137085 18,12 C18,8.6862915 15.3137085,6 12,6 Z M12,8 C14.209139,8 16,9.790861 16,12 C16,14.209139 14.209139,16 12,16 C9.790861,16 8,14.209139 8,12 C8,9.790861 9.790861,8 12,8 Z'}"></path> </svg> ${isImageBg ? '渐变背景' : '图片背景'} `; } bgToggleBtn.addEventListener('click', toggleBackground); return bgToggleBtn; } // 粒子效果开关 function initParticlesToggle() { const particlesToggleBtn = document.createElement('button'); particlesToggleBtn.className = 'particles-toggle-btn'; particlesToggleBtn.innerHTML = ` <svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"> <path d="M12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 Z M4,12 C4,9.87867966 4.84285512,7.84314513 6.34314575,6.34314575 C7.84343637,4.84314637 9.87867966,4 12,4 C14.1213203,4 16.1565636,4.84314637 17.6568542,6.34314575 C19.1571449,7.84314513 20,9.87867966 20,12 C20,14.1213203 19.1571449,16.1568549 17.6568542,17.6568542 C16.1565636,19.1568536 14.1213203,20 12,20 C9.87867966,20 7.84343637,19.1568536 6.34314575,17.6568542 C4.84285512,16.1568549 4,14.1213203 4,12 Z M12,6 C8.6862915,6 6,8.6862915 6,12 C6,15.3137085 8.6862915,18 12,18 C15.3137085,18 18,15.3137085 18,12 C18,8.6862915 15.3137085,6 12,6 Z M12,8 C14.209139,8 16,9.790861 16,12 C16,14.209139 14.209139,16 12,16 C9.790861,16 8,14.209139 8,12 C8,9.790861 9.790861,8 12,8 Z"></path> </svg> 粒子效果 `; // 从存储中获取粒子状态 const particlesEnabled = GM_getValue('particlesEnabled', true); if (!particlesEnabled && particlesControl) { particlesControl.stop(); particlesToggleBtn.innerHTML = ` <svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"> <path d="M12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 Z M4,12 C4,9.87867966 4.84285512,7.84314513 6.34314575,6.34314575 C7.84343637,4.84314637 9.87867966,4 12,4 C14.1213203,4 16.1565636,4.84314637 17.6568542,6.34314575 C19.1571449,7.84314513 20,9.87867966 20,12 C20,14.1213203 19.1571449,16.1568549 17.6568542,17.6568542 C16.1565636,19.1568536 14.1213203,20 12,20 C9.87867966,20 7.84343637,19.1568536 6.34314575,17.6568542 C4.84285512,16.1568549 4,14.1213203 4,12 Z M8,12 C8,9.790861 9.790861,8 12,8 C14.209139,8 16,9.790861 16,12 C16,14.209139 14.209139,16 12,16 C9.790861,16 8,14.209139 8,12 Z M10,12 C10,13.1045695 10.8954305,14 12,14 C13.1045695,14 14,13.1045695 14,12 C14,10.8954305 13.1045695,10 12,10 C10.8954305,10 10,10.8954305 10,12 Z"></path> </svg> 粒子效果 `; } // 切换粒子效果 particlesToggleBtn.addEventListener('click', function() { if (particlesControl) { const nowEnabled = particlesControl.toggle(); GM_setValue('particlesEnabled', nowEnabled); particlesToggleBtn.innerHTML = ` <svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"> <path d="${nowEnabled ? 'M12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 Z M4,12 C4,9.87867966 4.84285512,7.84314513 6.34314575,6.34314575 C7.84343637,4.84314637 9.87867966,4 12,4 C14.1213203,4 16.1565636,4.84314637 17.6568542,6.34314575 C19.1571449,7.84314513 20,9.87867966 20,12 C20,14.1213203 19.1571449,16.1568549 17.6568542,17.6568542 C16.1565636,19.1568536 14.1213203,20 12,20 C9.87867966,20 7.84343637,19.1568536 6.34314575,17.6568542 C4.84285512,16.1568549 4,14.1213203 4,12 Z M12,6 C8.6862915,6 6,8.6862915 6,12 C6,15.3137085 8.6862915,18 12,18 C15.3137085,18 18,15.3137085 18,12 C18,8.6862915 15.3137085,6 12,6 Z M12,8 C14.209139,8 16,9.790861 16,12 C16,14.209139 14.209139,16 12,16 C9.790861,16 8,14.209139 8,12 C8,9.790861 9.790861,8 12,8 Z' : 'M12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 Z M4,12 C4,9.87867966 4.84285512,7.84314513 6.34314575,6.34314575 C7.84343637,4.84314637 9.87867966,4 12,4 C14.1213203,4 16.1565636,4.84314637 17.6568542,6.34314575 C19.1571449,7.84314513 20,9.87867966 20,12 C20,14.1213203 19.1571449,16.1568549 17.6568542,17.6568542 C16.1565636,19.1568536 14.1213203,20 12,20 C9.87867966,20 7.84343637,19.1568536 6.34314575,17.6568542 C4.84285512,16.1568549 4,14.1213203 4,12 Z M8,12 C8,9.790861 9.790861,8 12,8 C14.209139,8 16,9.790861 16,12 C16,14.209139 14.209139,16 12,16 C9.790861,16 8,14.209139 8,12 Z M10,12 C10,13.1045695 10.8954305,14 12,14 C13.1045695,14 14,13.1045695 14,12 C14,10.8954305 13.1045695,10 12,10 C10.8954305,10 10,10.8954305 10,12 Z'}"></path> </svg> ${nowEnabled ? '关闭粒子' : '开启粒子'} `; } }); return particlesToggleBtn; } // 确保页面加载完成后初始化 window.addEventListener('DOMContentLoaded', function() { // 创建用户区域容器(确保在导航栏最右侧) const userAreaContainer = document.createElement('div'); userAreaContainer.className = 'user-area-container'; userAreaContainer.style.marginLeft = 'auto'; // 确保在导航栏最右侧 userAreaContainer.style.display = 'flex'; userAreaContainer.style.alignItems = 'center'; userAreaContainer.style.gap = '15px'; // 添加背景切换按钮 const bgToggleBtn = initBackgroundToggle(); userAreaContainer.appendChild(bgToggleBtn); // 添加粒子切换按钮 const particlesToggleBtn = initParticlesToggle(); userAreaContainer.appendChild(particlesToggleBtn); // 获取现有用户区域 const userArea = document.querySelector('.loginstatus-dropdown'); if (userArea) { // 确保用户名在容器内靠右 userArea.style.marginLeft = 'auto'; userAreaContainer.appendChild(userArea); } // 将用户容器添加到导航栏 const header = document.querySelector('.app-header'); if (header) { // 确保容器在导航栏最右侧 header.appendChild(userAreaContainer); } // 应用保存的背景设置 const useImageBackground = GM_getValue('useImageBackground', false); if (useImageBackground) { document.body.classList.add('image-bg'); } // 延迟初始化粒子系统(提高页面加载速度) setTimeout(() => { particlesControl = initParticles(); // 应用粒子效果状态 const particlesEnabled = GM_getValue('particlesEnabled', true); if (!particlesEnabled) { particlesControl.stop(); } }, 1000); // 窗口大小改变时重置画布 window.addEventListener('resize', function() { if (canvas) { canvas.width = window.innerWidth; canvas.height = window.innerHeight; } }); }); })();