diff --git a/html/options.html b/html/options.html
index 4b692d5..c33ce36 100644
--- a/html/options.html
+++ b/html/options.html
@@ -75,11 +75,6 @@
Styling Options
-
-
-
-
-
@@ -88,6 +83,11 @@
Styling Options
+
+
+
+
+
@@ -131,6 +132,9 @@ Data Management
+
+
+
diff --git a/js/background.js b/js/background.js
index 9ceea1f..90b2e4b 100644
--- a/js/background.js
+++ b/js/background.js
@@ -115,10 +115,11 @@ function isValidMessage(request) {
function processMessage(request, sendResponse) {
let processedMessage = request.message;
- chrome.storage.local.get(['codebook', 'mutedUsers', 'crypticPhrase'], function(result) {
+ chrome.storage.local.get(['codebook', 'mutedUsers', 'crypticPhrase', 'caseInsensitiveEncryption'], function(result) {
const codebook = result.codebook || {};
const mutedUsers = result.mutedUsers || [];
const crypticPhrase = result.crypticPhrase || '\\d ! d';
+ const caseInsensitiveEncryption = result.caseInsensitiveEncryption || false;
// Check if the message is from a muted user
const username = extractUsername(processedMessage);
@@ -130,7 +131,17 @@ function processMessage(request, sendResponse) {
if (request.action === "encrypt") {
for (const key in codebook) {
if (codebook.hasOwnProperty(key)) {
- processedMessage = processedMessage.replace(new RegExp(escapeRegExp(key), 'g'), codebook[key]);
+ const regex = caseInsensitiveEncryption
+ ? new RegExp(escapeRegExp(key), 'gi')
+ : new RegExp(escapeRegExp(key), 'g');
+ processedMessage = processedMessage.replace(regex, (match) => {
+ const replacement = codebook[key];
+ return caseInsensitiveEncryption ? replacement : (
+ match === match.toUpperCase() ? replacement.toUpperCase() :
+ match === match.toLowerCase() ? replacement.toLowerCase() :
+ replacement
+ );
+ });
}
}
// Replace default cryptic phrase with custom one
@@ -141,7 +152,16 @@ function processMessage(request, sendResponse) {
processedMessage = processedMessage.replace(new RegExp(escapeRegExp(crypticPhrase), 'g'), '\\d ! d');
for (const key in codebook) {
if (codebook.hasOwnProperty(key)) {
- processedMessage = processedMessage.replace(new RegExp(escapeRegExp(codebook[key]), 'g'), key);
+ const regex = caseInsensitiveEncryption
+ ? new RegExp(escapeRegExp(codebook[key]), 'gi')
+ : new RegExp(escapeRegExp(codebook[key]), 'g');
+ processedMessage = processedMessage.replace(regex, (match) => {
+ return caseInsensitiveEncryption ? key : (
+ match === match.toUpperCase() ? key.toUpperCase() :
+ match === match.toLowerCase() ? key.toLowerCase() :
+ key
+ );
+ });
}
}
sendResponse({ decryptedMessage: processedMessage });
diff --git a/js/discord.js b/js/discord.js
index 30c3653..e792bbb 100644
--- a/js/discord.js
+++ b/js/discord.js
@@ -34,6 +34,12 @@ CrypticChat.Discord = {
const contentElement = messageElement.querySelector('[id^="message-content-"]');
if (!contentElement) return null;
+ // Ignore repliedTextPreview
+ const repliedTextPreview = messageElement.querySelector('[class*="repliedTextPreview_"]');
+ if (repliedTextPreview) {
+ return null;
+ }
+
const originalText = contentElement.textContent.trim();
let decryptedText = originalText;
let isDecrypted = false;
diff --git a/js/options.js b/js/options.js
index 2f6115b..b32ccd5 100644
--- a/js/options.js
+++ b/js/options.js
@@ -69,6 +69,8 @@ document.addEventListener('DOMContentLoaded', function() {
document.getElementById(id).addEventListener('change', debounce(autoSave, 500));
document.getElementById(id).addEventListener('input', debounce(autoSave, 500));
});
+
+ document.getElementById('caseInsensitiveEncryption').addEventListener('change', saveOptions);
});
function debounce(func, delay) {
@@ -129,7 +131,8 @@ function saveOptions(showMessage = true) {
messageBubbleOpacity: document.getElementById('messageBubbleOpacity').value,
userColors: getUserColors(),
mutedUsers: getMutedUsers(),
- autoSend: document.getElementById('autoSend').checked
+ autoSend: document.getElementById('autoSend').checked,
+ caseInsensitiveEncryption: document.getElementById('caseInsensitiveEncryption').checked
};
chrome.storage.local.set(options, function() {
@@ -160,7 +163,8 @@ function loadOptions() {
'messageSpacing',
'crypticPhrase',
'messageBubbleColor',
- 'messageBubbleOpacity'
+ 'messageBubbleOpacity',
+ 'caseInsensitiveEncryption'
], function(items) {
document.getElementById('codebookText').value = formatCodebook(items.codebook || {});
document.getElementById('messagesToLoad').value = items.messagesToLoad || 50;
@@ -182,6 +186,7 @@ function loadOptions() {
document.getElementById('crypticPhrase').value = items.crypticPhrase || '\\d ! d';
document.getElementById('messageBubbleColor').value = items.messageBubbleColor || '#1e1e3f';
document.getElementById('messageBubbleOpacity').value = items.messageBubbleOpacity || '70';
+ document.getElementById('caseInsensitiveEncryption').checked = items.caseInsensitiveEncryption || false;
});
}