// ==UserScript== // @name S1 Plus - Stage1st 体验增强套件 // @namespace http://tampermonkey.net/ // @version 3.0 // @description 为Stage1st论坛提供帖子/用户屏蔽、导航栏自定义、自动签到、阅读进度跟踪等多种功能,全方位优化你的论坛体验。 // @author moekyo & Elence_ylns1314 (Merged and enhanced by Gemini) // @match https://stage1st.com/2b/* // @grant GM_setValue // @grant GM_getValue // @grant GM_addStyle // @license MIT // @downloadURL none // ==/UserScript== (function () { 'use strict'; const SCRIPT_VERSION = '3.0'; const SCRIPT_RELEASE_DATE = '2025-07-27'; // --- 样式注入 --- GM_addStyle(` /* --- 核心修复:禁用论坛自带的用户信息悬浮窗 --- */ #p_pop { display: none !important; } /* --- 按钮通用样式 --- */ .s1plus-btn { display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; background-color: #f3f4f6; color: #374151; font-size: 12px; font-weight: bold; cursor: pointer; user-select: none; white-space: nowrap; border: none; } .s1plus-btn:hover { background-color: #ef4444; color: white; } /* --- 帖子屏蔽按钮动画与布局 --- */ .thread-block-btn { position: absolute; top: 50%; left: 50%; z-index: 5; padding: 5px 10px 5px 12px; border-radius: 0 30px 30px 0; background-color: #f87171; color: white; font-size: 12px; border: none; box-shadow: 0 1px 3px rgba(0,0,0,0.2); opacity: 0; visibility: hidden; transform: translate(-50%, -50%) scale(0.85); transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); } tbody[id^="normalthread_"]:hover .thread-block-btn, tbody[id^="stickthread_"]:hover .thread-block-btn { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); transition-delay: 0.1s; } .thread-block-btn:hover { background-color: #ef4444; transform: translate(-50%, -50%) scale(1.1); } /* 阅读进度跳转按钮样式 */ .s1plus-progress-jump-btn { display: inline-block; margin: 0 8px; font-size: 12px; font-weight: normal; color: #6b7280; text-decoration: none; border: 1px solid #e5e7eb; background-color: #f9fafb; border-radius: 4px; padding: 1px 6px; transition: all 0.2s ease-in-out; vertical-align: middle; } .s1plus-progress-jump-btn:hover { color: white; background-color: #3b82f6; border-color: #3b82f6; } /* --- 用户屏蔽悬停交互样式 --- */ .s1plus-avatar-overlay-container { position: absolute; display: flex; align-items: center; justify-content: center; background-color: rgba(0, 0, 0, 0.55); opacity: 0; visibility: hidden; transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out; pointer-events: auto; z-index: 10; } .pls:hover .s1plus-avatar-overlay-container { opacity: 1; visibility: visible; } .s1plus-avatar-overlay-container .s1plus-btn { color: white; background-color: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.5); transform: scale(1); transition: all 0.2s ease-in-out; padding: 4px 8px; } .s1plus-avatar-overlay-container .s1plus-btn:hover { background-color: #ef4444; border-color: #ef4444; transform: scale(1.05); } /* --- 设置面板样式 --- */ .s1plus-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 9999; } .s1plus-modal-content { background-color: white; border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); width: 600px; max-width: 90%; max-height: 80vh; overflow: hidden; display: flex; flex-direction: column; } .s1plus-modal-header { padding: 16px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; } .s1plus-modal-title { font-size: 18px; font-weight: bold; color: #111827; } .s1plus-modal-close { cursor: pointer; font-size: 20px; color: #6b7280; } .s1plus-modal-body { padding: 0 16px 16px; overflow-y: auto; flex-grow: 1; } .s1plus-modal-footer { padding: 12px 16px; border-top: 1px solid #e5e7eb; text-align: right; font-size: 12px; color: #9ca3af; } .s1plus-tabs { display: flex; border-bottom: 1px solid #e5e7eb; margin-bottom: 16px; } .s1plus-tab-btn { padding: 12px 16px; cursor: pointer; border: none; background-color: transparent; font-size: 14px; color: #6b7280; border-bottom: 2px solid transparent; transition: all 0.2s; } .s1plus-tab-btn:hover { color: #111827; } .s1plus-tab-btn.active { color: #3b82f6; border-bottom-color: #3b82f6; font-weight: 500; } .s1plus-tab-content { display: none; padding-top: 8px; } .s1plus-tab-content.active { display: block; } .s1plus-empty { text-align: center; padding: 24px; color: #6b7280; } .s1plus-list { display: flex; flex-direction: column; gap: 8px; } .s1plus-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px; border-radius: 6px; background-color: #f9fafb; border: 1px solid #e5e7eb; } .s1plus-item-info { flex-grow: 1; min-width: 0; } .s1plus-item-title { font-weight: 500; color: #111827; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .s1plus-item-meta { font-size: 12px; color: #6b7280; margin-bottom: 8px; } .s1plus-item-toggle { font-size: 12px; color: #374151; display: flex; align-items: center; } .s1plus-item-toggle input { margin-right: 6px; transform: scale(1.1); } .s1plus-unblock-btn { padding: 6px 12px; border-radius: 4px; background-color: #f3f4f6; color: #6b7280; font-size: 14px; cursor: pointer; transition: all 0.2s; border: none; flex-shrink: 0; align-self: center; } .s1plus-unblock-btn:hover { background-color: #10b981; color: white; } .s1plus-sync-title { font-weight: 500; color: #111827; margin-bottom: 8px; } .s1plus-sync-desc { font-size: 14px; color: #6b7280; margin-bottom: 12px; line-height: 1.5; } .s1plus-sync-buttons { display: flex; gap: 8px; margin-bottom: 16px; } .s1plus-sync-btn { padding: 6px 12px; border-radius: 4px; background-color: #f3f4f6; color: #6b7280; font-size: 14px; cursor: pointer; transition: all 0.2s; border: none; } .s1plus-sync-btn:hover { background-color: #3b82f6; color: white; } .s1plus-sync-textarea { width: 100%; min-height: 80px; padding: 8px; border-radius: 4px; border: 1px solid #e5e7eb; font-family: monospace; font-size: 12px; resize: vertical; margin-bottom: 8px; box-sizing: border-box; } .s1plus-message { font-size: 14px; margin-top: 8px; padding: 8px; border-radius: 4px; display:none; text-align: center; } .s1plus-message.success { background-color: #d1fae5; color: #065f46; } .s1plus-message.error { background-color: #fee2e2; color: #b91c1c; } /* --- 确认弹窗样式 --- */ @keyframes s1plus-fade-in { from { opacity: 0; } to { opacity: 1; } } @keyframes s1plus-scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } } @keyframes s1plus-fade-out { from { opacity: 1; } to { opacity: 0; } } @keyframes s1plus-scale-out { from { transform: scale(1); opacity: 1; } to { transform: scale(0.97); opacity: 0; } } .s1plus-confirm-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.65); display: flex; justify-content: center; align-items: center; z-index: 10000; animation: s1plus-fade-in 0.2s ease-out; } .s1plus-confirm-content { background-color: white; border-radius: 12px; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); width: 420px; max-width: 90%; text-align: left; overflow: hidden; animation: s1plus-scale-in 0.25s ease-out; } .s1plus-confirm-body { padding: 20px 24px; font-size: 16px; color: #1f2937; line-height: 1.6; } .s1plus-confirm-body .confirm-title { font-weight: 600; font-size: 18px; margin-bottom: 8px; } .s1plus-confirm-body .confirm-subtitle { font-size: 14px; color: #6b7280; } .s1plus-confirm-footer { padding: 12px 16px; background-color: #f3f3f3ff; display: flex; justify-content: flex-end; gap: 12px; } .s1plus-confirm-btn { padding: 9px 18px; border-radius: 6px; font-size: 14px; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: all 0.15s ease-in-out; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); } .s1plus-confirm-btn:active { transform: translateY(1px); } .s1plus-confirm-btn.cancel { background-color: white; color: #374151; border-color: #d1d5db; } .s1plus-confirm-btn.cancel:hover { background-color: #f9fafb; border-color: #b0b8c2; } .s1plus-confirm-btn.confirm { background-color: #ef4444; color: white; border-color: #ef4444; } .s1plus-confirm-btn.confirm:hover { background-color: #dc2626; border-color: #dc2626; } /* --- 界面定制设置样式 --- */ .s1-settings-group { margin-bottom: 24px; } .s1-settings-group-title { font-size: 16px; font-weight: 500; color: #111827; border-bottom: 1px solid #e5e7eb; padding-bottom: 8px; margin-bottom: 12px; } .s1-settings-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; } .s1-settings-label { color: #374151; font-size: 14px; } .s1-settings-checkbox { transform: scale(1.2); } .s1plus-setting-desc { font-size: 12px; color: #6b7280; margin: -12px 0 16px 4px; padding: 0; line-height: 1.5; } .s1-nav-editor-item { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 8px; align-items: center; padding: 8px; border-radius: 4px; background: #f9fafb; user-select: none; } .s1-nav-editor-item:not(:last-child) { margin-bottom: 8px; } .s1-nav-editor-item.dragging { opacity: 0.5; background: #dbeafe; } .s1-nav-editor-item .drag-handle { cursor: grab; color: #9ca3af; padding: 0 8px; } .s1-nav-editor-item .drag-handle:active { cursor: grabbing; } .s1-nav-editor-item input { width: 100%; border: 1px solid #d1d5db; border-radius: 4px; padding: 6px 8px; font-size: 14px; box-sizing: border-box; } .s1-nav-editor-controls { display: flex; align-items: center; gap: 4px; } .s1-nav-editor-btn { padding: 4px; font-size: 18px; line-height: 1; cursor: pointer; border-radius: 4px; border:none; background: transparent; color: #9ca3af; } .s1-nav-editor-btn:hover { background: #e5e7eb; color: #374151; } .s1-nav-editor-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; } .s1-settings-action-btn { display: inline-block; padding: 10px 20px; border-radius: 6px; font-size: 14px; font-weight: 500; cursor: pointer; transition: background-color 0.2s; border: none; } .s1-settings-action-btn.primary { background-color: #3b82f6; color: white; } .s1-settings-action-btn.primary:hover { background-color: #2563eb; } .s1-settings-action-btn.secondary { background-color: #e5e7eb; color: #374151; } .s1-settings-action-btn.secondary:hover { background-color: #d1d5db; } `); // --- 数据处理 & 核心功能 --- const getBlockedThreads = () => GM_getValue('s1plus_blocked_threads', {}); const saveBlockedThreads = (threads) => GM_setValue('s1plus_blocked_threads', threads); const getBlockedUsers = () => GM_getValue('s1plus_blocked_users', {}); const saveBlockedUsers = (users) => GM_setValue('s1plus_blocked_users', users); const blockThread = (id, title, reason = 'manual') => { const b = getBlockedThreads(); if (b[id]) return; b[id] = { title, timestamp: Date.now(), reason }; saveBlockedThreads(b); hideThread(id); }; const unblockThread = (id) => { const b = getBlockedThreads(); delete b[id]; saveBlockedThreads(b); showThread(id); }; const hideThread = (id) => { (document.getElementById(`normalthread_${id}`) || document.getElementById(`stickthread_${id}`))?.setAttribute('style', 'display: none !important'); }; const showThread = (id) => { (document.getElementById(`normalthread_${id}`) || document.getElementById(`stickthread_${id}`))?.removeAttribute('style'); } const hideBlockedThreads = () => Object.keys(getBlockedThreads()).forEach(hideThread); const blockUser = (id, name) => { const settings = getSettings(); const b = getBlockedUsers(); b[id] = { name, timestamp: Date.now(), blockThreads: settings.blockThreadsOnUserBlock }; saveBlockedUsers(b); hideUserPosts(id); if (b[id].blockThreads) applyUserThreadBlocklist(); }; const unblockUser = (id) => { const b = getBlockedUsers(); delete b[id]; saveBlockedUsers(b); showUserPosts(id); unblockThreadsByUser(id); }; const hideUserPosts = (id) => { document.querySelectorAll(`a[href*="space-uid-${id}.html"]`).forEach(l => l.closest('table.plhin')?.setAttribute('style', 'display: none !important')); }; const showUserPosts = (id) => { document.querySelectorAll(`a[href*="space-uid-${id}.html"]`).forEach(l => l.closest('table.plhin')?.removeAttribute('style')); }; const hideBlockedUsersPosts = () => Object.keys(getBlockedUsers()).forEach(hideUserPosts); const getReadProgress = () => GM_getValue('s1plus_read_progress', {}); const saveReadProgress = (progress) => GM_setValue('s1plus_read_progress', progress); const updateThreadProgress = (threadId, postId, page) => { if (!postId || !page) return; const progress = getReadProgress(); progress[threadId] = { postId, page, timestamp: Date.now() }; saveReadProgress(progress); }; const applyUserThreadBlocklist = () => { const blockedUsers = getBlockedUsers(); const usersToBlockThreads = Object.keys(blockedUsers).filter(uid => blockedUsers[uid].blockThreads); if (usersToBlockThreads.length === 0) return; document.querySelectorAll('tbody[id^="normalthread_"]').forEach(row => { const authorLink = row.querySelector('td.by cite a[href*="space-uid-"]'); if (authorLink) { const uidMatch = authorLink.href.match(/space-uid-(\d+)\.html/); const authorId = uidMatch ? uidMatch[1] : null; if (authorId && usersToBlockThreads.includes(authorId)) { const threadId = row.id.replace('normalthread_', ''); const titleElement = row.querySelector('th a.s.xst'); if (threadId && titleElement) { blockThread(threadId, titleElement.textContent.trim(), `user_${authorId}`); } } } }); }; const unblockThreadsByUser = (userId) => { const allBlockedThreads = getBlockedThreads(); const reason = `user_${userId}`; Object.keys(allBlockedThreads).forEach(threadId => { if (allBlockedThreads[threadId].reason === reason) { unblockThread(threadId); } }); }; const exportData = () => JSON.stringify({ version: 3.1, settings: getSettings(), threads: getBlockedThreads(), users: getBlockedUsers(), read_progress: getReadProgress() }, null, 2); const importData = (jsonStr) => { try { const imported = JSON.parse(jsonStr); if (typeof imported !== 'object' || imported === null) throw new Error("无效数据格式"); let threadsImported = 0, usersImported = 0, progressImported = 0; const upgradeAndMerge = (type, importedData, getter, saver) => { if (!importedData || typeof importedData !== 'object') return 0; Object.keys(importedData).forEach(id => { const item = importedData[id]; if (type === 'users' && typeof item.blockThreads === 'undefined') item.blockThreads = false; if (type === 'threads' && typeof item.reason === 'undefined') item.reason = 'manual'; }); const merged = { ...getter(), ...importedData }; saver(merged); return Object.keys(importedData).length; }; if(imported.settings) { saveSettings({...getSettings(), ...imported.settings}); } threadsImported = upgradeAndMerge('threads', imported.threads, getBlockedThreads, saveBlockedThreads); usersImported = upgradeAndMerge('users', imported.users, getBlockedUsers, saveBlockedUsers); if (imported.read_progress) { const mergedProgress = { ...getReadProgress(), ...imported.read_progress }; saveReadProgress(mergedProgress); progressImported = Object.keys(imported.read_progress).length; } hideBlockedThreads(); hideBlockedUsersPosts(); applyUserThreadBlocklist(); initializeNavbar(); applyInterfaceCustomizations(); return { success: true, message: `成功导入 ${threadsImported} 条帖子、${usersImported} 条用户、${progressImported} 条阅读进度及相关设置。` }; } catch (e) { return { success: false, message: `导入失败: ${e.message}` }; } }; // --- 设置管理 --- const defaultSettings = { enableNavCustomization: true, changeLogoLink: true, hideBlacklistTip: true, blockThreadsOnUserBlock: true, customNavLinks: [ { name: '论坛', href: 'forum.php' }, { name: '归墟', href: 'forum-157-1.html' }, { name: '漫区', href: 'forum-6-1.html' }, { name: '游戏', href: 'forum-4-1.html' }, { name: '影视', href: 'forum-48-1.html' }, { name: 'PC数码', href: 'forum-51-1.html' }, { name: '黑名单', href: 'home.php?mod=space&do=friend&view=blacklist' } ] }; const getSettings = () => { const saved = GM_getValue('s1plus_settings', {}); return {...defaultSettings, ...saved}; }; const saveSettings = (settings) => GM_setValue('s1plus_settings', settings); // --- 界面定制功能 --- const applyInterfaceCustomizations = () => { const settings = getSettings(); if (settings.changeLogoLink) document.querySelector('#hd h2 a')?.setAttribute('href', './forum.php'); if (settings.hideBlacklistTip) document.getElementById('hiddenpoststip')?.remove(); }; const initializeNavbar = () => { const settings = getSettings(); const navUl = document.querySelector('#nv > ul'); if (!navUl) return; const createManagerLink = () => { const li = document.createElement('li'); li.id = 's1plus-nav-link'; const a = document.createElement('a'); a.href = 'javascript:void(0);'; a.textContent = 'S1 Plus 设置'; a.addEventListener('click', createManagementModal); li.appendChild(a); return li; }; document.getElementById('s1plus-nav-link')?.remove(); if (settings.enableNavCustomization) { navUl.innerHTML = ''; (settings.customNavLinks || []).forEach(link => { if(!link.name || !link.href) return; const li = document.createElement('li'); if (window.location.href.includes(link.href)) li.className = 'a'; const a = document.createElement('a'); a.href = link.href; a.textContent = link.name; a.setAttribute('hidefocus', 'true'); li.appendChild(a); navUl.appendChild(li); }); } navUl.appendChild(createManagerLink()); }; // --- UI 创建 --- const formatDate = (timestamp) => new Date(timestamp).toLocaleString('zh-CN'); const showMessage = (msgEl, message, isSuccess) => { msgEl.textContent = message; msgEl.className = `s1plus-message ${isSuccess ? 'success' : 'error'}`; msgEl.style.display = 'block'; setTimeout(() => { msgEl.style.display = 'none'; }, 3000); }; const createConfirmationModal = (title, subtitle, onConfirm) => { document.querySelector('.s1plus-confirm-modal')?.remove(); const modal = document.createElement('div'); modal.className = 's1plus-confirm-modal'; modal.innerHTML = `
提示:顶部总开关仅影响未来新屏蔽用户的默认设置。每个用户下方的独立开关,才是控制该用户主题帖的最终开关,拥有最高优先级。
${userItemIds.length === 0 ? `