// ==UserScript== // @name Deepseek Privacy // @namespace https://github.com/landifrancesco/Deepseek-Privacy // @version 1 // @description Hide and replace sensitive data on the chat interface with a user-friendly UI. // @author Francesco Landi // @match https://chat.deepseek.com/a/chat/s/* // @grant GM_addStyle // @license GNU General Public License v3.0 // @downloadURL https://update.greasyfork.icu/scripts/525247/Deepseek%20Privacy.user.js // @updateURL https://update.greasyfork.icu/scripts/525247/Deepseek%20Privacy.meta.js // ==/UserScript== (function () { 'use strict'; // Load saved sensitive data from localStorage let sensitiveData = JSON.parse(localStorage.getItem('sensitiveData')) || {}; let caseSensitive = JSON.parse(localStorage.getItem('caseSensitive')) || false; // Function to replace sensitive data function replaceSensitiveData() { const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT); let node; while (node = walker.nextNode()) { // Skip if the node is within the popup if (node.parentElement.closest('#sensitiveDataPopup')) continue; let text = node.nodeValue; // Replace each sensitive word for (const [word, replacement] of Object.entries(sensitiveData)) { const regex = new RegExp(word, caseSensitive ? "g" : "gi"); // Use "g" or "gi" based on caseSensitive text = text.replace(regex, replacement); } node.nodeValue = text; } } // Function to detect the page theme function detectTheme() { const bgColor = window.getComputedStyle(document.body).backgroundColor; const rgb = bgColor.match(/\d+/g); if (rgb) { const brightness = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000; return brightness > 128 ? 'light' : 'dark'; } return 'light'; // Default to light theme if detection fails } // Function to create the lock icon and popup UI function createUI() { const theme = detectTheme(); const isDarkTheme = theme === 'dark'; // Add styles for the lock icon and popup GM_addStyle(` #sensitiveDataLock { position: fixed; top: 10px; right: 10px; z-index: 1000; cursor: pointer; font-size: 24px; color: ${isDarkTheme ? '#fff' : '#555'}; } #sensitiveDataPopup { display: none; position: fixed; top: 50px; right: 10px; z-index: 1000; background: ${isDarkTheme ? '#333' : '#fff'}; border: 1px solid ${isDarkTheme ? '#555' : '#ccc'}; padding: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); width: 300px; color: ${isDarkTheme ? '#fff' : '#000'}; } #sensitiveDataPopup input { width: 100%; margin-bottom: 10px; padding: 5px; background: ${isDarkTheme ? '#444' : '#fff'}; color: ${isDarkTheme ? '#fff' : '#000'}; border: 1px solid ${isDarkTheme ? '#555' : '#ccc'}; } #sensitiveDataPopup button { padding: 5px 10px; margin-right: 5px; background: ${isDarkTheme ? '#555' : '#eee'}; color: ${isDarkTheme ? '#fff' : '#000'}; border: 1px solid ${isDarkTheme ? '#666' : '#ccc'}; cursor: pointer; } #sensitiveDataList { max-height: 200px; overflow-y: auto; margin-bottom: 10px; } .case-sensitive-container { display: flex; align-items: center; margin-bottom: 10px; } .case-sensitive-container label { margin-left: 5px; } `); // Create the lock icon const lockIcon = document.createElement('div'); lockIcon.id = 'sensitiveDataLock'; lockIcon.innerHTML = '🔒'; document.body.appendChild(lockIcon); // Create the popup const popup = document.createElement('div'); popup.id = 'sensitiveDataPopup'; popup.innerHTML = `