// ==UserScript== // @name Prompt Manager (Fixed Vertical Drag with Copy & Close) // @namespace http://tampermonkey.net/ // @version 2.7.5 // @description 在AI网站上保存并快速使用 Prompts,同时支持拖动按钮及位置保存 —— 修复按钮只能横向拖动的问题,增大关闭按钮点击区域并上移碰撞箱,复制后显示成功并自动关闭 // @author schweigen // @match https://chatgpt.com/* // @match https://claude.ai/* // @match https://chat.deepseek.com/* // @match https://www.perplexity.ai/* // @match https://chat.mistral.ai/* // @match https://app.nextchat.dev/* // @match https://chat01.ai/* // @match https://you.com/* // @match https://chatgpt.aicnm.cc/* // @match https://chatshare.xyz/* // @match https://chat.biggraph.net/* // @match https://grok.com/* // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_deleteValue // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // === 用户可编辑的 Prompts 列表 === const prompts = [ { title: "", content: `` }, { title: "", content: `` }, { title: "", content: `` }, { title: "", content: `` }, { title: "", content: `` }, { title: "", content: `` }, { title: "", content: `` }, { title: "", content: `` }, { title: "", content: `` }, { title: "", content: `` }, ]; // 添加必要的样式 GM_addStyle(` /* Prompt Manager 容器样式 */ #prompt-manager { position: fixed !important; top: 80px !important; right: 20px !important; width: 350px !important; max-height: 80vh !important; overflow-y: auto !important; overflow-x: visible !important; background: #ffffff !important; border: 1px solid #e1e4e8 !important; border-radius: 12px !important; box-shadow: 0 4px 16px rgba(0,0,0,0.1) !important; z-index: 2147483647 !important; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; display: block !important; color: #24292e !important; opacity: 1 !important; visibility: visible !important; } #prompt-manager.hidden { display: none !important; } /* 标题样式 */ #prompt-manager h2 { margin: 0 !important; padding: 16px !important; background: #2c3e50 !important; color: #ffffff !important; border-radius: 12px 12px 0 0 !important; text-align: center !important; font-size: 18px !important; font-weight: 600 !important; position: relative !important; } /* 关闭按钮样式(碰撞箱上移) */ #close-prompt-btn { position: absolute !important; top: -10px !important; /* 向上移动显示区域 */ right: 0 !important; padding: 10px 16px !important; cursor: pointer !important; font-size: 20px !important; color: #ffffff !important; user-select: none !important; } /* Prompt 项样式 */ .prompt-item { border-bottom: 1px solid #e1e4e8 !important; padding: 12px 16px !important; position: relative !important; transition: all 0.2s ease !important; background: #ffffff !important; } .prompt-item:hover { background: #f6f8fa !important; } .prompt-title { font-weight: 500 !important; cursor: pointer !important; position: relative !important; display: flex !important; justify-content: space-between !important; align-items: center !important; color: #2c3e50 !important; } .prompt-content { display: none !important; margin-top: 8px !important; white-space: pre-wrap !important; background: #f8f9fa !important; padding: 12px !important; border-radius: 6px !important; cursor: pointer !important; transition: background 0.2s ease !important; color: #2c3e50 !important; border: 1px solid #e1e4e8 !important; } .prompt-content:hover { background: #edf2f7 !important; } /* 复制按钮样式 */ .copy-button { background: #3498db !important; color: #ffffff !important; border: none !important; padding: 6px 12px !important; border-radius: 4px !important; cursor: pointer !important; font-size: 12px !important; margin-left: 10px !important; transition: all 0.2s ease !important; } .copy-button:hover { background: #2980b9 !important; transform: translateY(-1px) !important; } /* Toggle 按钮样式 */ #toggle-prompt-btn { position: fixed !important; top: 60px !important; right: 20px !important; width: 40px !important; height: 40px !important; background: #3498db !important; color: #ffffff !important; border: none !important; border-radius: 50% !important; cursor: pointer !important; font-size: 20px !important; display: flex !important; align-items: center !important; justify-content: center !important; z-index: 2147483647 !important; transition: all 0.2s ease !important; box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important; opacity: 1 !important; visibility: visible !important; } #toggle-prompt-btn:hover { background: #2980b9 !important; transform: translateY(-1px) !important; } /* 复制成功提示样式 */ #copy-success { position: fixed !important; top: 100px !important; right: 20px !important; background: #2ecc71 !important; color: #ffffff !important; padding: 8px 16px !important; border-radius: 6px !important; opacity: 0 !important; transition: opacity 0.3s ease !important; z-index: 2147483647 !important; font-size: 14px !important; box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important; } /* 内部成功提示样式 */ .inner-success { background: #2ecc71 !important; color: #ffffff !important; padding: 8px 12px !important; margin-top: 8px !important; border-radius: 6px !important; text-align: center !important; font-size: 14px !important; display: none !important; } /* 搜索输入框样式 */ #search-input { width: calc(100% - 32px) !important; padding: 10px 12px !important; margin: 16px !important; border: 1px solid #e1e4e8 !important; border-radius: 6px !important; background: #f8f9fa !important; color: #2c3e50 !important; font-size: 14px !important; transition: all 0.2s ease !important; } #search-input:focus { outline: none !important; border-color: #3498db !important; box-shadow: 0 0 0 2px rgba(52,152,219,0.2) !important; } #search-input::placeholder { color: #95a5a6 !important; } `); // 确保DOM加载完成后再创建元素 function createElements() { // 创建 Toggle 按钮 const toggleBtn = document.createElement('button'); toggleBtn.id = 'toggle-prompt-btn'; toggleBtn.title = '隐藏/显示 Prompt Manager'; toggleBtn.innerHTML = '☰'; document.body.appendChild(toggleBtn); // 如果用户之前拖动过,则恢复按钮保存的位置 const savedX = GM_getValue('toggleBtnX', null); const savedY = GM_getValue('toggleBtnY', null); if (savedX !== null && savedY !== null) { toggleBtn.style.setProperty('left', savedX + 'px', 'important'); toggleBtn.style.setProperty('top', savedY + 'px', 'important'); toggleBtn.style.setProperty('right', 'auto', 'important'); } // 创建 Prompt Manager 容器,增加了关闭叉号 const manager = document.createElement('div'); manager.id = 'prompt-manager'; manager.classList.add('hidden'); // 默认隐藏 manager.innerHTML = `