parent
ae27f94866
commit
4a789bac11
1 changed files with 6 additions and 5 deletions
|
|
@ -19,7 +19,7 @@
|
||||||
import { mzta_script } from './js/mzta-chatgpt.js';
|
import { mzta_script } from './js/mzta-chatgpt.js';
|
||||||
import { prefs_default } from './options/mzta-options-default.js';
|
import { prefs_default } from './options/mzta-options-default.js';
|
||||||
import { mzta_Menus } from './js/mzta-menus.js';
|
import { mzta_Menus } from './js/mzta-menus.js';
|
||||||
import { getCurrentIdentity } from './js/mzta-utils.js';
|
import { getCurrentIdentity, replaceBody } from './js/mzta-utils.js';
|
||||||
|
|
||||||
var createdWindowID = null;
|
var createdWindowID = null;
|
||||||
|
|
||||||
|
|
@ -62,17 +62,17 @@ messenger.runtime.onMessage.addListener(async (message, sender, sendResponse) =>
|
||||||
break;
|
break;
|
||||||
case 'chatgpt_replaceSelectedText':
|
case 'chatgpt_replaceSelectedText':
|
||||||
//console.log('chatgpt_replaceSelectedText: [' + message.tabId +'] ' + message.text)
|
//console.log('chatgpt_replaceSelectedText: [' + message.tabId +'] ' + message.text)
|
||||||
browser.tabs.sendMessage(message.tabId, { command: "replaceSelectedText", text: message.text });
|
browser.tabs.sendMessage(message.tabId, { command: "replaceSelectedText", text: message.text, tabId: message.tabId });
|
||||||
return true;
|
return true;
|
||||||
case 'chatgpt_replyMessage':
|
case 'chatgpt_replyMessage':
|
||||||
const paragraphsHtmlString = message.text;
|
const paragraphsHtmlString = message.text;
|
||||||
let prefs = await browser.storage.sync.get({reply_type: 'reply_all'});
|
let prefs = await browser.storage.sync.get({reply_type: 'reply_all'});
|
||||||
console.log('reply_type: ' + prefs.reply_type);
|
//console.log('reply_type: ' + prefs.reply_type);
|
||||||
let replyType = 'replyToAll';
|
let replyType = 'replyToAll';
|
||||||
if(prefs.reply_type === 'reply_sender'){
|
if(prefs.reply_type === 'reply_sender'){
|
||||||
replyType = 'replyToSender';
|
replyType = 'replyToSender';
|
||||||
}
|
}
|
||||||
console.log('replyType: ' + replyType);
|
//console.log('replyType: ' + replyType);
|
||||||
browser.messageDisplay.getDisplayedMessage(message.tabId).then(async (mailMessage) => {
|
browser.messageDisplay.getDisplayedMessage(message.tabId).then(async (mailMessage) => {
|
||||||
let reply_tab = await browser.compose.beginReply(mailMessage.id, replyType, {
|
let reply_tab = await browser.compose.beginReply(mailMessage.id, replyType, {
|
||||||
type: "reply",
|
type: "reply",
|
||||||
|
|
@ -100,7 +100,8 @@ messenger.runtime.onMessage.addListener(async (message, sender, sendResponse) =>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// we need to wait for the compose windows to load the content script
|
// we need to wait for the compose windows to load the content script
|
||||||
setTimeout(() => browser.tabs.sendMessage(reply_tab.id, { command: "insertText", text: paragraphsHtmlString }), 500);
|
//setTimeout(() => browser.tabs.sendMessage(reply_tab.id, { command: "insertText", text: paragraphsHtmlString, tabId: reply_tab.id }), 500);
|
||||||
|
setTimeout(() => replaceBody(reply_tab.id, paragraphsHtmlString), 500);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue