diff --git a/CHANGELOG.md b/CHANGELOG.md index 55a94444..57ddee8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@
tags with a newline at the beginning + // and removes all other HTML tags + return htmlString + .replace(/
/gi, '') // removes
tags + .replace(/<\/p>/gi, '\n') // replaces
tags with newline + .replace(/<[^>]*>/g, '') // removes any other HTML tags + .trim(); // removes leading/trailing whitespace +} + // This method is used to convert the model string id used in the URL // to the model string used in the webpage export function getGPTWebModelString(model) { diff --git a/mzta-background.js b/mzta-background.js index aaeaa2fc..7cff4363 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -20,7 +20,7 @@ import { mzta_script } from './js/mzta-chatgpt.js'; import { prefs_default } from './options/mzta-options-default.js'; import { mzta_Menus } from './js/mzta-menus.js'; import { taLogger } from './js/mzta-logger.js'; -import { getCurrentIdentity, getOriginalBody, replaceBody, setBody, i18nConditionalGet, generateCallID, migrateCustomPromptsStorage, migrateDefaultPromptsPropStorage, getGPTWebModelString, getTagsList, createTag, assignTagsToMessage, checkIfTagExists, getActiveSpecialPromptsIDs, checkSparksPresence, getMessages, getMailBody, extractJsonObject, contextMenuID_AddTags, contextMenuID_Spamfilter } from './js/mzta-utils.js'; +import { getCurrentIdentity, getOriginalBody, replaceBody, setBody, i18nConditionalGet, generateCallID, migrateCustomPromptsStorage, migrateDefaultPromptsPropStorage, getGPTWebModelString, getTagsList, createTag, assignTagsToMessage, checkIfTagExists, getActiveSpecialPromptsIDs, checkSparksPresence, getMessages, getMailBody, extractJsonObject, contextMenuID_AddTags, contextMenuID_Spamfilter, stripHtmlKeepLines } from './js/mzta-utils.js'; import { taPromptUtils } from './js/mzta-utils-prompt.js'; import { mzta_specialCommand } from './js/mzta-special-commands.js'; import { getSpamFilterPrompt } from './js/mzta-prompts.js'; @@ -194,15 +194,22 @@ messenger.runtime.onMessage.addListener((message, sender, sendResponse) => { async function _replaceSelectedText(tabId, text) { //console.log('chatgpt_replaceSelectedText: [' + tabId +'] ' + text) original_html = await getOriginalBody(tabId); + let prefs_repl = await browser.storage.sync.get({composing_plain_text: prefs_default.composing_plain_text}); + if(prefs_repl.composing_plain_text){ + text = stripHtmlKeepLines(text); + } await browser.tabs.sendMessage(tabId, { command: "replaceSelectedText", text: text, tabId: tabId }); return true; } return _replaceSelectedText(message.tabId, message.text); case 'chatgpt_replyMessage': async function _replyMessage(message) { - const paragraphsHtmlString = message.text; + let paragraphsHtmlString = message.text; //console.log(">>>>>>>>>>>> paragraphsHtmlString: " + paragraphsHtmlString); - let prefs = await browser.storage.sync.get({reply_type: 'reply_all'}); + let prefs = await browser.storage.sync.get({reply_type: prefs_default.reply_type, composing_plain_text: prefs_default.composing_plain_text}); + if(prefs.composing_plain_text){ + paragraphsHtmlString = stripHtmlKeepLines(paragraphsHtmlString); + } //console.log('reply_type: ' + prefs.reply_type); let replyType = 'replyToAll'; if(prefs.reply_type === 'reply_sender'){ diff --git a/options/mzta-options-default.js b/options/mzta-options-default.js index 47cb2314..7db33787 100644 --- a/options/mzta-options-default.js +++ b/options/mzta-options-default.js @@ -22,6 +22,7 @@ export const prefs_default = { chatgpt_win_width: 700, default_chatgpt_lang: '', default_sign_name: '', + composing_plain_text: false, connection_type: 'chatgpt_web', //Other values: 'chatgpt_api', 'ollama_api', 'openai_comp_api', 'google_gemini_api' chatgpt_web_model: '', chatgpt_web_tempchat: false, diff --git a/options/mzta-options.html b/options/mzta-options.html index 9083d20c..2cb1636a 100644 --- a/options/mzta-options.html +++ b/options/mzta-options.html @@ -101,6 +101,17 @@ +