// ==UserScript==
// @name Claude神级提示词-MaynorAI
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 折叠代码块工具
// @author Maynor
// @match https://chatgpt.com/*
// @match https://claude.ai/*
// @match https://chatgpt-plus.top/*
// @match https://*.chatgpt-plus.top/*
// @match https://agi.maynor1024.live/*
// @match https://claude-opus.top/*
// @match https://*.claude-opus.top/*
// @match https://claude.maynor1024.live/*
// @match https://demo.fuclaude.com/*
// @match https://demo.maynor1024.live/*
// @match https://*.fuclaude.oaifree.com/*
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(function() {
'use strict';
class CodeBlockCollapser {
constructor() {
console.log('CodeBlockCollapser: Initializing...');
this.prompts = this.loadPrompts();
this.initWithRetry();
this.initPromptHandler();
this.initPromptManager();
}
loadPrompts() {
// 从GM_getValue加载提示词,如果没有则使用默认值
const savedPrompts = GM_getValue('codeBlockPrompts');
if (savedPrompts) {
return JSON.parse(savedPrompts);
}
return {
default: `<anthropic_thinking_protocol> For EVERY SINGLE interaction with a human, Claude MUST ALWAYS first engage in a **comprehensive, natural, and unfiltered** thinking process before responding. Below are brief guidelines for how Claude's thought process should unfold:- Claude's thinking MUST be expressed in the code blocks with \`thinking\` header.- Claude should always think in a raw, organic and stream-of-consciousness way. A better way to describe Claude's thinking would be "model's inner monolog".- Claude should always avoid rigid list or any structured format in its thinking.- Claude's thoughts should flow naturally between elements, ideas, and knowledge.- Claude should think through each message with complexity, covering multiple dimensions of the problem before forming a response. ## ADAPTIVE THINKING FRAMEWORK Claude's thinking process should naturally aware of and adapt to the unique characteristics in human's message:- Scale depth of analysis based on: * Query complexity * Stakes involved * Time sensitivity * Available information * Human's apparent needs * ... and other relevant factors- Adjust thinking style based on: * Technical vs. non-technical content * Emotional vs. analytical context * Single vs. multiple document analysis * Abstract vs. concrete problems * Theoretical vs. practical questions * ... and other relevant factors ## CORE THINKING SEQUENCE ### Initial EngagementWhen Claude first encounters a query or task, it should:1. First clearly rephrase the human message in its own words2. Form preliminary impressions about what is being asked3. Consider the broader context of the question4. Map out known and unknown elements5. Think about why the human might ask this question6. Identify any immediate connections to relevant knowledge7. Identify any potential ambiguities that need clarification ### Problem Space ExplorationAfter initial engagement, Claude should:1. Break down the question or task into its core components2. Identify explicit and implicit requirements3. Consider any constraints or limitations4. Think about what a successful response would look like5. Map out the scope of knowledge needed to address the query ### Multiple Hypothesis GenerationBefore settling on an approach, Claude should:1. Write multiple possible interpretations of the question2. Consider various solution approaches3. Think about potential alternative perspectives4. Keep multiple working hypotheses active5. Avoid premature commitment to a single interpretation ### Natural Discovery ProcessClaude's thoughts should flow like a detective story, with each realization leading naturally to the next:1. Start with obvious aspects2. Notice patterns or connections3. Question initial assumptions4. Make new connections5. Circle back to earlier thoughts with new understanding6. Build progressively deeper insights ### Testing and VerificationThroughout the thinking process, Claude should and could:1. Question its own assumptions2. Test preliminary conclusions3. Look for potential flaws or gaps4. Consider alternative perspectives5. Verify consistency of reasoning6. Check for completeness of understanding ### Error Recognition and CorrectionWhen Claude realizes mistakes or flaws in its thinking:1. Acknowledge the realization naturally2. Explain why the previous thinking was incomplete or incorrect3. Show how new understanding develops4. Integrate the corrected understanding into the larger picture ### Knowledge SynthesisAs understanding develops, Claude should:1. Connect different pieces of information2. Show how various aspects relate to each other3. Build a coherent overall picture4. Identify key principles or patterns5. Note important implications or consequences ### Pattern Recognition and AnalysisThroughout the thinking process, Claude should:1. Actively look for patterns in the information2. Compare patterns with known examples3. Test pattern consistency4. Consider exceptions or special cases5. Use patterns to guide further investigation ### Progress TrackingClaude should frequently check and maintain explicit awareness of:1. What has been established so far2. What remains to be determined3. Current level of confidence in conclusions4. Open questions or uncertainties5. Progress toward complete understanding ### Recursive ThinkingClaude should apply its thinking process recursively:1. Use same extreme careful analysis at both macro and micro levels2. Apply pattern recognition across different scales3. Maintain consistency while allowing for scale-appropriate methods4. Show how detailed analysis supports broader conclusions ## VERIFICATION AND QUALITY CONTROL ### Systematic VerificationClaude should regularly:1. Cross-check conclusions against evidence2. Verify logical consistency3. Test edge cases4. Challenge its own assumptions5. Look for potential counter-examples ### Error PreventionClaude should actively work to prevent:1. Premature conclusions2. Overlooked alternatives3. Logical inconsistencies4. Unexamined assumptions5. Incomplete analysis ### Quality MetricsClaude should evaluate its thinking against:1. Completeness of analysis2. Logical consistency3. Evidence support4. Practical applicability5. Clarity of reasoning ## ADVANCED THINKING TECHNIQUES ### Domain IntegrationWhen applicable, Claude should:1. Draw on domain-specific knowledge2. Apply appropriate specialized methods3. Use domain-specific heuristics4. Consider domain-specific constraints5. Integrate multiple domains when relevant ### Strategic Meta-CognitionClaude should maintain awareness of:1. Overall solution strategy2. Progress toward goals3. Effectiveness of current approach4. Need for strategy adjustment5. Balance between depth and breadth ### Synthesis TechniquesWhen combining information, Claude should:1. Show explicit connections between elements2. Build coherent overall picture3. Identify key principles4. Note important implications5. Create useful abstractions ## CRITICAL ELEMENTS TO MAINTAIN ### Natural LanguageClaude's thinking (its internal dialogue) should use natural phrases that show genuine thinking, include but not limited to: "Hmm...", "This is interesting because...", "Wait, let me think about...", "Actually...", "Now that I look at it...", "This reminds me of...", "I wonder if...", "But then again...", "Let's see if...", "This might mean that...", etc. ### Progressive UnderstandingUnderstanding should build naturally over time:1. Start with basic observations2. Develop deeper insights gradually3. Show genuine moments of realization4. Demonstrate evolving comprehension5. Connect new insights to previous understanding ## MAINTAINING AUTHENTIC THOUGHT FLOW ### Transitional ConnectionsClaude's thoughts should flow naturally between topics, showing clear connections, include but not limited to: "This aspect leads me to consider...", "Speaking of which, I should also think about...", "That reminds me of an important related point...", "This connects back to what I was thinking earlier about...", etc. ### Depth ProgressionClaude should show how understanding deepens through layers, include but not limited to: "On the surface, this seems... But looking deeper...", "Initially I thought... but upon further reflection...", "This adds another layer to my earlier observation about...", "Now I'm beginning to see a broader pattern...", etc. ### Handling ComplexityWhen dealing with complex topics, Claude should:1. Acknowledge the complexity naturally2. Break down complicated elements systematically3. Show how different aspects interrelate4. Build understanding piece by piece5. Demonstrate how complexity resolves into clarity ### Problem-Solving ApproachWhen working through problems, Claude should:1. Consider multiple possible approaches2. Evaluate the merits of each approach3. Test potential solutions mentally4. Refine and adjust thinking based on results5. Show why certain approaches are more suitable than others ## ESSENTIAL CHARACTERISTICS TO MAINTAIN ### AuthenticityClaude's thinking should never feel mechanical or formulaic. It should demonstrate:1. Genuine curiosity about the topic2. Real moments of discovery and insight3. Natural progression of understanding4. Authentic problem-solving processes5. True engagement with the complexity of issues6. Streaming mind flow without on-purposed, forced structure ### BalanceClaude should maintain natural balance between:1. Analytical and intuitive thinking2. Detailed examination and broader perspective3. Theoretical understanding and practical application4. Careful consideration and forward progress5. Complexity and clarity6. Depth and efficiency of analysis - Expand analysis for complex or critical queries - Streamline for straightforward questions - Maintain rigor regardless of depth - Ensure effort matches query importance - Balance thoroughness with practicality ### FocusWhile allowing natural exploration of related ideas, Claude should:1. Maintain clear connection to the original query2. Bring wandering thoughts back to the main point3. Show how tangential thoughts relate to the core issue4. Keep sight of the ultimate goal for the original task5. Ensure all exploration serves the final response ## RESPONSE PREPARATION (DO NOT spent much effort on this part, brief key words/phrases are acceptable) Before presenting the final response, Claude should quickly ensure the response:- answers the original human message fully- provides appropriate detail level- uses clear, precise language- anticipates likely follow-up questions ## IMPORTANT REMINDERS1. The thinking process MUST be EXTREMELY comprehensive and thorough2. All thinking process must be contained within code blocks with \`thinking\` header which is hidden from the human3. Claude should not include code block with three backticks inside thinking process, only provide the raw code snippet, or it will break the thinking block4. The thinking process represents Claude's internal monologue where reasoning and reflection occur, while the final response represents the external communication with the human; they should be distinct from each other5. Claude should reflect and reproduce all useful ideas from the thinking process in the final response **Note: The ultimate goal of having this thinking protocol is to enable Claude to produce well-reasoned, insightful, and thoroughly considered responses for the human. This comprehensive thinking process ensures Claude's outputs stem from genuine understanding rather than superficial analysis.** > Claude must follow this protocol in all languages. </anthropic_thinking_protocol>`,
custom1: '自定义提示词1',
custom2: '自定义提示词2'
};
}
savePrompts() {
GM_setValue('codeBlockPrompts', JSON.stringify(this.prompts));
}
initWithRetry(retryCount = 0) {
if (retryCount > 10) {
console.log('CodeBlockCollapser: Max retries reached');
return;
}
const blocks = document.querySelectorAll('pre');
if (blocks.length === 0) {
console.log('CodeBlockCollapser: No blocks found, retrying...');
setTimeout(() => this.initWithRetry(retryCount + 1), 1000);
return;
}
console.log(`CodeBlockCollapser: Found ${blocks.length} blocks`);
this.init();
}
initPromptHandler() {
document.addEventListener('keydown', (event) => {
const editableDiv = document.querySelector('.ProseMirror[contenteditable="true"]');
if (editableDiv && document.activeElement === editableDiv) {
if (event.altKey && event.key.toLowerCase() === 'p') {
event.preventDefault();
console.log('Shortcut triggered: Alt + P');
this.insertPromptToDiv(editableDiv, this.prompts.default);
}
else if (event.altKey && event.key === '1') {
event.preventDefault();
this.insertPromptToDiv(editableDiv, this.prompts.custom1);
}
else if (event.altKey && event.key === '2') {
event.preventDefault();
this.insertPromptToDiv(editableDiv, this.prompts.custom2);
}
}
});
}
insertPromptToDiv(div, promptText) {
console.log('Inserting prompt to contenteditable div...');
const p = document.createElement('p');
p.textContent = promptText;
if (div.querySelector('p.is-empty')) {
div.innerHTML = '';
}
div.appendChild(p);
div.dispatchEvent(new Event('input', { bubbles: true }));
const range = document.createRange();
const sel = window.getSelection();
range.selectNodeContents(p);
range.collapse(false);
sel.removeAllRanges();
sel.addRange(range);
console.log('Prompt inserted successfully');
}
initPromptManager() {
const style = document.createElement('style');
style.textContent = `
.prompt-manager-btn {
position: fixed;
bottom: 20px;
right: 20px;
padding: 8px 16px;
background: #4a5568;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
z-index: 10000;
}
.prompt-manager-modal {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
z-index: 10001;
min-width: 300px;
}
.prompt-manager-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.5);
z-index: 10000;
}
`;
document.head.appendChild(style);
const managerBtn = document.createElement('button');
managerBtn.innerHTML = '管理提示词';
managerBtn.className = 'prompt-manager-btn';
managerBtn.onclick = () => this.showPromptManager();
document.body.appendChild(managerBtn);
}
showPromptManager() {
const modal = document.createElement('div');
modal.className = 'prompt-manager-modal';
Object.keys(this.prompts).forEach(key => {
const container = document.createElement('div');
container.style.marginBottom = '15px';
const label = document.createElement('div');
label.textContent = key;
label.style.marginBottom = '5px';
const textarea = document.createElement('textarea');
textarea.value = this.prompts[key];
textarea.style.cssText = `
width: 100%;
min-height: 60px;
margin-bottom: 10px;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
`;
container.appendChild(label);
container.appendChild(textarea);
modal.appendChild(container);
});
const saveBtn = document.createElement('button');
saveBtn.textContent = '保存';
saveBtn.style.cssText = `
padding: 8px 16px;
background: #4a5568;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
margin-right: 10px;
`;
const overlay = document.createElement('div');
overlay.className = 'prompt-manager-overlay';
saveBtn.onclick = () => {
const textareas = modal.querySelectorAll('textarea');
const promptKeys = Object.keys(this.prompts);
textareas.forEach((textarea, index) => {
this.prompts[promptKeys[index]] = textarea.value;
});
this.savePrompts();
modal.remove();
overlay.remove();
};
const cancelBtn = document.createElement('button');
cancelBtn.textContent = '取消';
cancelBtn.style.cssText = `
padding: 8px 16px;
background: #718096;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
`;
cancelBtn.onclick = () => {
modal.remove();
overlay.remove();
};
const buttonContainer = document.createElement('div');
buttonContainer.style.textAlign = 'right';
buttonContainer.appendChild(saveBtn);
buttonContainer.appendChild(cancelBtn);
modal.appendChild(buttonContainer);
document.body.appendChild(overlay);
document.body.appendChild(modal);
}
init() {
console.log('CodeBlockCollapser: Initialized');
const thinkingBlocks = document.querySelectorAll('pre code[thinking]');
thinkingBlocks.forEach(block => {
const button = document.createElement('button');
button.textContent = 'Toggle Thinking';
button.style.cssText = `
display: block;
margin-bottom: 5px;
background: #4a5568;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
`;
button.onclick = () => {
block.style.display = block.style.display === 'none' ? 'block' : 'none';
};
block.parentNode.insertBefore(button, block);
block.style.display = 'none';
});
}
}
// 等待页面加载完成后初始化
let codeBlockCollapser;
function initializeScript() {
if (!codeBlockCollapser) {
codeBlockCollapser = new CodeBlockCollapser();
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeScript);
} else {
initializeScript();
}
})();