From bc3dff856e9fc8c4094e1266f51a7eff5a0807d4 Mon Sep 17 00:00:00 2001
From: mic
Date: Tue, 2 Apr 2024 00:50:30 +0200
Subject: [PATCH] COrrectly handling the carraige returns. Fixes #9
---
js/mzta-chatgpt.js | 7 +++++--
mzta-background.js | 14 ++++++++++++--
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/js/mzta-chatgpt.js b/js/mzta-chatgpt.js
index 008a7355..a87aaa5c 100644
--- a/js/mzta-chatgpt.js
+++ b/js/mzta-chatgpt.js
@@ -35,9 +35,11 @@ async function chatgpt_getFromDOM(pos) {
strPos = pos.toString().toLowerCase();
let response = '';
if (responseDivs.length) {
- if (/last|final/.test(strPos)) // get last response
+ if (/last|final/.test(strPos)){ // get last response
+ responseDivs[responseDivs.length - 1].innerHTML = responseDivs[responseDivs.length - 1].innerHTML.replace(/<\\/p>/g, '
\\n\\n').replace(/
/g, '
\\n');
response = responseDivs[responseDivs.length - 1].textContent;
- else { // get nth response
+ //console.log('chatgpt_getFromDOM: [HTML] ' + responseDivs[responseDivs.length - 1].innerHTML.replace(/]*>/gi, '').replace(/<\\/div>/gi, '').replace(/