// ==UserScript== // @name AI懒人包 // @name:en AI Prompt Injector // @namespace ai-prompt-injector // @description 一键注入预设提示词,让AI帮你干活!支持文心一言、ChatGPT、豆包、DeepSeek等平台,支持自定义提示词 // @description:en One-click prompt injection for AI assistants. Support Wenxin Yiyan, ChatGPT, Doubao, DeepSeek and more. Custom prompts supported. // @version 2.1 // @author WHATIFAAA // @icon https://www.google.com/s2/favicons?domain=doubao.com // @match *://*.doubao.com/* // @match *://*.baidu.com/* // @match *://*.openai.com/* // @match *://*.moonshot.cn/* // @match *://*.anthropic.com/* // @match *://*.deepseek.com/* // @run-at document-end // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // ==/UserScript== (function() { 'use strict'; console.log('AI懒人包脚本已加载'); console.log('当前URL:', window.location.href); const PLATFORMS = { yiyan: { name: '文心一言', urlPattern: /yiyan\.baidu\.com/ }, chatgpt: { name: 'ChatGPT', urlPattern: /chat\.openai\.com/ }, doubao: { name: '豆包', urlPattern: /doubao\.com/ }, kimi: { name: 'Kimi', urlPattern: /kimi\.moonshot\.cn/ }, claude: { name: 'Claude', urlPattern: /claude\.anthropic\.com/ }, deepseek: { name: 'DeepSeek', urlPattern: /deepseek\.com/ } }; const PROMPTS = [ { category: '文案写作', items: [ { name: '小红书文案', prompt: `请帮我写一篇小红书风格的文案,主题是【在这里输入你的主题】。\n\n我的信息:\n- 地点:{{CURRENT_LOCATION}}\n- 时间:{{CURRENT_DATE}}\n- 身份:{{USER_IDENTITY}}\n\n要求:\n- 标题吸睛,带emoji表情\n- 语言活泼亲切,使用网络流行语\n- 结构清晰,有干货分享\n- 结尾引导互动\n- 字数控制在300-500字\n\n请按照以下格式输出:\n🎀 标题:\n✨ 正文:\n💡 小贴士:\n👇 互动:` }, { name: '公众号推文', prompt: `请帮我写一篇公众号推文,主题是【在这里输入你的主题】。\n\n我的信息:\n- 地点:{{CURRENT_LOCATION}}\n- 时间:{{CURRENT_DATE}}\n- 身份:{{USER_IDENTITY}}\n\n要求:\n- 标题要有吸引力,符合微信生态\n- 开头要有钩子,引发兴趣\n- 内容有价值,结构清晰\n- 结尾有引导关注和互动\n- 字数控制在1500-2000字\n\n请提供完整的推文内容,包括配图建议。` }, { name: '产品文案', prompt: `请帮我为【产品名称】写一段产品文案。\n\n产品信息:【请描述产品特点、功能、优势】\n目标人群:【目标用户群体】\n我的身份:{{USER_IDENTITY}}\n\n要求:\n- 突出产品核心卖点\n- 语言简洁有力\n- 激发购买欲望\n- 适合电商平台使用\n\n请提供:1) 主标题 2) 副标题 3) 核心卖点(3-5点) 4) 行动号召语` }, { name: '活动海报文案', prompt: `请帮我写一个活动海报文案,活动主题是【活动名称】。\n\n活动详情:\n- 时间:【活动时间】\n- 地点:【活动地点】(默认{{CURRENT_LOCATION}})\n- 参与人群:【目标人群】\n- 活动亮点:【3-5个亮点】\n\n风格要求:【文艺/活泼/高端/简约】\n\n请提供:主标题、副标题、活动信息、亮点列表、行动号召语。` } ] }, { category: '工作办公', items: [ { name: '写周报', prompt: `请帮我写一份{{CURRENT_YEAR}}年{{CURRENT_MONTH}}月的工作周报。\n\n我的信息:\n- 身份:{{USER_IDENTITY}}\n- 时间:{{CURRENT_DATE}}\n\n本周工作内容:\n【请输入本周完成的工作】\n\n下周计划:\n【请输入下周工作计划】\n\n遇到的问题:\n【如有问题请输入】\n\n要求:\n- 格式清晰,分点列出\n- 语言专业简洁\n- 突出工作成果和价值\n- 字数控制在500-800字` }, { name: '写邮件', prompt: `请帮我写一封邮件。\n\n邮件类型:【工作汇报/商务合作/请假申请/其他】\n收件人:【收件人姓名/职位】\n主题:【邮件主题】\n我的身份:{{USER_IDENTITY}}\n\n邮件内容要点:\n【请输入邮件主要内容】\n\n要求:\n- 格式规范,专业得体\n- 语言简洁明了\n- 语气恰当\n- 包含必要的称呼和落款` }, { name: '会议纪要', prompt: `请帮我整理会议纪要。\n\n会议主题:【会议主题】\n会议时间:{{CURRENT_TIME}}\n参会人员:【姓名列表】\n\n会议内容要点:\n【请输入会议讨论内容】\n\n决议事项:\n【请输入会议决定】\n\n后续行动:\n【请输入待办事项及负责人】\n\n要求:格式清晰,便于跟踪执行。` }, { name: 'PPT大纲', prompt: `请帮我设计一份PPT大纲,主题是【主题名称】。\n\n目标受众:【目标人群】\n核心目的:【演示目的】\n预计时长:【演示时间】\n我的身份:{{USER_IDENTITY}}\n\n要求:\n- 结构清晰,逻辑严谨\n- 建议页数:10-15页\n- 包含封面、目录、内容页、总结\n- 每页简要说明内容要点` } ] }, { category: '编程开发', items: [ { name: '写代码', prompt: `请帮我写一段代码。\n\n需求描述:\n【请详细描述你的需求】\n\n技术栈:\n【请指定编程语言和框架】\n\n要求:\n- 代码结构清晰\n- 添加必要的注释\n- 提供测试用例(如果适用)\n- 说明使用方法` }, { name: '代码审查', prompt: `请帮我审查这段代码。\n\n代码内容:\n【请粘贴你的代码】\n\n审查关注点:\n- 代码质量和规范性\n- 潜在的bug和性能问题\n- 安全性问题\n- 代码优化建议\n\n请给出详细的审查意见和改进建议。` }, { name: '技术方案', prompt: `请帮我设计一个技术方案。\n\n需求背景:\n【请描述业务需求】\n\n技术约束:\n【请说明技术限制条件】\n\n需要设计的内容:\n- 架构设计\n- 技术选型\n- 数据库设计\n- API接口设计\n- 关键流程图\n\n请提供详细的技术方案文档。` }, { name: 'Bug排查', prompt: `请帮我排查一个Bug。\n\n问题描述:\n【请详细描述问题现象】\n\n出现场景:\n【请说明触发条件】\n\n相关代码:\n【请粘贴相关代码】\n\n已经尝试的解决方法:\n【请说明已尝试的方案】\n\n请分析可能的原因并给出解决方案。` } ] }, { category: '学习教育', items: [ { name: '写论文', prompt: `请帮我写一篇学术论文,主题是【论文主题】。\n\n我的信息:\n- 身份:{{USER_IDENTITY}}\n- 时间:{{CURRENT_DATE}}\n\n论文类型:【本科/硕士/期刊论文】\n学科领域:【学科名称】\n字数要求:【具体字数】\n\n要求:\n- 结构完整(摘要、引言、正文、结论、参考文献)\n- 逻辑严谨,论证充分\n- 引用格式规范\n- 提供参考文献列表` }, { name: '知识点总结', prompt: `请帮我总结【知识点名称】的核心内容。\n\n我的身份:{{USER_IDENTITY}}\n\n要求:\n- 条理清晰,分点列出\n- 突出重点和难点\n- 包含关键概念和公式\n- 适合快速复习\n- 可配合思维导图结构` }, { name: '学习计划', prompt: `请帮我制定一份学习计划。\n\n学习目标:【目标描述】\n时间周期:【学习时长】\n现有基础:【当前水平】\n我的身份:{{USER_IDENTITY}}\n\n要求:\n- 合理安排学习进度\n- 包含具体学习内容\n- 设定阶段性目标\n- 提供学习资源建议\n- 包含复习和练习安排` }, { name: '解题思路', prompt: `请帮我分析这道题目。\n\n题目内容:\n【请粘贴题目】\n\n我的身份:{{USER_IDENTITY}}\n\n要求:\n- 分析解题思路\n- 提供详细解答步骤\n- 解释关键知识点\n- 给出举一反三的建议\n- 说明易错点` } ] }, { category: '生活娱乐', items: [ { name: '周末去哪玩', prompt: `请帮我推荐{{CURRENT_LOCATION}}周末好玩的地方。\n\n我的信息:\n- 时间:{{CURRENT_DATE}}({{CURRENT_WEEKDAY}})\n- 地点:{{CURRENT_LOCATION}}\n- 身份:{{USER_IDENTITY}}\n- 预算:{{USER_BUDGET}}\n- 兴趣:{{USER_INTERESTS}}\n\n要求:推荐 3-5 个地方,要有逼格,要省钱,要适合拍照发朋友圈。` }, { name: '本地美食', prompt: `请帮我推荐{{CURRENT_LOCATION}}的特色美食。\n\n我的信息:\n- 地点:{{CURRENT_LOCATION}}\n- 身份:{{USER_IDENTITY}}\n- 预算:{{USER_BUDGET}}\n- 兴趣:{{USER_INTERESTS}}\n\n要求:\n- 推荐本地特色菜系和必吃餐厅\n- 考虑{{TIME_PERIOD}}用餐场景\n- 适合{{USER_BUDGET}}预算\n- 推荐3-5家餐厅及招牌菜` }, { name: '旅行攻略', prompt: `请帮我规划一次旅行。\n\n目的地:【城市/景点名称】\n旅行天数:【天数】\n出行时间:【季节/月份】\n我的出发地:{{CURRENT_LOCATION}}\n我的预算:{{USER_BUDGET}}\n我的兴趣:{{USER_INTERESTS}}\n同行人数:【人数】\n\n要求:\n- 详细行程安排(每天)\n- 必去景点推荐\n- 美食推荐\n- 交通住宿建议\n- 注意事项和旅行小贴士` }, { name: '菜谱推荐', prompt: `请帮我推荐一些菜谱。\n\n我的信息:\n- 地点:{{CURRENT_LOCATION}}\n- 身份:{{USER_IDENTITY}}\n- 预算:{{USER_BUDGET}}\n\n需求:\n- 菜系偏好:【中/西/日/韩/其他,默认为{{CURRENT_LOCATION}}本地菜】\n- 烹饪难度:【简单/中等/复杂】\n- 食材限制:【素食/无辣/海鲜/其他】\n- 用餐场景:【早餐/午餐/晚餐/聚会】\n\n请提供3-5个菜谱,包含:\n- 菜名\n- 所需食材(份量)\n- 详细做法步骤\n- 烹饪小贴士` }, { name: '礼物推荐', prompt: `请帮我推荐一份礼物。\n\n送礼对象:【父母/朋友/恋人/同事】\n年龄范围:【年龄段】\n兴趣爱好:【兴趣描述,默认{{USER_INTERESTS}}】\n预算范围:【预算金额,默认{{USER_BUDGET}}】\n送礼场合:【生日/节日/纪念日/其他】\n我的身份:{{USER_IDENTITY}}\n\n请推荐3-5个合适的礼物,并说明推荐理由和购买建议。` }, { name: '电影推荐', prompt: `请帮我推荐一些电影。\n\n我的信息:\n- 身份:{{USER_IDENTITY}}\n- 时间:{{CURRENT_DATE}}\n- 兴趣:{{USER_INTERESTS}}\n\n偏好类型:【动作/喜剧/爱情/科幻/悬疑/文艺/纪录片】\n观影场景:【放松/思考/约会/家庭】\n地区偏好:【中国/美国/日韩/欧洲】\n是否看过:【可提供已看过的电影避免重复】\n\n请推荐5部电影,包含:\n- 电影名称\n- 推荐理由\n- 豆瓣/IMDb评分\n- 适合人群` } ] } ]; const CUSTOM_PROMPTS_KEY = 'ai_prompt_custom_prompts'; const CONFIG_KEY = 'ai_prompt_config'; function getConfig() { try { const saved = GM_getValue(CONFIG_KEY, '{}'); const config = JSON.parse(saved); return { location: config.location || '上海市', identity: config.identity || '大学生', budget: config.budget || '有限', interests: config.interests || '美食、旅行、拍照' }; } catch { return { location: '上海市', identity: '大学生', budget: '有限', interests: '美食、旅行、拍照' }; } } function saveConfig(config) { GM_setValue(CONFIG_KEY, JSON.stringify(config)); } function getCurrentTimeInfo() { const now = new Date(); const year = now.getFullYear(); const month = now.getMonth() + 1; const day = now.getDate(); const weekDay = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][now.getDay()]; const hour = now.getHours(); let timePeriod = ''; if (hour >= 6 && hour < 9) timePeriod = '早晨'; else if (hour >= 9 && hour < 12) timePeriod = '上午'; else if (hour >= 12 && hour < 14) timePeriod = '中午'; else if (hour >= 14 && hour < 18) timePeriod = '下午'; else if (hour >= 18 && hour < 22) timePeriod = '晚上'; else timePeriod = '深夜'; return { year, month, day, weekDay, hour, timePeriod, full: now.toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' }), date: `${year}年${month}月${day}日`, time: `${hour}:${now.getMinutes().toString().padStart(2, '0')}` }; } function replaceVariables(text) { const config = getConfig(); const time = getCurrentTimeInfo(); const variables = { CURRENT_TIME: time.full, CURRENT_YEAR: time.year, CURRENT_MONTH: time.month, CURRENT_DAY: time.day, CURRENT_WEEKDAY: time.weekDay, CURRENT_HOUR: time.hour, TIME_PERIOD: time.timePeriod, CURRENT_DATE: time.date, CURRENT_LOCATION: config.location, USER_IDENTITY: config.identity, USER_BUDGET: config.budget, USER_INTERESTS: config.interests }; let result = text; for (const [key, value] of Object.entries(variables)) { const regex = new RegExp(`\\{\\{${key}\\}\\}`, 'g'); result = result.replace(regex, value); } return result; } function getCustomPrompts() { try { const saved = GM_getValue(CUSTOM_PROMPTS_KEY, '[]'); return JSON.parse(saved); } catch { return []; } } function saveCustomPrompts(prompts) { GM_setValue(CUSTOM_PROMPTS_KEY, JSON.stringify(prompts)); } function addCustomPrompt(name, prompt) { const prompts = getCustomPrompts(); const exists = prompts.some(p => p.name === name); if (!exists) { prompts.push({ name, prompt }); saveCustomPrompts(prompts); } return prompts; } function removeCustomPrompt(name) { const prompts = getCustomPrompts(); const filtered = prompts.filter(p => p.name !== name); saveCustomPrompts(filtered); return filtered; } function getAllPrompts() { const customPrompts = getCustomPrompts(); if (customPrompts.length === 0) { return PROMPTS; } return [ ...PROMPTS, { category: '🎯 我的自定义', items: customPrompts } ]; } function createSettingsPanel() { const panel = document.createElement('div'); panel.id = 'ai-prompt-settings-panel'; panel.style.cssText = ` position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); padding: 24px; width: 520px; max-height: 80vh; overflow-y: auto; z-index: 99999; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; `; const config = getConfig(); panel.innerHTML = `

AI懒人包设置

📍 个人信息设置

📝 添加自定义提示词

🔧 可用变量

在提示词中使用 {{变量名}} 格式,发送时会自动替换为真实值:

{{CURRENT_TIME}} - 当前完整时间
{{CURRENT_DATE}} - 当前日期
{{CURRENT_YEAR}} - 当前年份
{{CURRENT_MONTH}} - 当前月份
{{CURRENT_DAY}} - 当前日期
{{CURRENT_WEEKDAY}} - 当前星期
{{TIME_PERIOD}} - 当前时段
{{CURRENT_LOCATION}} - 你的位置
{{USER_IDENTITY}} - 你的身份
{{USER_BUDGET}} - 你的预算
{{USER_INTERESTS}} - 你的兴趣

我的自定义提示词

`; const overlay = document.createElement('div'); overlay.id = 'prompt-settings-overlay'; overlay.style.cssText = ` position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 9998; `; document.body.appendChild(overlay); document.body.appendChild(panel); updateCustomPromptList(); document.getElementById('prompt-settings-close').addEventListener('click', closePanel); document.getElementById('prompt-settings-overlay').addEventListener('click', closePanel); document.getElementById('custom-prompt-add').addEventListener('click', handleAddPrompt); document.getElementById('custom-prompt-name').addEventListener('keydown', (e) => { if (e.key === 'Enter') document.getElementById('custom-prompt-content').focus(); }); document.getElementById('custom-prompt-content').addEventListener('keydown', (e) => { if (e.key === 'Enter' && e.ctrlKey) handleAddPrompt(); }); document.getElementById('config-save').addEventListener('click', handleSaveConfig); function handleSaveConfig() { const newConfig = { location: document.getElementById('config-location').value.trim() || '上海市', identity: document.getElementById('config-identity').value.trim() || '大学生', budget: document.getElementById('config-budget').value.trim() || '有限', interests: document.getElementById('config-interests').value.trim() || '美食、旅行、拍照' }; saveConfig(newConfig); alert('设置已保存!'); } function closePanel() { panel.remove(); overlay.remove(); refreshSidebar(); } function handleAddPrompt() { const nameInput = document.getElementById('custom-prompt-name'); const contentInput = document.getElementById('custom-prompt-content'); const name = nameInput.value.trim(); const prompt = contentInput.value.trim(); if (!name || !prompt) { alert('请填写完整的提示词名称和内容'); return; } addCustomPrompt(name, prompt); nameInput.value = ''; contentInput.value = ''; updateCustomPromptList(); } function updateCustomPromptList() { const list = document.getElementById('custom-prompt-list'); const prompts = getCustomPrompts(); if (prompts.length === 0) { list.innerHTML = '

暂无自定义提示词

'; return; } list.innerHTML = prompts.map((prompt, index) => `
${index + 1}. ${prompt.name}
${prompt.prompt}
`).join(''); document.querySelectorAll('.custom-prompt-remove-btn').forEach(btn => { btn.addEventListener('click', (e) => { const name = e.target.dataset.name; removeCustomPrompt(name); updateCustomPromptList(); }); }); } } function getCurrentPlatform() { const url = window.location.href; for (const [key, platform] of Object.entries(PLATFORMS)) { if (platform.urlPattern.test(url)) { console.log('匹配到平台:', platform.name); return platform; } } console.log('未匹配到任何平台'); return null; } function getBackgroundColor() { const body = document.body; const html = document.documentElement; const bodyStyle = window.getComputedStyle(body); const htmlStyle = window.getComputedStyle(html); let bgColor = bodyStyle.backgroundColor || htmlStyle.backgroundColor; if (!bgColor || bgColor === 'transparent') { bgColor = 'rgb(255, 255, 255)'; } return bgColor; } function isDarkBackground() { const bgColor = getBackgroundColor(); const rgbMatch = bgColor.match(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i); if (rgbMatch) { const r = parseInt(rgbMatch[1]); const g = parseInt(rgbMatch[2]); const b = parseInt(rgbMatch[3]); const brightness = (r * 299 + g * 587 + b * 114) / 1000; return brightness < 128; } const hexMatch = bgColor.match(/#([0-9a-fA-F]{6})|#([0-9a-fA-F]{3})/); if (hexMatch) { let hex = hexMatch[1] || hexMatch[2]; if (hex.length === 3) { hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; } const r = parseInt(hex.substring(0, 2), 16); const g = parseInt(hex.substring(2, 4), 16); const b = parseInt(hex.substring(4, 6), 16); const brightness = (r * 299 + g * 587 + b * 114) / 1000; return brightness < 128; } return false; } function getThemeColors() { const isDark = isDarkBackground(); console.log('当前背景模式:', isDark ? '深色' : '浅色'); if (isDark) { return { sidebarBg: 'rgba(255, 255, 255, 0.15)', sidebarBorder: 'rgba(255, 255, 255, 0.2)', textColor: '#ffffff', textOpacity: 'rgba(255, 255, 255, 0.7)', btnBg: 'rgba(255, 255, 255, 0.1)', btnHoverBg: 'rgba(255, 255, 255, 0.2)', btnTextColor: '#ffffff' }; } else { return { sidebarBg: 'rgba(255, 255, 255, 0.95)', sidebarBorder: 'rgba(0, 0, 0, 0.1)', textColor: '#333333', textOpacity: 'rgba(0, 0, 0, 0.6)', btnBg: 'rgba(102, 126, 234, 0.1)', btnHoverBg: 'rgba(102, 126, 234, 0.2)', btnTextColor: '#333333' }; } } function sendPrompt(text) { text = replaceVariables(text); console.log('准备发送提示词:', text.substring(0, 50) + '...'); let inputElement = document.querySelector('textarea'); if (!inputElement) { inputElement = document.querySelector('input[type="text"]'); } if (!inputElement) { inputElement = document.querySelector('[contenteditable="true"]'); } if (!inputElement) { console.log('未找到输入框'); return; } inputElement.focus(); if (inputElement.tagName === 'TEXTAREA' || inputElement.tagName === 'INPUT') { const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set; nativeInputValueSetter.call(inputElement, text); const event = new Event('input', { bubbles: true, cancelable: true }); event.simulated = true; inputElement.dispatchEvent(event); inputElement.dispatchEvent(new Event('change', { bubbles: true })); inputElement.dispatchEvent(new Event('keyup', { bubbles: true })); } else if (inputElement.isContentEditable) { inputElement.innerHTML = text; inputElement.dispatchEvent(new Event('input', { bubbles: true })); inputElement.dispatchEvent(new Event('blur', { bubbles: true })); } setTimeout(() => { const buttons = document.querySelectorAll('button'); let sendBtn = Array.from(buttons).find(btn => { const btnText = btn.textContent || ''; return btnText.includes('发送') || btnText.includes('Send') || btnText.includes('发送消息'); }); if (!sendBtn) { sendBtn = Array.from(buttons).find(btn => { const icon = btn.querySelector('svg'); if (!icon) return false; const iconPath = icon.querySelector('path') || icon.querySelector('use'); return iconPath || btn.getAttribute('type') === 'submit'; }); } if (!sendBtn) { sendBtn = Array.from(buttons).find(btn => { return btn.classList.contains('send') || btn.classList.contains('submit') || btn.getAttribute('role') === 'button' && btn.querySelector('svg'); }); } if (sendBtn) { sendBtn.click(); console.log('发送按钮已点击'); } else { console.log('未找到发送按钮'); } }, 300); } function createSidebar() { console.log('开始创建侧边栏'); const colors = getThemeColors(); const sidebar = document.createElement('div'); sidebar.id = 'ai-prompt-sidebar'; sidebar.innerHTML = `
${getAllPrompts().map(cat => `
${cat.category.startsWith('🎯') ? cat.category : '📁 ' + cat.category}
${cat.items.map(item => ``).join('')}
`).join('')}
`; document.body.appendChild(sidebar); console.log('侧边栏已创建'); const buttons = sidebar.querySelectorAll('.ai-prompt-btn'); buttons.forEach(btn => { btn.addEventListener('click', (e) => { e.stopPropagation(); if (btn.id === 'ai-prompt-settings-btn') { createSettingsPanel(); return; } const prompt = decodeURIComponent(btn.getAttribute('data-prompt')); sendPrompt(prompt); }); }); } function updateSidebarTheme() { const sidebar = document.getElementById('ai-prompt-sidebar'); if (!sidebar) return; const colors = getThemeColors(); const styleEl = sidebar.querySelector('style'); styleEl.textContent = ` #ai-prompt-sidebar { position: fixed !important; top: 50% !important; right: 0 !important; transform: translateY(-50%) !important; width: 60px !important; min-height: 220px !important; background: ${colors.sidebarBg} !important; border: 1px solid ${colors.sidebarBorder} !important; border-right: none !important; border-radius: 12px 0 0 12px !important; box-shadow: -3px 0 20px rgba(0,0,0,0.2) !important; z-index: 99999 !important; display: flex !important; flex-direction: column !important; align-items: center !important; justify-content: flex-start !important; cursor: pointer !important; transition: all 0.3s ease !important; padding: 15px 0 !important; overflow: visible !important; } #ai-prompt-sidebar:hover { width: 300px !important; min-height: auto !important; max-height: 80vh !important; overflow-y: auto !important; } #ai-prompt-logo { font-size: 28px !important; margin-bottom: 10px !important; color: ${colors.textColor} !important; writing-mode: vertical-rl !important; text-orientation: mixed !important; white-space: nowrap !important; transition: all 0.3s ease !important; } #ai-prompt-sidebar:hover #ai-prompt-logo { writing-mode: horizontal-tb !important; font-size: 18px !important; font-weight: 600 !important; margin-bottom: 15px !important; } #ai-prompt-content { display: none !important; flex-direction: column !important; gap: 15px !important; padding: 0 15px 15px 15px !important; width: 100% !important; box-sizing: border-box !important; } #ai-prompt-sidebar:hover #ai-prompt-content { display: flex !important; } .ai-prompt-category { font-size: 12px !important; font-weight: 600 !important; color: ${colors.textOpacity} !important; margin: 0 0 8px 0 !important; padding-left: 8px !important; border-left: 3px solid #667eea !important; white-space: nowrap !important; } .ai-prompt-btn-row { display: flex !important; flex-wrap: wrap !important; gap: 6px !important; } .ai-prompt-btn { padding: 8px 14px !important; background: ${colors.btnBg} !important; border: none !important; border-radius: 8px !important; color: ${colors.btnTextColor} !important; font-size: 12px !important; cursor: pointer !important; text-align: center !important; transition: all 0.2s ease !important; white-space: nowrap !important; flex-shrink: 0 !important; } .ai-prompt-btn:hover { background: ${colors.btnHoverBg} !important; transform: translateY(-2px) !important; box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important; } `; } function refreshSidebar() { const existingSidebar = document.getElementById('ai-prompt-sidebar'); if (existingSidebar) { existingSidebar.remove(); } createSidebar(); } function init() { console.log('初始化AI懒人包...'); const platform = getCurrentPlatform(); if (!platform) { console.log('当前网站不支持'); return; } if (document.body) { createSidebar(); const observer = new MutationObserver(() => { updateSidebarTheme(); }); observer.observe(document.documentElement, { attributes: true, attributeFilter: ['style', 'class'], childList: false, subtree: false }); observer.observe(document.body, { attributes: true, attributeFilter: ['style', 'class'], childList: false, subtree: false }); setInterval(updateSidebarTheme, 2000); } else { document.addEventListener('DOMContentLoaded', () => { createSidebar(); const observer = new MutationObserver(() => { updateSidebarTheme(); }); observer.observe(document.documentElement, { attributes: true, attributeFilter: ['style', 'class'], childList: false, subtree: false }); observer.observe(document.body, { attributes: true, attributeFilter: ['style', 'class'], childList: false, subtree: false }); setInterval(updateSidebarTheme, 2000); }); setTimeout(() => { if (document.body) { createSidebar(); } }, 2000); } } init(); })();