Clipboard Sanitizer
Relevant source files
The following files were used as context for generating this wiki page:
The Clipboard Sanitizer is a privacy-focused feature within the Messenger Unleashed desktop application designed to strip tracking metadata and telemetry parameters from URLs pasted into the chat interface. By intercepting paste events, the system ensures that user-shared links do not contain identifiable tracking strings typically used by social media and marketing platforms to monitor user behavior across the web.
This system operates across the Electron main process and the preload script, leveraging a combination of IPC (Inter-Process Communication) for state management and DOM event interception for real-time sanitization.
Architecture and Data Flow
The Clipboard Sanitizer utilizes a distributed architecture where the configuration is maintained in the Main process and the execution logic resides in the Preload script.
Configuration Management
The feature is controlled by a boolean flag clipboardSanitize stored via electron-store. The Main process handles the toggle logic and synchronizes this state with the renderer via IPC.
Sanitization Logic
The core logic resides in the setupClipboardSanitizer function within the preload script. It attaches a listener to the paste event on the document. When a paste occurs, the system:
- Extracts plain text from the clipboard data.
- Attempts to parse the text as a URL.
- Identifies and removes a predefined list of tracking parameters.
- Re-inserts the "clean" URL into the target input field or content-editable element.
Sources: src/preload/index.ts:503-556
Implementation Details
Tracked Parameters
The system specifically targets common marketing and social media tracking identifiers.
| Parameter | Description |
|---|---|
utm_* | Google Analytics UTM parameters (source, medium, campaign, etc.) |
fbclid | Facebook Click ID |
gclid | Google Click ID |
yclid | Yandex Click ID |
mc_eid / mc_cid | Mailchimp identifiers |
ref / ref_src | General referral source trackers |
Sources: src/preload/index.ts:512-517
DOM Interaction
The sanitizer handles two types of input targets within the Messenger interface:
- Content-Editable Elements: Uses
window.getSelection()anddocument.createTextNode()to replace the selection with the sanitized URL, then dispatches anInputEventto trigger React state updates. - Standard Inputs/Textareas: Uses
setRangeText()or string manipulation oftarget.valueto inject the sanitized link.
Sources: src/preload/index.ts:522-552
Sequence Diagram
The following diagram illustrates the interaction between the user, the DOM, and the sanitization logic.
Configuration and Control
Users can manage the Clipboard Sanitizer through multiple interface points provided by the application.
UI Entry Points
- Settings Modal: A toggle row in the Privacy tab of the settings UI.
- Application Menu: Located under
Unleashed > Privacy & Stealth > Clipboard Sanitizer. - Landing Page: Highlighted as a key privacy feature for stripping tracking metadata.
Sources: src/main/index.ts:1332-1337, src/preload/settings-modal.ts:252-257, landing-page/src/app/HomeClient.tsx:184-188
State Synchronization
When the user toggles the feature in the UI, the Main process updates the persistent store and notifies the renderer.
| Action | Source File | Logic |
|---|---|---|
| Toggle Feature | src/main/index.ts:1091 | Updates electron-store and calls pushRendererConfig. |
| Sync Config | src/main/index.ts:1145 | Sends update-config IPC message to renderer. |
| Apply Config | src/preload/index.ts:107 | Preload updates local config object. |
Sources: src/main/index.ts:1091-1096, src/main/index.ts:1145-1159, src/preload/index.ts:107-109
Conclusion
The Clipboard Sanitizer serves as a transparent privacy layer within Messenger Unleashed. By neutralizing tracking parameters at the point of entry (the paste event), it prevents the leaking of cross-platform telemetry while maintaining the functional utility of link sharing. Its deep integration with both standard HTML inputs and Messenger's specific content-editable structures ensures reliable performance across the application's evolving web-based UI.