From ba4024ddbf2ee1b04f786341cefb6a4e481331c8 Mon Sep 17 00:00:00 2001 From: Mic Date: Fri, 21 Mar 2025 18:34:30 +0100 Subject: [PATCH 1/5] chatgtpweb: Include diff library in content scripts for enhanced functionality. see #109 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index fa3ce5cf..a13a85be 100644 --- a/manifest.json +++ b/manifest.json @@ -59,7 +59,7 @@ "content_scripts": [ { "matches": ["https://*.chatgpt.com/*"], - "js": ["js/tb115_segmenter/tb115_loader.js"], + "js": ["js/tb115_segmenter/tb115_loader.js","js/lib/diff.js"], "all_frames": true, "run_at": "document_start" } From 7c606bcb71a3f8d0f3b6c2221da14bd17878cccb Mon Sep 17 00:00:00 2001 From: mic Date: Sat, 22 Mar 2025 17:17:17 +0100 Subject: [PATCH 2/5] Update diff viewer to use body text as fallback for original text. see #109 --- api_webchat/messagesArea.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api_webchat/messagesArea.js b/api_webchat/messagesArea.js index c4888060..cae92c4e 100644 --- a/api_webchat/messagesArea.js +++ b/api_webchat/messagesArea.js @@ -254,7 +254,11 @@ class MessagesArea extends HTMLElement { diffvButton.textContent = 'Show differences'; diffvButton.addEventListener('click', async () => { let strippedText = fullTextHTMLAtAssignment.replace(/<\/?[^>]+(>|$)/g, ""); - this.appendDiffViewer(promptData.prompt_info?.selection_text, strippedText); + let originalText = promptData.prompt_info?.selection_text; + if((originalText == null) || (originalText == "")) { + originalText = promptData.prompt_info?.body_text; + } + this.appendDiffViewer(originalText, strippedText); }); actionButtons.appendChild(diffvButton); } From bebbfdd74cb6e75f8af838b32ef2c5fd17997301 Mon Sep 17 00:00:00 2001 From: mic Date: Sat, 22 Mar 2025 17:42:23 +0100 Subject: [PATCH 3/5] Add dark mode styles for added and removed message highlights. see #109 --- api_webchat/messagesArea.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api_webchat/messagesArea.js b/api_webchat/messagesArea.js index cae92c4e..bfc02123 100644 --- a/api_webchat/messagesArea.js +++ b/api_webchat/messagesArea.js @@ -45,7 +45,6 @@ messagesAreaStyle.textContent = ` line-height: 1.3; padding: 5px; border-radius: 10px; - } .message p{ margin: 0; @@ -95,12 +94,19 @@ messagesAreaStyle.textContent = ` background-color: #d4fcdc; display: inline; } - .removed { background-color: #fddddd; display: inline; text-decoration: line-through; } + @media (prefers-color-scheme: dark) { + .added { + background-color:rgb(0, 94, 0); + } + .removed { + background-color:rgb(90, 0, 0); + } + } `; messagesAreaTemplate.content.appendChild(messagesAreaStyle); From 23adcbf48fab00197e0c1059159b95eb7325689f Mon Sep 17 00:00:00 2001 From: mic Date: Sat, 22 Mar 2025 17:58:13 +0100 Subject: [PATCH 4/5] Add diff viewer functionality and related UI elements. work in progress. see #109 --- _locales/en/messages.json | 4 +++ js/mzta-chatgpt.js | 70 +++++++++++++++++++++++++++++++++++++-- mzta-background.js | 7 ++++ 3 files changed, 79 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index b654ddf6..c380ce14 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1214,5 +1214,9 @@ "noActiveCalendar": { "message": "No active calendar found!", "description": "" + }, + "btn_show_differences": { + "message": "Show differences", + "description": "" } } \ No newline at end of file diff --git a/js/mzta-chatgpt.js b/js/mzta-chatgpt.js index 182ae6f4..d3abe0d8 100644 --- a/js/mzta-chatgpt.js +++ b/js/mzta-chatgpt.js @@ -20,7 +20,7 @@ // Some original methods derived from https://github.com/KudoAI/chatgpt.js/blob/7eb8463cd61143fa9e1d5a8ec3c14d3c1b286e54/chatgpt.js // Using a full string to inject it in the ChatGPT page to avoid any security error -export const mzta_script = ` +//export const mzta_script = ` let force_go = false; let do_force_completion = false; let current_message = null; @@ -99,7 +99,7 @@ function chatpgt_scrollToBottom () { function addCustomDiv(prompt_action,tabId,mailMessageId) { // Create