// ==UserScript==
// @name 给DeepSeek添加原生化的提示词管理功能
// @namespace http://tampermonkey.net/
// @version 1.5
// @description 为 DeepSeek 添加提示词管理功能,点击直接进输入框。
// @author 独爱冰淇淋
// @match https://chat.deepseek.com/*
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// @license MIT
// @downloadURL https://update.greasyfork.icu/scripts/523368/%E7%BB%99DeepSeek%E6%B7%BB%E5%8A%A0%E5%8E%9F%E7%94%9F%E5%8C%96%E7%9A%84%E6%8F%90%E7%A4%BA%E8%AF%8D%E7%AE%A1%E7%90%86%E5%8A%9F%E8%83%BD.user.js
// @updateURL https://update.greasyfork.icu/scripts/523368/%E7%BB%99DeepSeek%E6%B7%BB%E5%8A%A0%E5%8E%9F%E7%94%9F%E5%8C%96%E7%9A%84%E6%8F%90%E7%A4%BA%E8%AF%8D%E7%AE%A1%E7%90%86%E5%8A%9F%E8%83%BD.meta.js
// ==/UserScript==
(function() {
'use strict';
// 添加样式
GM_addStyle(`
.prompt-list {
position: fixed;
background: #FFFFFF;
border-radius: 12px;
width: 640px;
max-height: 80vh;
overflow-y: auto;
display: none;
z-index: 1000;
box-shadow: 0px 12px 24px 0px rgba(0, 0, 0, 0.08);
padding: 0;
}
.prompt-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 20px;
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
position: sticky;
top: 0;
background: #FFFFFF;
z-index: 1;
}
.prompt-title {
font-size: 16px;
font-weight: 600;
color: rgb(28, 28, 28);
margin: 0;
}
.add-prompt-btn {
padding: 6px 12px;
border-radius: 6px;
border: none;
background: rgb(77, 107, 254);
color: #FFFFFF;
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: all 0.2s;
display: flex;
align-items: center;
gap: 4px;
}
.add-prompt-btn:hover {
background: rgb(56, 86, 233);
}
.prompt-list-content {
padding: 12px 16px;
}
.prompt-item {
display: flex;
align-items: center;
padding: 8px 12px;
border-radius: 6px;
margin: 4px 0;
border: 1px solid transparent;
transition: all 0.2s;
cursor: pointer;
position: relative;
gap: 6px;
}
.prompt-item:hover {
background: rgb(248, 248, 249);
border-color: rgba(0, 0, 0, 0.06);
}
.prompt-item-left {
font-size: 13px;
font-weight: 600;
color: #1c1c1c;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex-shrink: 0;
position: relative;
padding-right: 12px;
line-height: 1.5;
min-width: 60px;
}
.prompt-item-left::after {
content: '';
position: absolute;
right: 6px;
top: 50%;
transform: translateY(-50%);
width: 1px;
height: 14px;
background-color: rgba(0, 0, 0, 0.1);
}
.prompt-item-content {
flex: 1;
min-width: 0;
font-size: 13px;
color: #666;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 4px;
line-height: 1.5;
}
.prompt-actions {
position: static;
display: none;
transform: none;
margin-left: auto;
padding-left: 4px;
opacity: 0;
transition: opacity 0.2s;
}
.prompt-item:hover .prompt-actions {
display: flex;
opacity: 1;
}
.prompt-action-btn {
background: none;
border: none;
padding: 4px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
color: #1c1c1c;
opacity: 0.7;
transition: opacity 0.2s;
}
.prompt-action-btn:hover {
opacity: 1;
}
.edit-prompt {
color: #1c1c1c;
}
.edit-prompt:hover {
color: #000000;
}
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.4);
display: flex;
align-items: start;
justify-content: center;
z-index: 1001;
padding-top: 100px;
}
.modal-content {
background: white;
border-radius: 8px;
width: 90%;
max-width: 600px;
position: relative;
padding: 24px 32px;
}
.modal-header {
font-size: 16px;
font-weight: 600;
margin-bottom: 20px;
padding-right: 24px;
}
.modal-close {
position: absolute;
right: 16px;
top: 16px;
cursor: pointer;
padding: 8px;
background: none;
border: none;
color: #666;
font-size: 18px;
line-height: 1;
}
.form-group {
margin-bottom: 16px;
}
.form-label {
display: block;
margin-bottom: 8px;
font-size: 14px;
color: #1c1c1c;
}
.form-label span {
color: #ff4d4f;
margin-left: 4px;
}
.form-input {
width: 100%;
padding: 8px 12px;
border: 1px solid #d9d9d9;
border-radius: 6px;
font-size: 14px;
line-height: 1.5;
box-sizing: border-box;
transition: all 0.2s;
}
.form-input:focus {
outline: none;
border-color: #4d6bfe;
box-shadow: 0 0 0 2px rgba(77, 107, 254, 0.1);
}
.form-input::placeholder {
color: #bfbfbf;
}
textarea.form-input {
min-height: 120px;
resize: vertical;
}
.modal-footer {
margin-top: 24px;
text-align: right;
}
.save-btn {
background: rgb(79, 70, 229);
color: white;
border: none;
padding: 8px 32px;
border-radius: 20px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: all 0.2s;
}
.save-btn:hover {
background: rgb(67, 56, 202);
}
.delete-prompt {
background-color: #dc2626;
color: white;
padding: 3px 8px;
border-radius: 4px;
transition: background-color 0.2s;
}
.delete-prompt:hover {
background-color: #b91c1c;
color: white;
}
.confirm-dialog {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
z-index: 1003;
width: 300px;
}
.confirm-dialog-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 1002;
}
.confirm-dialog-title {
font-size: 16px;
font-weight: 500;
margin-bottom: 12px;
color: #1c1c1c;
}
.confirm-dialog-buttons {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-top: 16px;
}
.confirm-dialog-button {
padding: 6px 12px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
}
.confirm-dialog-cancel {
background: #f3f4f6;
color: #374151;
}
.confirm-dialog-cancel:hover {
background: #e5e7eb;
}
.confirm-dialog-confirm {
background: #dc2626;
color: white;
}
.confirm-dialog-confirm:hover {
background: #b91c1c;
}
.prompt-action-btn {
padding: 8px;
background: transparent;
border: none;
cursor: pointer;
color: #666;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
}
.prompt-action-btn:hover {
background: rgba(0, 0, 0, 0.06);
color: #333;
}
.edit-prompt svg {
width: 16px;
height: 16px;
}
.prompt-header-buttons {
display: flex;
gap: 8px;
align-items: center;
}
.import-export-btn {
display: flex;
align-items: center;
justify-content: center;
padding: 4px;
border: none;
background: transparent;
color: #666;
cursor: pointer;
border-radius: 4px;
}
.import-export-btn:hover {
background: rgba(0, 0, 0, 0.06);
color: #333;
}
.import-export-menu {
position: absolute;
top: 100%;
right: 0;
background: white;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
padding: 4px;
z-index: 1001;
}
.import-export-menu button {
display: block;
width: 100%;
padding: 8px 16px;
border: none;
background: none;
text-align: left;
cursor: pointer;
border-radius: 4px;
color: #1c1c1c;
font-size: 14px;
}
.import-export-menu button:hover {
background: rgba(0, 0, 0, 0.06);
}
`);
function createElements() {
// 找到按钮容器
const buttonContainer = document.querySelector('.ec4f5d61');
if (!buttonContainer) {
console.log('Button container not found');
return;
}
// 创建按钮
const promptButtonWrapper = document.createElement('div');
promptButtonWrapper.setAttribute('role', 'button');
promptButtonWrapper.className = 'ds-button ds-button--rect ds-button--m prompt-saver-button';
promptButtonWrapper.style.cssText = `
background-color: #FFFFFF;
padding: 4px 6px;
height: 28px;
border-radius: 14px;
border: 1px solid rgba(0, 0, 0, 0.12);
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 1.5px;
font-size: 12px;
line-height: 1;
white-space: nowrap;
transition: all 0.2s;
box-sizing: border-box;
margin: 0 12px 0 4px;
`;
// 添加鼠标悬停效果
promptButtonWrapper.addEventListener('mouseenter', () => {
if (promptList.style.display === 'none') { // 只在列表隐藏时改变悬停颜色
promptButtonWrapper.style.backgroundColor = 'rgb(224, 228, 237)';
}
});
promptButtonWrapper.addEventListener('mouseleave', () => {
if (promptList.style.display === 'none') { // 只在列表隐藏时恢复背景色
promptButtonWrapper.style.backgroundColor = '#FFFFFF';
}
});
// 创建图标
const iconSpan = document.createElement('span');
iconSpan.className = 'ds-button__icon';
iconSpan.style.cssText = `
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
color: #1c1c1c;
margin-right: -1px;
`;
const iconSvg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
iconSvg.setAttribute('width', '18');
iconSvg.setAttribute('height', '18');
iconSvg.setAttribute('viewBox', '0 0 16 16');
iconSvg.setAttribute('fill', 'none');
iconSvg.style.cssText = `
color: inherit;
width: 100%;
height: 100%;
`;
iconSvg.innerHTML = `