// ==UserScript== // @name 导出DeepSeek回答为图片 | Export DeepSeek Answer to Image // @namespace http://github.com/byronleeeee/exportDeepseek // @version 1.1 // @description 将DeepSeek的回答导出为一张图片 // @author ByronLeeeee // @match *://chat.deepseek.com/* // @grant none // @require https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // i18n translations const i18n = { 'zh': { exportBtn: '导出AI回答为图片', notFound: 'AI回答区域未找到!', selectScheme: '选择配色方案:', footer: '回答来自DeepSeek,仅供参考', lastAnswer: '最新回答', colorSchemes: [ { name: '白色-蓝色', top: '#FFFFFF', bottom: '#4D6BFE', textTop: '#000000', textBottom: '#FFFFFF' }, { name: '黑色-金色', top: '#121212', bottom: '#FFD700', textTop: '#FFFFFF', textBottom: '#000000' }, { name: '浅灰-青色', top: '#F5F5F5', bottom: '#008080', textTop: '#000000', textBottom: '#FFFFFF' }, { name: '深灰-紫色', top: '#333333', bottom: '#800080', textTop: '#FFFFFF', textBottom: '#FFFFFF' } ], error: '生成图片失败,请查看控制台了解详情。', cancel: '取消', export: '导出', addCreator: '添加生成者信息', creatorName: '生成者名称', creatorPlaceholder: '输入你的名字' }, 'en': { exportBtn: 'Export AI Answer to Image', notFound: 'AI answer div not found!', selectScheme: 'Select a color scheme:', footer: 'Answer from DeepSeek, for reference only', lastAnswer: 'Last Answer', colorSchemes: [ { name: 'White-Blue', top: '#FFFFFF', bottom: '#4D6BFE', textTop: '#000000', textBottom: '#FFFFFF' }, { name: 'Black-Gold', top: '#121212', bottom: '#FFD700', textTop: '#FFFFFF', textBottom: '#000000' }, { name: 'Light Gray-Teal', top: '#F5F5F5', bottom: '#008080', textTop: '#000000', textBottom: '#FFFFFF' }, { name: 'Dark Gray-Purple', top: '#333333', bottom: '#800080', textTop: '#FFFFFF', textBottom: '#FFFFFF' } ], error: 'Failed to generate image. Check console for details.', cancel: 'Cancel', export: 'Export', addCreator: 'Add creator info', creatorName: 'Creator name', creatorPlaceholder: 'Enter your name' } }; const userLang = (navigator.language || navigator.userLanguage).split('-')[0]; const lang = i18n[userLang] ? userLang : 'en'; const texts = i18n[lang]; // Add styles with dark mode support function addStyles() { const style = document.createElement('style'); style.textContent = ` .ai-export-fab { position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; border-radius: 50%; background-color: #4D6BFE; color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 8px rgba(0,0,0,0.2); z-index: 9999; transition: all 0.3s ease; } .ai-export-fab:hover { transform: scale(1.05); box-shadow: 0 6px 12px rgba(0,0,0,0.3); } .ai-export-fab-icon { display: flex; align-items: center; justify-content: center; } .ai-export-tooltip { position: absolute; background: rgba(0,0,0,0.7); color: white; padding: 5px 10px; border-radius: 4px; font-size: 12px; white-space: nowrap; right: 70px; opacity: 0; transition: opacity 0.3s; pointer-events: none; } .ai-export-fab:hover .ai-export-tooltip { opacity: 1; } .ai-color-scheme-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 10000; } .ai-modal-content { background-color: white; border-radius: 8px; padding: 20px; width: 300px; max-width: 90%; color: #000000; /* Default for light mode */ } body.dark .ai-modal-content { background-color: #1e1e1e; /* Dark mode background */ color: #ffffff; /* Dark mode text */ } .ai-modal-header { font-size: 18px; font-weight: bold; margin-bottom: 15px; } .ai-scheme-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; } .ai-scheme-option { border: 2px solid transparent; border-radius: 6px; overflow: hidden; cursor: pointer; transition: all 0.2s; } .ai-scheme-option:hover { transform: translateY(-2px); } .ai-scheme-option.selected { border-color: #4D6BFE; } .ai-scheme-preview { display: flex; flex-direction: column; height: 100px; } .ai-scheme-top { flex: 3; display: flex; align-items: center; justify-content: center; font-weight: bold; } .ai-scheme-bottom { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 12px; } .ai-modal-buttons { display: flex; justify-content: flex-end; gap: 10px; } .ai-modal-button { padding: 8px 16px; border-radius: 4px; border: none; cursor: pointer; font-weight: bold; } .ai-modal-button.primary { background-color: #4D6BFE; color: white; } .ai-modal-button.secondary { background-color: #f1f1f1; color: #333; } body.dark .ai-modal-button.secondary { background-color: #333333; color: #ffffff; } .ai-export-button { position: absolute; top: 10px; right: 10px; background-color: #4D6BFE; color: white; border: none; border-radius: 4px; padding: 4px 8px; font-size: 12px; cursor: pointer; opacity: 0; transition: opacity 0.2s; z-index: 100; } ._4f9bf79:hover .ai-export-button { opacity: 1; } .ai-creator-option { margin: 15px 0; } .ai-creator-checkbox { margin-right: 8px; } .ai-creator-input { margin-top: 8px; width: 100%; padding: 8px; border-radius: 4px; border: 1px solid #ccc; box-sizing: border-box; display: none; } body.dark .ai-creator-input { background-color: #333; color: #fff; border-color: #555; } `; document.head.appendChild(style); } // Create FAB function createFAB() { const fab = document.createElement('div'); fab.innerHTML = `