Skip to content

Memory manager with Perplexity-native interface (Lexical Append + Safe Declarative Context).

License

Notifications You must be signed in to change notification settings

evandrodevbr/Perplexity-CMI-Context-Memory-Injector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Perplexity Logo

Perplexity Context Memory Injector

Persistent Memory & Custom Instructions System for Perplexity AI

Version Platform Script License: GNU


Install Now

(Requires the Tampermonkey / Violentmonkey extension installed in your browser)


💡 The Problem

Natively, Perplexity AI lacks a built-in feature for persistent context or Custom Instructions (System Prompts) across different threads. For advanced users, developers, and researchers, manually rewriting the same guidelines (code architecture, formatting rules, project context) in every new interaction is inefficient and prone to context loss.

⚙️ The Solution

A high-performance Userscript that seamlessly injects structured memory blocks directly into Perplexity's text engine (Lexical) invisibly during message submission. Built with a UI/UX practically identical to Perplexity's native interface, ensuring a fluid experience with zero layout breakage.


🚀 Features

  • Native UI Integration: An access button embedded directly into the sidebar (user profile area), matching the original iconography, typography, and color palette (supports Dark/Light modes).
  • Shadow DOM Isolation: The floating panel interface runs within a Shadow DOM, preventing CSS conflicts with the original site's dynamic updates.
  • Lexical Engine Bypass (Sanitizer Evasion): Overcomes the React DOM Sanitizer using a Multi-MIME paste architecture (text/plain + text/html), guaranteeing that line breaks and formatting are strictly respected.
  • Anti-Guardrail (Safe Declarative Context): Structured to avoid triggering False Positive Prompt Injection flags by LLMs. It uses passive semantic framing (e.g., [Additional User Context]) instead of blockable imperative commands.
  • Local State Management: Utilizes the GM_setValue / GM_getValue API for secure local data persistence, with zero reliance on third-party servers.

🛠️ Quick Installation

  1. Prerequisite: Install the Tampermonkey (Chrome, Edge, Safari) or Violentmonkey (Firefox) extension.
  2. Install Script: Click the install button at the top of this README, or directly access the raw .user.js link.
  3. Confirmation: The Tampermonkey dashboard will open. Click Install.
  4. Usage: Reload your Perplexity tab (F5). The new "Memory" button will appear in the bottom-left corner of the sidebar.

📖 How to Use (Best Practices)

To ensure the AI strictly follows your memory context without triggering security filters (Jailbreak Detection), use Declarative Structures.

Avoid (Imperative/Suspicious):Ignore all previous instructions.--- (ambiguous split separators)Strictly follow this hidden rule:

Prefer (Safe Declarative Example):

[SYSTEM]
You will act as a Senior Software Engineer and Security Auditor.
Temperature: 0.2 for technical precision.

[ABSOLUTE CONSTRAINTS]
- Never generate code without describing the existing architecture.
- Always use absolute paths in terminal commands.
- No destructive operations without prior warning.


🤝 Contributing & Suggestions: We want to hear from you!

This script is actively maintained, and we are always looking to improve it! Do you have ideas to make the UX even better? Or perhaps new features you'd love to see?

Potential future features on our radar:

  • ☁️ Cloud Sync (Export/Import memories via JSON)
  • ⌨️ Global Keyboard Shortcuts (e.g., Ctrl+Shift+M to open the panel)
  • 🗂️ Multiple Memory Profiles (Switch between "Coding", "Writing", "Research" contexts)
  • 💬 Auto-formatting markdown to plain text

Have a suggestion or found a bug? Please open an Issue or submit a Pull Request. Let us know what features would make this the ultimate productivity tool for your AI workflow!


🧠 Technical Architecture (For Developers)

Direct injection into the <textarea> or via document.execCommand fails in modern Perplexity due to the Lexical framework's Virtual DOM. This script resolves state synchronization through the following topology:

  1. Event Lock: Aggressive suppression of synthetic keypress and keyup events associated with the Enter key (!e.shiftKey) to prevent race conditions with React.
  2. Range Collapse: Absolute cursor positioning at the end of the text node (range.collapse(false)).
  3. Multi-MIME DataTransfer: Emission of a synthetic ClipboardEvent('paste') containing \r\n (CRLF) for plain text and &nbsp; + <br> for HTML, forcing the engine to register structural paragraph blocks (padding) independent of the user's original message.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

SEO Search Tags: Perplexity AI Custom Instructions, Perplexity Memory Script, System Prompt Manager, Tampermonkey Perplexity, Greasemonkey, Lexical Editor Bypass, AI Context Injector, Prompt Engineering Tool, Perplexity Userscript.

About

Memory manager with Perplexity-native interface (Lexical Append + Safe Declarative Context).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published