Merge pull request #364 from micz/chatgpt_web_custom_gpt_project
Chatgpt web custom gpt project
This commit is contained in:
commit
557e9060b4
16 changed files with 669 additions and 121 deletions
|
|
@ -14,6 +14,7 @@
|
|||
<li>Added the <i>{%empty%}</i> placeholder to prevent the email body from being automatically appended at the end of the prompt [<a href="https://github.com/micz/ThunderAI/issues/345">#345</a>].</li>
|
||||
<li>Added a check for the presence of the correct version of ThunderAI Sparks [<a href="https://github.com/micz/ThunderAI/issues/315">#315</a>].</li>
|
||||
<li><i>[All APIs]</i> Improved the form asking for additional text [<a href="https://github.com/micz/ThunderAI/issues/97">#97</a>].</li>
|
||||
<li>Custom Prompts form improved.</li>
|
||||
<li>Various improvements.</li>
|
||||
<li>...</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -607,6 +607,10 @@
|
|||
"message": "In case of login issues in the ThunderAI window, open ChatGPT in a new tab using the button on the right, log in, then close the tab and continue using ThunderAI.",
|
||||
"description": ""
|
||||
},
|
||||
"OpenChatGPTTab_Info2": {
|
||||
"message": "Opening ChatGPT Web from here will apply any configured settings for the model, project, and Custom GPT.",
|
||||
"description": ""
|
||||
},
|
||||
"placeholder_mail_text_body": {
|
||||
"message": "Mail body",
|
||||
"description": ""
|
||||
|
|
@ -672,11 +676,11 @@
|
|||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_chatgpt_web_model": {
|
||||
"message": "ChatGPT Web model",
|
||||
"message": "ChatGPT Web Model",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_chatgpt_web_model_info": {
|
||||
"message": "This is the model that will be enforced for the ChatGPT Web Interface. If none is specified or an incorrect one is provided, the default model will be set by ChatGPT on the webpage.",
|
||||
"message": "This is the Model that will be enforced for the ChatGPT Web Interface. If none is specified or an incorrect one is provided, the default model will be set by ChatGPT on the webpage.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_chatgpt_web_tempchat": {
|
||||
|
|
@ -1386,5 +1390,53 @@
|
|||
"AccountSelector_Spamfilter": {
|
||||
"message": "Choose the accounts where the spam filter is enabled",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_chatgpt_web_project": {
|
||||
"message": "ChatGPT Web Project",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_chatgpt_web_project_info": {
|
||||
"message": "This is the Project that will be enforced for the ChatGPT Web Interface.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_chatgpt_web_custom_gpt": {
|
||||
"message": "ChatGPT Web Custom GPT",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_chatgpt_web_custom_gpt_info": {
|
||||
"message": "This is the Custom GPT that will be enforced for the ChatGPT Web Interface.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_chatgpt_web_custom_data_info": {
|
||||
"message": "This must be in the following form:",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_chatgpt_web_custom_data_info2": {
|
||||
"message": "You can find the correct value in the browser URL field when you open the related ChatGPT page.",
|
||||
"description": ""
|
||||
},
|
||||
"customPrompts_Properties": {
|
||||
"message": "Properties",
|
||||
"description": ""
|
||||
},
|
||||
"customPrompts_show_additional_info": {
|
||||
"message": "Show additional properties",
|
||||
"description": ""
|
||||
},
|
||||
"customPrompts_hide_additional_info": {
|
||||
"message": "Hide additional properties",
|
||||
"description": ""
|
||||
},
|
||||
"customPrompts_show_additional_info_show": {
|
||||
"message": "Additional properties",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_CustomGPT_Warn": {
|
||||
"message": "If a Project is specified in the options or in a prompt, it will override the Custom GPT setting.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_Project_No_temporary_chat_warn": {
|
||||
"message": "If a Project is specified in the options or in a prompt, the temporary chat will not be used.",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -310,9 +310,9 @@ class MessageInput extends HTMLElement {
|
|||
this._customTextArea.focus();
|
||||
}
|
||||
|
||||
async _customTextBtnClick(args) { console.log('>>>>>>>>> this in _customTextBtnClick:', this);
|
||||
async _customTextBtnClick(args) {
|
||||
const customText = this._customTextArea.value;
|
||||
console.log(">>>>>>>>>>>>>>>> customText: " + customText);
|
||||
// console.log(">>>>>>>>>>>>>>>> customText: " + customText);
|
||||
args.customBtn.disabled = true;
|
||||
args.customBtn.classList.add('disabled');
|
||||
args.customLoading.style.display = 'inline-block';
|
||||
|
|
|
|||
|
|
@ -83,8 +83,16 @@ async function chatgpt_isIdle() {
|
|||
|
||||
function chatgpt_getRegenerateButton() {
|
||||
for (const mainSVG of document.querySelectorAll('main svg.icon-md')) {
|
||||
if (mainSVG.querySelector('path[d^="M3.06957"]')) // regen icon found
|
||||
if (mainSVG.querySelector('path[d^="M3.06957"]')){ // regen icon found
|
||||
//console.log(">>>>>>>>>> found regen icon!");
|
||||
return mainSVG.parentNode.parentNode;
|
||||
}
|
||||
}
|
||||
for (const mainSVG of document.querySelectorAll('main svg.icon-md-heavy')) {
|
||||
if (mainSVG.querySelector('path[d^="M11 4.9099C11 4.47485"]')){ // read aloud icon found
|
||||
//console.log(">>>>>>>>>> found read aloud icon!");
|
||||
return mainSVG.parentNode.parentNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -317,13 +325,15 @@ function customTextBtnClick(args) {
|
|||
}
|
||||
|
||||
function checkGPTModel(model) {
|
||||
if(model == '') return;
|
||||
if(model == '') return Promise.resolve();
|
||||
doLog("checkGPTModel model: " + model);
|
||||
return new Promise((resolve, reject) => {
|
||||
// Set up an interval that shows the warning after 2 seconds
|
||||
const intervalId2 = setTimeout(() => {
|
||||
document.getElementById('mzta-model_warn').style.display = 'inline-block';
|
||||
document.getElementById('mzta-btn_model').style.display = 'inline';
|
||||
let modelWarn = document.getElementById('mzta-model_warn');
|
||||
let btnModel = document.getElementById('mzta-btn_model');
|
||||
if (modelWarn) modelWarn.style.display = 'inline-block';
|
||||
if (btnModel) btnModel.style.display = 'inline';
|
||||
}, 2000);
|
||||
// Set up an interval that checks the value every 100 milliseconds
|
||||
const intervalId = setInterval(() => {
|
||||
|
|
@ -331,15 +341,13 @@ function checkGPTModel(model) {
|
|||
// const element = document.querySelector('div#radix-\\\\:ri2\\\\: > div > span.text-token-text-secondary');
|
||||
const elements = document.querySelectorAll('[id*=radix] span')
|
||||
|
||||
for(element of elements){
|
||||
for(let element of elements){
|
||||
// Check if the element exists and its content is '4' or '4o'
|
||||
doLog("checkGPTModel model found in DOM: " + element.textContent);
|
||||
if ((element && element.textContent === model)||(force_go)) {
|
||||
doLog("The GPT Model is now " + model);
|
||||
clearInterval(intervalId);
|
||||
clearTimeout(intervalId2);
|
||||
document.getElementById('mzta-model_warn').style.display = 'none';
|
||||
document.getElementById('mzta-btn_model').style.display = 'none';
|
||||
resolve(model);
|
||||
break;
|
||||
} else if (!element) {
|
||||
|
|
@ -388,7 +396,7 @@ async function doProceed(message, customText = ''){
|
|||
// console.log(">>>>>>>>>>>> doProceed customText: " + customText);
|
||||
// console.log(">>>>>>>>>>>> doProceed final_prompt: " + final_prompt);
|
||||
// console.log(">>>>>>>>>>>> doProceed mztaPhDefVal: " + JSON.stringify(mztaPhDefVal));
|
||||
//check if there is che additional_text placeholder
|
||||
//check if there is the additional_text placeholder
|
||||
if(final_prompt.includes('{%additional_text%}')){
|
||||
// console.log(">>>>>>>>>>>> found ph customText: " + customText);
|
||||
final_prompt = final_prompt.replace('{%additional_text%}', customText || (mztaPhDefVal == '1'?'':'{%additional_text%}'));
|
||||
|
|
@ -408,14 +416,7 @@ async function doProceed(message, customText = ''){
|
|||
break;
|
||||
case -2: // textarea not found
|
||||
let curr_model_warn = document.getElementById('mzta-model_warn');
|
||||
let message = browser.i18n.getMessage("chatgpt_textarea_not_found_error");
|
||||
let parts = message.split(/<a href="([^"]+)">([^<]+)<\\/a>/);
|
||||
curr_model_warn.textContent = parts[0];
|
||||
let link = document.createElement('a');
|
||||
link.href = parts[1];
|
||||
link.textContent = parts[2];
|
||||
curr_model_warn.appendChild(link);
|
||||
curr_model_warn.appendChild(document.createTextNode(parts[3]));
|
||||
curr_model_warn.textContent = browser.i18n.getMessage("chatgpt_textarea_not_found_error");
|
||||
curr_model_warn.style.display = 'inline-block';
|
||||
document.getElementById('mzta-curr_msg').textContent = "";
|
||||
document.getElementById('mzta-loading').style.display = 'none';
|
||||
|
|
@ -437,6 +438,10 @@ async function doProceed(message, customText = ''){
|
|||
}
|
||||
|
||||
function doRetry(){
|
||||
document.getElementById('mzta-model_warn').style.display = 'none';
|
||||
document.getElementById('mzta-btn_retry').remove();
|
||||
document.getElementById('mzta-loading').style.display = 'inline-block';
|
||||
document.getElementById('mzta-curr_msg').textContent = browser.i18n.getMessage("chatgpt_win_working");
|
||||
doProceed(current_message);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,15 @@
|
|||
Position Compose Message (position_compose attribute):
|
||||
<num>: position number
|
||||
|
||||
ChatGPT Web Model (chatgpt_web_model attribute):
|
||||
<model>: model name (e.g. gpt-4, gpt-3.5-turbo, etc.)
|
||||
|
||||
ChatGPT Web Project (chatgpt_web_project attribute):
|
||||
<project>: project id url
|
||||
|
||||
ChatGPT Web Custom GPT (chatgpt_web_custom_gpt attribute):
|
||||
<custom_gpt>: custom gpt id url
|
||||
|
||||
*/
|
||||
|
||||
const defaultPrompts = [
|
||||
|
|
@ -77,6 +86,9 @@ const defaultPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "1",
|
||||
use_diff_viewer: "0",
|
||||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -91,6 +103,9 @@ const defaultPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "1",
|
||||
use_diff_viewer: "0",
|
||||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -105,6 +120,9 @@ const defaultPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "1",
|
||||
use_diff_viewer: "1",
|
||||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -119,6 +137,9 @@ const defaultPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "1",
|
||||
use_diff_viewer: "1",
|
||||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -133,6 +154,9 @@ const defaultPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "1",
|
||||
use_diff_viewer: "0",
|
||||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -147,6 +171,9 @@ const defaultPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "1",
|
||||
use_diff_viewer: "0",
|
||||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -161,6 +188,9 @@ const defaultPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "1",
|
||||
use_diff_viewer: "1",
|
||||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -175,6 +205,9 @@ const defaultPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "0",
|
||||
use_diff_viewer: "0",
|
||||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -189,6 +222,9 @@ const defaultPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "0",
|
||||
use_diff_viewer: "0",
|
||||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -371,6 +407,15 @@ async function getCustomPrompts() {
|
|||
if (prompt.use_diff_viewer === undefined) {
|
||||
prompt.use_diff_viewer = "0";
|
||||
}
|
||||
if(prompt.chatgpt_web_model === undefined){
|
||||
prompt.chatgpt_web_model = "";
|
||||
}
|
||||
if(prompt.chatgpt_web_project === undefined){
|
||||
prompt.chatgpt_web_project = "";
|
||||
}
|
||||
if(prompt.chatgpt_web_custom_gpt === undefined){
|
||||
prompt.chatgpt_web_custom_gpt = "";
|
||||
}
|
||||
});
|
||||
return prefs._custom_prompt;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -411,6 +411,24 @@ export async function checkSparksPresence() {
|
|||
}
|
||||
}
|
||||
|
||||
export function validateChatGPTWebCustomData(data) {
|
||||
return /^\/g\/[a-zA-Z0-9/-]+$/.test(data) || data == '';
|
||||
}
|
||||
|
||||
export function sanitizeChatGPTModelData(input) {
|
||||
return encodeURIComponent(input).toLowerCase()
|
||||
}
|
||||
|
||||
export function sanitizeChatGPTWebCustomData(input) {
|
||||
// Removes all characters that are not letters, numbers, dashes, or slashes
|
||||
return input.replace(/[^\p{L}\p{N}\/-]+/gu, '');
|
||||
}
|
||||
|
||||
export function validateCustomData_ChatGPTWeb(event) {
|
||||
let is_valid = validateChatGPTWebCustomData(event.target.value);
|
||||
event.target.style.borderColor = is_valid ? 'green' : 'red';
|
||||
document.getElementById(event.target.id + '_info').style.color = is_valid ? '' : 'red';
|
||||
}
|
||||
|
||||
// The following methods are a modified version derived from https://github.com/ali-raheem/Aify/blob/13ff87583bc520fb80f555ab90a90c5c9df797a7/plugin/content_scripts/compose.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, sanitizeChatGPTModelData, sanitizeChatGPTWebCustomData } 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';
|
||||
|
|
@ -317,6 +317,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
taLog.changeDebug(prefs.do_debug);
|
||||
prefs = checkScreenDimensions(prefs);
|
||||
//console.log(">>>>>>>>>>>>>>>> prefs: " + JSON.stringify(prefs));
|
||||
console.log(">>>>>>>>>>>>>>>> prompt_info: " + JSON.stringify(prompt_info));
|
||||
taLog.log("Prompt length: " + promptText.length);
|
||||
if(promptText.length > prefs.max_prompt_length){
|
||||
// Prompt too long for ChatGPT
|
||||
|
|
@ -334,18 +335,40 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
let rand_call_id = '_chatgptweb_' + generateCallID();
|
||||
let call_opt = '';
|
||||
|
||||
let _wait_time = 1000;
|
||||
let _base_url = "https://chatgpt.com";
|
||||
let _webproject_set = false;
|
||||
let _custom_gpt_set = false;
|
||||
let _use_prompt_info_custom_gpt = false;
|
||||
let _custom_model = sanitizeChatGPTModelData(prompt_info.chatgpt_web_model != '' ? prompt_info.chatgpt_web_model : prefs.chatgpt_web_model);
|
||||
let _web_project = sanitizeChatGPTWebCustomData(prompt_info.chatgpt_web_project != '' ? prompt_info.chatgpt_web_project : prefs.chatgpt_web_project)
|
||||
let _custom_gpt = sanitizeChatGPTWebCustomData(prompt_info.chatgpt_web_custom_gpt != '' ? prompt_info.chatgpt_web_custom_gpt : prefs.chatgpt_web_custom_gpt)
|
||||
|
||||
if(prefs.chatgpt_web_tempchat){
|
||||
call_opt += '&temporary-chat=true';
|
||||
}
|
||||
|
||||
if(prefs.chatgpt_web_model != ''){
|
||||
call_opt += '&model=' + encodeURIComponent(prefs.chatgpt_web_model).toLowerCase();
|
||||
if((prompt_info.chatgpt_web_model != '') || (prefs.chatgpt_web_model != '')){
|
||||
call_opt += '&model=' + _custom_model;
|
||||
}
|
||||
|
||||
taLog.log("[chatgpt_web] call_opt: " + call_opt);
|
||||
|
||||
// If there is a custom gpt on the prompt, but also a web_project on the prefs, we need to use the custom gpt
|
||||
_use_prompt_info_custom_gpt = (prompt_info.chatgpt_web_custom_gpt != '' && prompt_info.chatgpt_web_project == '');
|
||||
|
||||
if(!_use_prompt_info_custom_gpt && ((prompt_info.chatgpt_web_project != '') || (prefs.chatgpt_web_project != ''))){
|
||||
_base_url += _web_project;
|
||||
_webproject_set = true;
|
||||
_wait_time = 2000;
|
||||
}
|
||||
if(!_webproject_set && ((prompt_info.chatgpt_web_custom_gpt != '') || (prefs.chatgpt_web_custom_gpt != ''))){
|
||||
_base_url += _custom_gpt;
|
||||
_custom_gpt_set = true;
|
||||
}
|
||||
|
||||
let win_options = {
|
||||
url: "https://chatgpt.com?call_id=" + rand_call_id + call_opt,
|
||||
url: _base_url + "?call_id=" + rand_call_id + call_opt,
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
@ -360,9 +383,9 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
async function handleChatGptWeb(createdTab) {
|
||||
taLog.log("ChatGPT web interface script started...");
|
||||
|
||||
let _gpt_model = getGPTWebModelString(prefs.chatgpt_web_model);
|
||||
let _gpt_model = getGPTWebModelString(_custom_model);
|
||||
|
||||
taLog.log("prefs.chatgpt_web_model: " + prefs.chatgpt_web_model);
|
||||
taLog.log("_custom_model: " + _custom_model);
|
||||
taLog.log("_gpt_model: " + _gpt_model);
|
||||
|
||||
let originalText = prompt_info.selection_text;
|
||||
|
|
@ -377,15 +400,15 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
let mztaDoCustomText=`+ do_custom_text +`;
|
||||
let mztaPromptName="[`+ i18nConditionalGet(prompt_name) +`]";
|
||||
let mztaPhDefVal="`+(prefs.placeholders_use_default_value?'1':'0')+`";
|
||||
let mztaGPTModel="`+ _gpt_model +`";
|
||||
let mztaGPTModel="`+ (_custom_gpt_set ? '' : _gpt_model) +`";
|
||||
let mztaDoDebug="`+(prefs.do_debug?'1':'0')+`";
|
||||
let mztaUseDiffViewer="`+(prompt_info.use_diff_viewer=='1'?'1':'0')+`";
|
||||
let mztaOriginalText="`+ JSON.stringify(originalText).slice(1, -1) +`";
|
||||
`;
|
||||
|
||||
taLog.log("Waiting 1 sec");
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
taLog.log("Waiting 1 sec done");
|
||||
taLog.log("Waiting " + _wait_time + " millisec");
|
||||
await new Promise(resolve => setTimeout(resolve, _wait_time));
|
||||
taLog.log("Waiting " + _wait_time + " millisec done");
|
||||
|
||||
await browser.tabs.executeScript(createdTab.id, { code: pre_script + mzta_script, matchAboutBlank: false });
|
||||
// let mailMessage = await browser.messageDisplay.getDisplayedMessage(curr_tabId);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ export const prefs_default = {
|
|||
connection_type: 'chatgpt_web', //Other values: 'chatgpt_api', 'ollama_api', 'openai_comp_api', 'google_gemini_api'
|
||||
chatgpt_web_model: '',
|
||||
chatgpt_web_tempchat: false,
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
chatgpt_api_key: '',
|
||||
chatgpt_model: '',
|
||||
chatgpt_developer_messages: '',
|
||||
|
|
|
|||
|
|
@ -74,6 +74,10 @@ span.dims_label{
|
|||
display: inline-block;
|
||||
}
|
||||
|
||||
span.opt_title{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#btn_custom_prompts{
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<td colspan="2" style="text-align:center;" class="warning"><b>__MSG_hyprland_warning__</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span>__MSG_prefs_OptionText_chatgpt_win_text__</span>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_chatgpt_win_text__</span>
|
||||
<td>
|
||||
<label>
|
||||
<span class="dims_label">__MSG_prefs_OptionText_chatgpt_win_height__</span>
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OptionText_default_sign_name__</span>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_default_sign_name__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OptionText_default_chatgpt_lang__</span>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_default_chatgpt_lang__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<span>__MSG_prefs_OptionText_reply_type__</span>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_reply_type__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OptionText_dynamic_menu_order_alphabet__</span>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_dynamic_menu_order_alphabet__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -81,7 +81,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OptionText_dynamic_menu_force_enter__</span>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_dynamic_menu_force_enter__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -92,7 +92,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OptionText_placeholders_use_default_value__</span>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_placeholders_use_default_value__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<span>__MSG_prefs_Connection_type__</span>
|
||||
<span class="opt_title">__MSG_prefs_Connection_type__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
|
|
@ -122,7 +122,7 @@
|
|||
<tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OptionText_chatgpt_web_model__</span>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_chatgpt_web_model__</span>
|
||||
<br><table title="__MSG_prefs_OptionText_chatgpt_web_model_tooltip__"><tr><td><i class="small_info"><nobr>__MSG_AllowedValues__:</nobr></i></td><td><i class="small_info"> <nobr class="conntype_chatgpt_web_option">gpt-4o</nobr> <nobr class="conntype_chatgpt_web_option">gpt-4o-mini</nobr> <nobr class="conntype_chatgpt_web_option">gpt-4</nobr> <nobr class="conntype_chatgpt_web_option">o1</nobr> <nobr class="conntype_chatgpt_web_option">o3-mini</nobr> <nobr class="conntype_chatgpt_web_option">o3-mini-high</nobr></i></td></tr></table>
|
||||
</label></td>
|
||||
<td>
|
||||
|
|
@ -134,26 +134,53 @@
|
|||
</tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OptionText_chatgpt_web_tempchat__</span>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_chatgpt_web_project__</span>
|
||||
<br><i class="small_info" id="chatgpt_web_project_info">__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ <b>/g/PROJECT-ID-PROJECT-NAME/project</b>
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__</i>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="chatgpt_web_tempchat" name="chatgpt_web_tempchat" class="option-input" />
|
||||
<span>__MSG_prefs_OptionText_chatgpt_web_tempchat_info__</span>
|
||||
<input type="text" id="chatgpt_web_project" name="chatgpt_web_project" class="option-input" />
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_project_info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td><label>
|
||||
<span>__MSG_OpenChatGPTTab_Info__</span>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_chatgpt_web_custom_gpt__</span>
|
||||
<br><i class="small_info" id="chatgpt_web_custom_gpt_info">__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ <b>/g/CUSTOM-GPT-ID</b>
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__</i>
|
||||
</label></td>
|
||||
<td>
|
||||
<button id="btnChatGPTWeb_Tab">__MSG_OpenChatGPTTab__</button>
|
||||
<label>
|
||||
<input type="text" id="chatgpt_web_custom_gpt" name="chatgpt_web_custom_gpt" class="option-input" />
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_custom_gpt_info__
|
||||
<br>__MSG_prefs_OptionText_CustomGPT_Warn__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_chatgpt_web_tempchat__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="chatgpt_web_tempchat" name="chatgpt_web_tempchat" class="option-input" />
|
||||
<span>__MSG_prefs_OptionText_chatgpt_web_tempchat_info__
|
||||
<br>__MSG_prefs_OptionText_Project_No_temporary_chat_warn__
|
||||
</span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td colspan="2" style="padding:0px 2em;text-align:center;"><span>__MSG_OpenChatGPTTab_Info__</span>
|
||||
<br><br><button id="btnChatGPTWeb_Tab">__MSG_OpenChatGPTTab__</button>
|
||||
<br><br>__MSG_OpenChatGPTTab_Info2__
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_api">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_ChatGPT_API_Key__</span>
|
||||
<span class="opt_title">__MSG_prefs_ChatGPT_API_Key__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<div class="api_key-container">
|
||||
|
|
@ -167,7 +194,7 @@
|
|||
<tr class="conntype_chatgpt_api">
|
||||
<td>
|
||||
<label>
|
||||
<span>__MSG_ChatGPT_Models__</span>
|
||||
<span class="opt_title">__MSG_ChatGPT_Models__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
|
|
@ -181,7 +208,7 @@
|
|||
<tr class="conntype_chatgpt_api">
|
||||
<td>
|
||||
<label>
|
||||
<span>__MSG_ChatGPT_Developer_Messages__</span>
|
||||
<span class="opt_title">__MSG_ChatGPT_Developer_Messages__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
|
|
@ -193,7 +220,7 @@
|
|||
</tr>
|
||||
<tr class="conntype_google_gemini_api">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_GoogleGemini_API_Key__</span>
|
||||
<span class="opt_title">__MSG_prefs_GoogleGemini_API_Key__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<div class="api_key-container">
|
||||
|
|
@ -207,7 +234,7 @@
|
|||
<tr class="conntype_google_gemini_api">
|
||||
<td>
|
||||
<label>
|
||||
<span>__MSG_GoogleGemini_Models__</span>
|
||||
<span class="opt_title">__MSG_GoogleGemini_Models__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
|
|
@ -221,7 +248,7 @@
|
|||
<tr class="conntype_google_gemini_api">
|
||||
<td>
|
||||
<label>
|
||||
<span>__MSG_GoogleGemini_SystemInstruction__</span>
|
||||
<span class="opt_title">__MSG_GoogleGemini_SystemInstruction__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
|
|
@ -233,7 +260,7 @@
|
|||
</tr>
|
||||
<tr class="conntype_ollama_api">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_API_Host__</span>
|
||||
<span class="opt_title">__MSG_prefs_API_Host__</span>
|
||||
<br><i class="small_info">__MSG_prefs_API_Host_Info__ http://127.0.0.1:11434</i>
|
||||
</label></td>
|
||||
<td>
|
||||
|
|
@ -253,7 +280,7 @@
|
|||
<tr class="conntype_ollama_api">
|
||||
<td>
|
||||
<label>
|
||||
<span>__MSG_Ollama_Models__</span>
|
||||
<span class="opt_title">__MSG_Ollama_Models__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
|
|
@ -266,7 +293,7 @@
|
|||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_API_Host__</span>
|
||||
<span class="opt_title">__MSG_prefs_API_Host__</span>
|
||||
<br><i class="small_info">__MSG_prefs_API_Host_Info__ http://localhost:1234</i>
|
||||
</label></td>
|
||||
<td>
|
||||
|
|
@ -286,7 +313,7 @@
|
|||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OptionText_openai_comp_use_v1__</span>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_openai_comp_use_v1__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -297,7 +324,7 @@
|
|||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OpenAIComp_API_Key__</span>
|
||||
<span class="opt_title">__MSG_prefs_OpenAIComp_API_Key__</span>
|
||||
<br><i class="small_info">__MSG_Optional__</i>
|
||||
</label></td>
|
||||
<td>
|
||||
|
|
@ -312,7 +339,7 @@
|
|||
<tr class="conntype_openai_comp_api">
|
||||
<td>
|
||||
<label>
|
||||
<span>__MSG_OpenAIComp_Models__</span>
|
||||
<span class="opt_title">__MSG_OpenAIComp_Models__</span>
|
||||
<br><button id="btnOpenAICompForceModel" class="btn_small">__MSG_prefs_OpenAIComp_ForceModel__</button></td>
|
||||
</label>
|
||||
</td>
|
||||
|
|
@ -326,7 +353,7 @@
|
|||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OpenAIComp_ChatName__</span>
|
||||
<span class="opt_title">__MSG_prefs_OpenAIComp_ChatName__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -336,7 +363,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr id="max_prompt_length_tr">
|
||||
<td><span>__MSG_prefs_OptionText_max_prompt_length__</span></td>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_max_prompt_length__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="number" id="max_prompt_length" name="max_prompt_length" class="option-input" />
|
||||
|
|
@ -345,7 +372,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="add_tags_tr">
|
||||
<td><span>__MSG_prefs_OptionText_add_tags__</span>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags__</span>
|
||||
<br><button id="btnManageTagsInfo" class="btn_small">__MSG_prefs_OptionText_btnManageTagsInfo__</button></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -355,7 +382,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="spamfilter_tr">
|
||||
<td><span>__MSG_prefs_OptionText_spamfilter__</span>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_spamfilter__</span>
|
||||
<br><button id="btnManageSpamFilterInfo" class="btn_small">__MSG_prefs_OptionText_btnManageSpamFilterInfo__</button></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -365,7 +392,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="get_calendar_event_tr">
|
||||
<td><span>__MSG_prefs_OptionText_get_calendar_event__</span>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_get_calendar_event__</span>
|
||||
<br><button id="btnManageCalendarEventInfo" class="btn_small">__MSG_prefs_OptionText_btnManageCalendarEventInfo__</button></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -375,7 +402,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="get_task_tr">
|
||||
<td><span>__MSG_prefs_OptionText_get_task__</span>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_get_task__</span>
|
||||
<br><button id="btnManageTaskInfo" class="btn_small">__MSG_prefs_OptionText_btnManageTaskInfo__</button></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -393,7 +420,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td style="width:20em"><label>
|
||||
<span>__MSG_Debug__</span>
|
||||
<span class="opt_title">__MSG_Debug__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import { OpenAI } from '../js/api/openai.js';
|
|||
import { Ollama } from '../js/api/ollama.js';
|
||||
import { OpenAIComp } from '../js/api/openai_comp.js'
|
||||
import { GoogleGemini } from '../js/api/google_gemini.js';
|
||||
import { checkSparksPresence, isThunderbird128OrGreater, openTab } from '../js/mzta-utils.js';
|
||||
import { checkSparksPresence, isThunderbird128OrGreater, openTab, sanitizeChatGPTModelData, sanitizeChatGPTWebCustomData, validateCustomData_ChatGPTWeb } from '../js/mzta-utils.js';
|
||||
|
||||
let taLog = new taLogger("mzta-options",true);
|
||||
let _isThunderbird128OrGreater = true;
|
||||
|
|
@ -298,16 +298,22 @@ function disable_SpamFilter(){
|
|||
|
||||
async function disable_GetCalendarEvent(){
|
||||
let get_calendar_event = document.getElementById('get_calendar_event');
|
||||
let get_task = document.getElementById('get_task');
|
||||
let no_sparks_tr = document.getElementById('no_sparks');
|
||||
let no_sparks_text = document.getElementById('no_sparks_text');
|
||||
let wrong_sparks_text = document.getElementById('wrong_sparks_text');
|
||||
let is_spark_present = await checkSparksPresence();
|
||||
let conntype_select = document.getElementById("connection_type");
|
||||
get_calendar_event.disabled = (conntype_select.value === "chatgpt_web") || !(is_spark_present == 1);
|
||||
get_task.disabled = (conntype_select.value === "chatgpt_web") || !(is_spark_present == 1);
|
||||
let get_calendar_event_tr_elements = document.querySelectorAll('.get_calendar_event_tr');
|
||||
get_calendar_event_tr_elements.forEach(get_calendar_event_tr => {
|
||||
get_calendar_event_tr.style.display = get_calendar_event.disabled ? 'none' : 'table-row';
|
||||
});
|
||||
let get_task_tr_elements = document.querySelectorAll('.get_task_tr');
|
||||
get_task_tr_elements.forEach(get_task_tr => {
|
||||
get_task_tr.style.display = get_task.disabled ? 'none' : 'table-row';
|
||||
});
|
||||
no_sparks_tr.style.display = ((is_spark_present == 1) || (conntype_select.value === "chatgpt_web")) ? 'none' : 'table-row';
|
||||
no_sparks_text.style.display = (is_spark_present == -1) ? 'inline' : 'none';
|
||||
wrong_sparks_text.style.display = (is_spark_present == 0) ? 'inline' : 'none';
|
||||
|
|
@ -448,6 +454,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
document.getElementById("ollama_host").addEventListener("change", warn_Ollama_HostEmpty);
|
||||
document.getElementById("openai_comp_host").addEventListener("change", warn_OpenAIComp_HostEmpty);
|
||||
document.getElementById("google_gemini_api_key").addEventListener("change", warn_GoogleGemini_APIKeyEmpty);
|
||||
document.getElementById("chatgpt_web_project").addEventListener("input", validateCustomData_ChatGPTWeb);
|
||||
document.getElementById("chatgpt_web_custom_gpt").addEventListener("input", validateCustomData_ChatGPTWeb);
|
||||
|
||||
let prefs = await browser.storage.sync.get({chatgpt_model: '', ollama_model: '', openai_comp_model: '', google_gemini_model: '', chatgpt_win_height: 0, chatgpt_win_width: 0 });
|
||||
|
||||
|
|
@ -673,8 +681,24 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
});
|
||||
|
||||
const btnChatGPTWeb_Tab = document.getElementById('btnChatGPTWeb_Tab');
|
||||
btnChatGPTWeb_Tab.addEventListener('click', () => {
|
||||
browser.tabs.create({ url: 'https://chatgpt.com/' });
|
||||
btnChatGPTWeb_Tab.addEventListener('click', async () => {
|
||||
let prefs_mod = await browser.storage.sync.get({chatgpt_web_model: prefs_default.chatgpt_web_model, chatgpt_web_project: prefs_default.chatgpt_web_project, chatgpt_web_custom_gpt: prefs_default.chatgpt_web_custom_gpt});
|
||||
|
||||
let base_url = 'https://chatgpt.com';
|
||||
let model_opt = '';
|
||||
let webproject_set = false;
|
||||
|
||||
if((prefs_mod.chatgpt_web_model != '') && (prefs_mod.chatgpt_web_model != undefined)){
|
||||
model_opt = '?model=' + sanitizeChatGPTModelData(prefs_mod.chatgpt_web_model);
|
||||
}
|
||||
if((prefs_mod.chatgpt_web_project != '') && (prefs_mod.chatgpt_web_project != undefined)){
|
||||
base_url += sanitizeChatGPTWebCustomData(prefs_mod.chatgpt_web_project);
|
||||
webproject_set = true;
|
||||
}
|
||||
if(!webproject_set && (prefs_mod.chatgpt_web_custom_gpt != '') && (prefs_mod.chatgpt_web_custom_gpt != undefined)){
|
||||
base_url += sanitizeChatGPTWebCustomData(prefs_mod.chatgpt_web_custom_gpt);
|
||||
}
|
||||
browser.tabs.create({ url: base_url + model_opt });
|
||||
});
|
||||
|
||||
browser.runtime.getPlatformInfo().then(info => {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
<li>Added a check for the presence of the correct version of ThunderAI Sparks [<a href="https://github.com/micz/ThunderAI/issues/315">#315</a>].</li>
|
||||
<li>Added the <i>{%empty%}</i> placeholder to prevent the email body from being automatically appended at the end of the prompt [<a href="https://github.com/micz/ThunderAI/issues/345">#345</a>].</li>
|
||||
<li><i>[All APIs]</i> Improved the form asking for additional text [<a href="https://github.com/micz/ThunderAI/issues/97">#97</a>].</li>
|
||||
<li>Custom Prompts form improved.</li>
|
||||
<li>Various improvements.</li>
|
||||
<li>...</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ table {
|
|||
thead {
|
||||
position: sticky;
|
||||
top: 26px;
|
||||
z-index: 90;
|
||||
}
|
||||
|
||||
#command_palette{
|
||||
|
|
@ -33,6 +34,7 @@ thead {
|
|||
padding-top: 1px;
|
||||
height: 26px;
|
||||
width: 100%;
|
||||
z-index: 90;
|
||||
}
|
||||
|
||||
#btnNew{
|
||||
|
|
@ -102,6 +104,10 @@ table .sort.desc {
|
|||
background-image: url(../images/listjs-arrow-sort-active-up.png);
|
||||
}
|
||||
|
||||
tbody.list tr{
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.hiddendata{
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -135,6 +141,24 @@ table .sort.desc {
|
|||
font-style: italic;
|
||||
}
|
||||
|
||||
.field_title{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.field_title_s{
|
||||
font-weight: bold;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
.field_title_us{
|
||||
font-weight: bold;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
label, .id_show, .text_show, .name_show, .type_show, .action_show{
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
#txtIdNew, .id_output{
|
||||
text-transform: lowercase;
|
||||
}
|
||||
|
|
@ -204,6 +228,67 @@ table .sort.desc {
|
|||
padding-right: 2px;
|
||||
}
|
||||
|
||||
#chatgpt_web_additional_info_toggle td{
|
||||
padding:0px 5px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#chatgpt_web_additional_info, #chatgpt_web_additional_info_toggle, .chatgpt_web_additional_info, .chatgpt_web_additional_info_toggle, .chatgpt_web_additional_info_show{
|
||||
background-color: rgb(255, 209, 183);
|
||||
display:none;
|
||||
}
|
||||
|
||||
#chatgpt_web_additional_info_toggle, .chatgpt_web_additional_info_toggle{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#chatgpt_web_additional_info_toggle:hover, .chatgpt_web_additional_info_toggle:hover{
|
||||
background-color: rgb(255, 189, 153);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#chatgpt_web_additional_info_toggle td{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#chatgpt_web_additional_info td{
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.chatgpt_web_additional_info_toggle{
|
||||
width: -moz-available;
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.chatgpt_web_additional_info_show{
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
height: 100%;
|
||||
padding: 3px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.chatgpt_web_additional_info_row{
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.chatgpt_web_additional_info_row span{
|
||||
margin-right: 0.4em;
|
||||
}
|
||||
|
||||
input.input_additional[type="text"]{
|
||||
width: -moz-available;
|
||||
}
|
||||
|
||||
.small_info{
|
||||
font-size:smaller;
|
||||
}
|
||||
|
||||
.conntype_chatgpt_web_option{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body {
|
||||
background-color: #1C1B22;
|
||||
|
|
@ -250,4 +335,12 @@ table .sort.desc {
|
|||
.autocomplete-list li.active {
|
||||
background-color: #4c4e58;
|
||||
}
|
||||
|
||||
#chatgpt_web_additional_info{
|
||||
background-color: rgb(39, 11, 0);
|
||||
}
|
||||
|
||||
#chatgpt_web_additional_info, #chatgpt_web_additional_info_toggle, .chatgpt_web_additional_info, .chatgpt_web_additional_info_toggle, .chatgpt_web_additional_info_show{
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
|
|
@ -27,29 +27,39 @@
|
|||
<table class="width_all">
|
||||
<tr>
|
||||
<td class="w19">
|
||||
<label for="txtIdNew">*__MSG_customPrompts_form_label_ID__:</label>
|
||||
<label for="txtIdNew" class="field_title">*__MSG_customPrompts_form_label_ID__:</label>
|
||||
<br>
|
||||
<input type="text" id="txtIdNew" name="id" class="input_new" tabindex="1">
|
||||
<br><span class="small_label">[__MSG_customPrompts_form_label_ID_rules__]</span>
|
||||
</td>
|
||||
<td rowspan="2" class="w25">
|
||||
<label for="txtTextNew">*__MSG_customPrompts_form_label_Text__:</label>
|
||||
<label for="txtTextNew" class="field_title">*__MSG_customPrompts_form_label_Text__:</label>
|
||||
<br>
|
||||
<div class="autocomplete-container">
|
||||
<textarea id="txtTextNew" name="text" class="input_new text_output editor" tabindex="3"></textarea>
|
||||
<ul class="autocomplete-list hidden"></ul>
|
||||
</div>
|
||||
</td>
|
||||
<td class="w19">
|
||||
<label for="selectTypeNew">__MSG_customPrompts_add_to_menu__:</label>
|
||||
<td rowspan="2" class="w19">
|
||||
<label for="selectTypeNew" class="field_title">__MSG_customPrompts_add_to_menu__:</label>
|
||||
<br>
|
||||
<select id="selectTypeNew" name="type" tabindex="4" class="type_output">
|
||||
<option value="0">__MSG_customPrompts_add_to_menu_always__</option>
|
||||
<option value="1">__MSG_customPrompts_add_to_menu_reading__</option>
|
||||
<option value="2">__MSG_customPrompts_add_to_menu_composing__</option>
|
||||
</select>
|
||||
<br><br>
|
||||
<label for="selectActionNew" class="field_title">__MSG_customPrompts_form_label_Action__:</label>
|
||||
<br>
|
||||
<select id="selectActionNew" name="action" tabindex="5">
|
||||
<option value="0">__MSG_customPrompts_close_button__</option>
|
||||
<option value="1">__MSG_customPrompts_do_reply__</option>
|
||||
<option value="2">__MSG_customPrompts_substitute_text__</option>
|
||||
</select>
|
||||
</td>
|
||||
<td rowspan="2" class="w19">
|
||||
<label class="field_title">__MSG_customPrompts_Properties__:</label>
|
||||
<br>
|
||||
<span class="need_selected_span"><input type="checkbox" id="checkboxNeedSelectedNew" name="need_selected" class="need_selected_new" value="1" tabindex="6"> <label for="checkboxNeedSelectedNew">__MSG_customPrompts_form_label_need_selected__</label></span>
|
||||
<br>
|
||||
<input type="checkbox" id="checkboxNeedSignatureNew" name="need_signature" value="1" tabindex="7"> <label for="checkboxNeedSignatureNew">__MSG_customPrompts_form_label_need_signature__</label>
|
||||
|
|
@ -63,18 +73,31 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="w19">
|
||||
<label for="txtNameNew">*__MSG_customPrompts_form_label_Name__:</label>
|
||||
<label for="txtNameNew" class="field_title">*__MSG_customPrompts_form_label_Name__:</label>
|
||||
<br>
|
||||
<input type="text" id="txtNameNew" name="name" class="input_new" tabindex="2">
|
||||
</td>
|
||||
<td class="w19">
|
||||
<label for="selectActionNew">__MSG_customPrompts_form_label_Action__:</label>
|
||||
<br>
|
||||
<select id="selectActionNew" name="action" tabindex="5">
|
||||
<option value="0">__MSG_customPrompts_close_button__</option>
|
||||
<option value="1">__MSG_customPrompts_do_reply__</option>
|
||||
<option value="2">__MSG_customPrompts_substitute_text__</option>
|
||||
</select>
|
||||
</tr>
|
||||
<tr id="chatgpt_web_additional_info_toggle"><td colspan="4"><span class="small_info">__MSG_customPrompts_show_additional_info__</span></td></tr>
|
||||
<tr id="chatgpt_web_additional_info"><!-- ChatGPT Web additional info -->
|
||||
<td colspan="2">
|
||||
<label for="chatGPTWebModelNew" class="field_title">__MSG_prefs_OptionText_chatgpt_web_model__:</label>
|
||||
<br>
|
||||
<input type="text" id="chatGPTWebModelNew" name="chatGPTWebModelNew" class="input_new input_additional" tabindex="10">
|
||||
<table title="__MSG_prefs_OptionText_chatgpt_web_model_tooltip__"><tr id="chatgpt_web_models_list">TODO</tr></table>
|
||||
<br><br>
|
||||
<label for="chatGPTWebProjectNew" class="field_title">__MSG_prefs_OptionText_chatgpt_web_project__:</label>
|
||||
<br>
|
||||
<input type="text" id="chatGPTWebProjectNew" name="chatGPTWebProjectNew" class="input_new input_additional" tabindex="11">
|
||||
<br><i class="small_info" id="chatGPTWebProjectNew_info">__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ <b>/g/PROJECT-ID-PROJECT-NAME/project</b>
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__</i>
|
||||
</td>
|
||||
<td colspan="2">
|
||||
<label for="chatGPTWebCustomGPTNew" class="field_title">__MSG_prefs_OptionText_chatgpt_web_custom_gpt__:</label>
|
||||
<br>
|
||||
<input type="text" id="chatGPTWebCustomGPTNew" name="chatGPTWebCustomGPTNew" class="input_new input_additional" tabindex="11">
|
||||
<br><i class="small_info" id="chatGPTWebCustomGPTNew_info">__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ <b>/g/CUSTOM-GPT-ID</b>
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__</i>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
@ -89,8 +112,8 @@
|
|||
<th class="sort" data-sort="id">__MSG_customPrompts_form_label_ID__</th>
|
||||
<th class="sort" data-sort="name">__MSG_customPrompts_form_label_Name__</th>
|
||||
<th class="sort" data-sort="text">__MSG_customPrompts_form_label_Text__</th>
|
||||
<th class="sort" data-sort="type">__MSG_customPrompts_add_to_menu__</th>
|
||||
<th>Properties</th>
|
||||
<th> </th>
|
||||
<th>__MSG_customPrompts_Properties__</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
|||
|
|
@ -16,12 +16,14 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { prefs_default } from "../../options/mzta-options-default.js";
|
||||
import { getPrompts, setDefaultPromptsProperties, setCustomPrompts, preparePromptsForExport, preparePromptsForImport } from "../../js/mzta-prompts.js";
|
||||
import { isThunderbird128OrGreater, getCustomPromptsUsedSpace, sanitizeHtml } from "../../js/mzta-utils.js";
|
||||
import { isThunderbird128OrGreater, getCustomPromptsUsedSpace, sanitizeHtml, validateCustomData_ChatGPTWeb } from "../../js/mzta-utils.js";
|
||||
import { taLogger } from "../../js/mzta-logger.js";
|
||||
import { getPlaceholders } from "../../js/mzta-placeholders.js";
|
||||
import { textareaAutocomplete } from "../../js/mzta-placeholders-autocomplete.js";
|
||||
|
||||
let prefs = null;
|
||||
var promptsList = null;
|
||||
var somethingChanged = false;
|
||||
var positionMax_compose = 0;
|
||||
|
|
@ -33,8 +35,8 @@ let autocompleteSuggestions = [];
|
|||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
|
||||
let prefs_debug = await browser.storage.sync.get({do_debug: false});
|
||||
taLog = new taLogger("mzta-custom-prompts", prefs_debug.do_debug);
|
||||
prefs = await browser.storage.sync.get({ connection_type:prefs_default.connection_type, do_debug: prefs_default.do_debug });
|
||||
taLog = new taLogger("mzta-custom-prompts", prefs.do_debug);
|
||||
|
||||
setStorageSpace();
|
||||
|
||||
|
|
@ -98,22 +100,68 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
});
|
||||
});
|
||||
|
||||
// document.addEventListener('click', (e) => {
|
||||
// // Check if the click was outside the textarea or suggestion list
|
||||
// const isClickInsideTextarea = e.target.closest('.editor');
|
||||
// const isClickInsideAutocompleteList = e.target.closest('.autocomplete-list');
|
||||
|
||||
// if (!isClickInsideTextarea && !isClickInsideAutocompleteList) {
|
||||
// textareas.forEach(textarea => {
|
||||
// const container = textarea.closest('.autocomplete-container');
|
||||
// const autocompleteList = container.querySelector('.autocomplete-list');
|
||||
// hideSuggestions(autocompleteList);
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
i18n.updateDocument();
|
||||
|
||||
switch(prefs.connection_type) {
|
||||
case 'chatgpt_web': {
|
||||
// for the new item form
|
||||
document.getElementById('chatgpt_web_additional_info_toggle').style.display = 'table-row';
|
||||
// for the edit list items form
|
||||
document.querySelectorAll('.chatgpt_web_additional_info_toggle').forEach(element => {
|
||||
element.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
let additionalInfoRow = e.target.closest('td').querySelector('.chatgpt_web_additional_info');
|
||||
if (additionalInfoRow.style.display === 'none' || additionalInfoRow.style.display === '') {
|
||||
additionalInfoRow.style.display = 'block';
|
||||
e.target.innerText = browser.i18n.getMessage('customPrompts_hide_additional_info');
|
||||
} else {
|
||||
additionalInfoRow.style.display = 'none';
|
||||
e.target.innerText = browser.i18n.getMessage('customPrompts_show_additional_info');
|
||||
}
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('input.chatgpt_web_project_output').forEach(element => {
|
||||
element.addEventListener("input", validateCustomData_ChatGPTWeb);
|
||||
});
|
||||
document.querySelectorAll('input.chatgpt_web_custom_gpt_output').forEach(element => {
|
||||
element.addEventListener("input", validateCustomData_ChatGPTWeb);
|
||||
});
|
||||
break;
|
||||
}
|
||||
// case 'chatgpt_api':
|
||||
// document.getElementById('chatgpt_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'ollama_api':
|
||||
// document.getElementById('ollama_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'openai_comp_api':
|
||||
// document.getElementById('openai_comp_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'google_gemini_api':
|
||||
// document.getElementById('google_gemini_api').style.display = 'block';
|
||||
// break;
|
||||
}
|
||||
|
||||
const chatgptWebAdditionalPropToggle = document.getElementById('chatgpt_web_additional_info_toggle');
|
||||
chatgptWebAdditionalPropToggle.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const additionalInfoRow = document.getElementById('chatgpt_web_additional_info');
|
||||
if (additionalInfoRow.style.display === 'none' || additionalInfoRow.style.display === '') {
|
||||
additionalInfoRow.style.display = 'table-row';
|
||||
let subspan = chatgptWebAdditionalPropToggle.querySelector('td span');
|
||||
if (subspan) {
|
||||
subspan.innerText = browser.i18n.getMessage('customPrompts_hide_additional_info');
|
||||
}
|
||||
} else {
|
||||
additionalInfoRow.style.display = 'none';
|
||||
let subspan = chatgptWebAdditionalPropToggle.querySelector('td span');
|
||||
if (subspan) {
|
||||
subspan.innerText = browser.i18n.getMessage('customPrompts_show_additional_info');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//To add a new item
|
||||
var txtIdNew = document.getElementById('txtIdNew');
|
||||
var txtNameNew = document.getElementById('txtNameNew');
|
||||
|
|
@ -125,6 +173,12 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
var checkboxNeedCustomTextNew = document.getElementById('checkboxNeedCustomTextNew');
|
||||
var checkboxDefineResponseLangNew = document.getElementById('checkboxDefineResponseLangNew');
|
||||
var checkboxUseDiffViewerNew = document.getElementById('checkboxUseDiffViewerNew');
|
||||
// ChatGTP Web Integration
|
||||
var chatgptWebModelNew = document.getElementById('chatGPTWebModelNew');
|
||||
var chatgptWebProjectNew = document.getElementById('chatGPTWebProjectNew');
|
||||
var chatgptWebCustomGptNew = document.getElementById('chatGPTWebCustomGPTNew');
|
||||
chatgptWebProjectNew.addEventListener("input", validateCustomData_ChatGPTWeb);
|
||||
chatgptWebCustomGptNew.addEventListener("input", validateCustomData_ChatGPTWeb);
|
||||
|
||||
selectActionNew.addEventListener('change', (e) => {
|
||||
if (e.target.value === "2") {
|
||||
|
|
@ -141,7 +195,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
if(!checkFields()) {
|
||||
return;
|
||||
}
|
||||
let newItem = promptsList.add({
|
||||
let newItemData = {
|
||||
id: String(txtIdNew.value.trim()).toLocaleLowerCase(),
|
||||
name: txtNameNew.value.trim(),
|
||||
text: txtTextNew.value.trim(),
|
||||
|
|
@ -157,7 +211,29 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
position_display: positionMax_display + 1,
|
||||
is_default: 0,
|
||||
idnum: idnumMax + 1,
|
||||
});
|
||||
};
|
||||
|
||||
switch(prefs.connection_type) {
|
||||
case 'chatgpt_web':
|
||||
newItemData.chatgpt_web_model = chatgptWebModelNew.value.trim();
|
||||
newItemData.chatgpt_web_project = chatgptWebProjectNew.value.trim();
|
||||
newItemData.chatgpt_web_custom_gpt = chatgptWebCustomGptNew.value.trim();
|
||||
break;
|
||||
// case 'chatgpt_api':
|
||||
// document.getElementById('chatgpt_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'ollama_api':
|
||||
// document.getElementById('ollama_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'openai_comp_api':
|
||||
// document.getElementById('openai_comp_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'google_gemini_api':
|
||||
// document.getElementById('google_gemini_api').style.display = 'block';
|
||||
// break;
|
||||
}
|
||||
|
||||
let newItem = promptsList.add(newItemData);
|
||||
idnumMax++;
|
||||
let curr_idnum = newItem[0].values().idnum;
|
||||
let checkboxes = document.querySelectorAll(`tr[data-idnum="${curr_idnum}"] input[type="checkbox"]`);
|
||||
|
|
@ -266,6 +342,10 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
};
|
||||
}
|
||||
|
||||
document.querySelectorAll('.chatgpt_web_additional_info_show').forEach(element => {
|
||||
toggleAdditionalPropertiesShow(element.closest('tr'));
|
||||
});
|
||||
|
||||
}, { once: true });
|
||||
|
||||
//========= handling an item in a row
|
||||
|
|
@ -291,6 +371,8 @@ function showItemRowEditor(tr) {
|
|||
text_output.style.display = 'inline';
|
||||
textareaAutocomplete(text_output, autocompleteSuggestions)
|
||||
tr.querySelector('.text_show').style.display = 'none';
|
||||
toggleAdditionalPropertiesEditor(tr);
|
||||
tr.querySelector('.chatgpt_web_additional_info_show').style.display = 'none';
|
||||
tr.querySelector('.type_output').style.display = 'inline';
|
||||
tr.querySelector('.type_show').style.display = 'none';
|
||||
const action_output = tr.querySelector('.action_output')
|
||||
|
|
@ -311,6 +393,9 @@ function hideItemRowEditor(tr) {
|
|||
tr.querySelector('.name_show').style.display = 'inline';
|
||||
tr.querySelector('.text_output').style.display = 'none';
|
||||
tr.querySelector('.text_show').style.display = 'inline';
|
||||
tr.querySelector('.chatgpt_web_additional_info_toggle').style.display = 'none';
|
||||
tr.querySelector('.chatgpt_web_additional_info').style.display = 'none';
|
||||
toggleAdditionalPropertiesShow(tr);
|
||||
tr.querySelector('.type_output').style.display = 'none';
|
||||
tr.querySelector('.type_show').style.display = 'inline';
|
||||
const action_output = tr.querySelector('.action_output')
|
||||
|
|
@ -324,6 +409,85 @@ function hideItemRowEditor(tr) {
|
|||
tr.querySelector('input.use_diff_viewer').disabled = true;
|
||||
}
|
||||
|
||||
function toggleAdditionalPropertiesShow(tr) {
|
||||
switch(prefs.connection_type) {
|
||||
case 'chatgpt_web': {
|
||||
let element = tr.querySelector('.chatgpt_web_additional_info_show');
|
||||
let chatGPTWebModel_show = tr.querySelector('.chatgpt_web_model_show');
|
||||
let chatGPTWebProject_show = tr.querySelector('.chatgpt_web_project_show');
|
||||
let chatGPTWebCustomGPT_show = tr.querySelector('.chatgpt_web_custom_gpt_show');
|
||||
|
||||
if ((chatGPTWebModel_show.innerText !== '' && chatGPTWebModel_show.innerText !== 'undefined') ||
|
||||
(chatGPTWebProject_show.innerText !== '' && chatGPTWebProject_show.innerText !== 'undefined') ||
|
||||
(chatGPTWebCustomGPT_show.innerText !== '' && chatGPTWebCustomGPT_show.innerText !== 'undefined')) {
|
||||
element.style.display = 'flex';
|
||||
} else {
|
||||
element.style.display = 'none';
|
||||
}
|
||||
|
||||
if(chatGPTWebModel_show.innerText === '' || chatGPTWebModel_show.innerText === 'undefined') {
|
||||
chatGPTWebModel_show.parentNode.style.display = 'none';
|
||||
} else {
|
||||
chatGPTWebModel_show.parentNode.style.display = 'inline';
|
||||
}
|
||||
if(chatGPTWebProject_show.innerText === '' || chatGPTWebProject_show.innerText === 'undefined') {
|
||||
chatGPTWebProject_show.parentNode.style.display = 'none';
|
||||
} else {
|
||||
chatGPTWebProject_show.parentNode.style.display = 'inline';
|
||||
}
|
||||
if(chatGPTWebCustomGPT_show.innerText === '' || chatGPTWebCustomGPT_show.innerText === 'undefined') {
|
||||
chatGPTWebCustomGPT_show.parentNode.style.display = 'none';
|
||||
} else {
|
||||
chatGPTWebCustomGPT_show.parentNode.style.display = 'inline';
|
||||
}
|
||||
break;
|
||||
}
|
||||
// case 'chatgpt_api':
|
||||
// document.getElementById('chatgpt_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'ollama_api':
|
||||
// document.getElementById('ollama_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'openai_comp_api':
|
||||
// document.getElementById('openai_comp_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'google_gemini_api':
|
||||
// document.getElementById('google_gemini_api').style.display = 'block';
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleAdditionalPropertiesEditor(tr) {
|
||||
switch(prefs.connection_type) {
|
||||
case 'chatgpt_web': {
|
||||
let info_toggle = tr.querySelector('.chatgpt_web_additional_info_toggle');
|
||||
info_toggle.style.display = 'block';
|
||||
let chatGPTWebModel_show = tr.querySelector('.chatgpt_web_model_show').innerText;
|
||||
let chatGPTWebProject_show = tr.querySelector('.chatgpt_web_project_show').innerText;
|
||||
let chatGPTWebCustomGPT_show = tr.querySelector('.chatgpt_web_custom_gpt_show').innerText;
|
||||
|
||||
if ((chatGPTWebModel_show !== '' && chatGPTWebModel_show !== 'undefined') ||
|
||||
(chatGPTWebProject_show !== '' && chatGPTWebProject_show !== 'undefined') ||
|
||||
(chatGPTWebCustomGPT_show !== '' && chatGPTWebCustomGPT_show !== 'undefined')) {
|
||||
info_toggle.click();
|
||||
}
|
||||
break;
|
||||
}
|
||||
// case 'chatgpt_api':
|
||||
// document.getElementById('chatgpt_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'ollama_api':
|
||||
// document.getElementById('ollama_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'openai_comp_api':
|
||||
// document.getElementById('openai_comp_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'google_gemini_api':
|
||||
// document.getElementById('google_gemini_api').style.display = 'block';
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleDiffviewer(e) {
|
||||
e.preventDefault();
|
||||
const tr = e.target.parentNode.parentNode;
|
||||
|
|
@ -371,6 +535,9 @@ function handleCancelClick(e) {
|
|||
// tr.querySelector('.type_output').selectedOptions[0].text = tr.querySelector('.type_show').innerText;
|
||||
tr.querySelector('.action_output').value = tr.querySelector('.action').innerText;
|
||||
// tr.querySelector('.action_output').selectedOptions[0].text = tr.querySelector('.action_show').innerText;
|
||||
tr.querySelector('.chatgpt_web_model_output').value = tr.querySelector('.chatgpt_web_model_show').innerText;
|
||||
tr.querySelector('.chatgpt_web_project_output').value = tr.querySelector('.chatgpt_web_project_show').innerText;
|
||||
tr.querySelector('.chatgpt_web_custom_gpt_output').value = tr.querySelector('.chatgpt_web_custom_gpt_show').innerText;
|
||||
hideItemRowEditor(tr);
|
||||
}
|
||||
|
||||
|
|
@ -386,6 +553,9 @@ function handleConfirmClick(e) {
|
|||
tr.querySelector('.id_show').innerText = String(tr.querySelector('.id_output').value).toLocaleLowerCase();
|
||||
tr.querySelector('.name_show').innerText = tr.querySelector('.name_output').value;
|
||||
tr.querySelector('.text_show').innerText = tr.querySelector('.text_output').value;
|
||||
tr.querySelector('.chatgpt_web_model_show').innerText = tr.querySelector('.chatgpt_web_model_output').value;
|
||||
tr.querySelector('.chatgpt_web_project_show').innerText = tr.querySelector('.chatgpt_web_project_output').value;
|
||||
tr.querySelector('.chatgpt_web_custom_gpt_show').innerText = tr.querySelector('.chatgpt_web_custom_gpt_output').value;
|
||||
tr.querySelector('.type').innerText = tr.querySelector('.type_output').value;
|
||||
tr.querySelector('.type_show').innerText = tr.querySelector('.type_output').selectedOptions[0].text;
|
||||
tr.querySelector('.action').innerText = tr.querySelector('.action_output').value;
|
||||
|
|
@ -451,24 +621,53 @@ function loadPromptsList(values){
|
|||
let output = `<tr ` + ((values.is_default == 1) ? 'class="is_default"':'') + `>
|
||||
<td class="w08"><span class="id id_show"></span><input type="text" class="hiddendata id_output" value="` + values.id + `" /></td>
|
||||
<td class="w08"><span class="name name_show"></span><input type="text" class="hiddendata name_output" value="` + values.name + `" /></td>
|
||||
<td class="w40"><span class="text text_show"></span><div class="autocomplete-container"><textarea class="hiddendata text_output editor">` + values.text.replace(/<br\s*\/?>/gi, "\n") + `</textarea><ul class="autocomplete-list hidden"></ul></div></td>
|
||||
<td class="w08"><span class="type_show">` + type_output + `</span>
|
||||
<td class="w40">
|
||||
<span class="text text_show"></span>
|
||||
<div class="autocomplete-container">
|
||||
<textarea class="hiddendata text_output editor">` + values.text.replace(/<br\s*\/?>/gi, "\n") + `</textarea>
|
||||
<ul class="autocomplete-list hidden"></ul>
|
||||
</div>
|
||||
<div class="chatgpt_web_additional_info_toggle small_info">__MSG_customPrompts_show_additional_info__</div>
|
||||
<div class="chatgpt_web_additional_info">
|
||||
<span class="field_title_us">__MSG_prefs_OptionText_chatgpt_web_model__:</span>
|
||||
<br>
|
||||
<input type="text" class="input_additional chatgpt_web_model_output" tabindex="10" value="` + values.chatgpt_web_model + `">
|
||||
<table title="__MSG_prefs_OptionText_chatgpt_web_model_tooltip__"><tr id="chatgpt_web_models_list">TODO</tr></table>
|
||||
<br><br>
|
||||
<span class="field_title_us">__MSG_prefs_OptionText_chatgpt_web_project__:</span>
|
||||
<br>
|
||||
<input type="text" id="chatgpt_web_project_` + values.id + `" class="input_additional chatgpt_web_project_output" tabindex="11" value="` + values.chatgpt_web_project + `">
|
||||
<br><i class="small_info" id="chatgpt_web_project_` + values.id + `_info">__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ <b>/g/PROJECT_ID-PROJECT_NAME/project</b>
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__</i>
|
||||
<br><br>
|
||||
<span class="field_title_us">__MSG_prefs_OptionText_chatgpt_web_custom_gpt__:</span>
|
||||
<br>
|
||||
<input type="text" id="chatgpt_web_custom_gpt_` + values.id + `" class="input_additional chatgpt_web_custom_gpt_output" tabindex="11" value="` + values.chatgpt_web_custom_gpt + `">
|
||||
<br><i class="small_info" id="chatgpt_web_custom_gpt_` + values.id + `_info">__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ <b>/g/CUSTOM_GPT_ID</b>
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__
|
||||
<br>__MSG_prefs_OptionText_CustomGPT_Warn__</i>
|
||||
</div>
|
||||
</td>
|
||||
<td class="w08"><span class="field_title_s">__MSG_customPrompts_add_to_menu__:</span>
|
||||
<br>
|
||||
<span class="type_show">` + type_output + `</span>
|
||||
<select class="type_output hiddendata">
|
||||
<option value="0"` + ((values.type == "0") ? ' selected':'') + `>__MSG_customPrompts_add_to_menu_always__</option>
|
||||
<option value="1"` + ((values.type == "1") ? ' selected':'') + `>__MSG_customPrompts_add_to_menu_reading__</option>
|
||||
<option value="2"` + ((values.type == "2") ? ' selected':'') + `>__MSG_customPrompts_add_to_menu_composing__</option>
|
||||
</select>` +
|
||||
`<span class="type hiddendata"></span>
|
||||
<br><br>
|
||||
<span class="field_title_s">__MSG_customPrompts_form_label_Action__:</span>
|
||||
<br><span class="action_show">` + action_output + `</span>
|
||||
<select class="action_output hiddendata">
|
||||
<option value="0"` + ((values.action == "0") ? ' selected':'') + `>__MSG_customPrompts_close_button__</option>
|
||||
<option value="1"` + ((values.action == "1") ? ' selected':'') + `>__MSG_customPrompts_do_reply__</option>
|
||||
<option value="2"` + ((values.action == "2") ? ' selected':'') + `>__MSG_customPrompts_substitute_text__</option>
|
||||
</select>` +
|
||||
`<span class="action hiddendata"></span>
|
||||
</td>
|
||||
<td class="w17">
|
||||
Action: <span class="action_show">` + action_output + `</span>
|
||||
<select class="action_output hiddendata">
|
||||
<option value="0"` + ((values.action == "0") ? ' selected':'') + `>__MSG_customPrompts_close_button__</option>
|
||||
<option value="1"` + ((values.action == "1") ? ' selected':'') + `>__MSG_customPrompts_do_reply__</option>
|
||||
<option value="2"` + ((values.action == "2") ? ' selected':'') + `>__MSG_customPrompts_substitute_text__</option>
|
||||
</select>` +
|
||||
`<span class="action hiddendata"></span>
|
||||
<br>
|
||||
<label><span class="need_selected_span"><input type="checkbox" class="need_selected" disabled> __MSG_customPrompts_form_label_need_selected__</span></label>
|
||||
<br>
|
||||
<label><input type="checkbox" class="need_signature" disabled> __MSG_customPrompts_form_label_need_signature__</label>
|
||||
|
|
@ -483,6 +682,11 @@ function loadPromptsList(values){
|
|||
<span class="is_default hiddendata"></span>
|
||||
<span class="position_compose hiddendata"></span>
|
||||
<span class="position_display hiddendata"></span>
|
||||
<div class="chatgpt_web_additional_info_show small_info"><span class="chatgpt_web_additional_info_row field_title"><i>__MSG_customPrompts_show_additional_info_show__</i></span>
|
||||
<div class="chatgpt_web_additional_info_row"><span class="field_title">__MSG_prefs_OptionText_chatgpt_web_model__:</span><span class="chatgpt_web_model chatgpt_web_model_show">` + values.chatgpt_web_model + `</span></div>
|
||||
<div class="chatgpt_web_additional_info_row"><span class="field_title">__MSG_prefs_OptionText_chatgpt_web_project__:</span><span class="chatgpt_web_project chatgpt_web_project_show">` + values.chatgpt_web_project + `</span></div>
|
||||
<div class="chatgpt_web_additional_info_row"><span class="field_title">__MSG_prefs_OptionText_chatgpt_web_custom_gpt__:</span><span class="chatgpt_web_custom_gpt chatgpt_web_custom_gpt_show">` + values.chatgpt_web_custom_gpt + `</span></div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btnEditItem"` + ((values.is_default == 1) ? ' disabled':'') + `>__MSG_customPrompts_btnEdit__</button>
|
||||
|
|
@ -500,6 +704,28 @@ function loadPromptsList(values){
|
|||
}
|
||||
};
|
||||
|
||||
switch(prefs.connection_type) {
|
||||
case 'chatgpt_web': {
|
||||
options.valueNames.push('chatgpt_web_model', 'chatgpt_web_project', 'chatgpt_web_custom_gpt');
|
||||
break;
|
||||
}
|
||||
// case 'chatgpt_api':
|
||||
// document.getElementById('chatgpt_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'ollama_api':
|
||||
// document.getElementById('ollama_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'openai_comp_api':
|
||||
// document.getElementById('openai_comp_api').style.display = 'block';
|
||||
// break;
|
||||
// case 'google_gemini_api':
|
||||
// document.getElementById('google_gemini_api').style.display = 'block';
|
||||
// break;
|
||||
}
|
||||
|
||||
// console.log('>>>>>>>>>>>>> options: ' + JSON.stringify(options));
|
||||
// console.log('>>>>>>>>>>>>> values: ' + JSON.stringify(values));
|
||||
|
||||
promptsList = new List('all_prompts', options, values);
|
||||
|
||||
checkSelectedBoxes();
|
||||
|
|
@ -574,6 +800,9 @@ function clearFields() {
|
|||
document.getElementById('txtIdNew').value = '';
|
||||
document.getElementById('txtNameNew').value = '';
|
||||
document.getElementById('txtTextNew').value = '';
|
||||
document.getElementById('chatGPTWebModelNew').value = '';
|
||||
document.getElementById('chatGPTWebProjectNew').value = '';
|
||||
document.getElementById('chatGPTWebCustomGPTNew').value = '';
|
||||
document.getElementById('selectTypeNew').value = '0';
|
||||
document.getElementById('selectActionNew').value = '0';
|
||||
document.getElementById('checkboxNeedSelectedNew').value = '0';
|
||||
|
|
@ -643,6 +872,7 @@ async function saveAll() {
|
|||
promptsList.reIndex();
|
||||
let newPrompts = promptsList.items.map(item => {
|
||||
// For each item in the array, return only the '_values' part
|
||||
// console.log(">>>>>>>>>>>>>>>> item: " + JSON.stringify(item))
|
||||
return item.values();
|
||||
});
|
||||
taLog.log('newPrompts: ' + JSON.stringify(newPrompts));
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
get_calendar_event = prefs.get_calendar_event;
|
||||
get_task = prefs.get_task;
|
||||
_ok_sparks = await checkSparksPresence() == 1;
|
||||
console.log(">>>>>>>>>>>>>>>>> add_tags: " + add_tags);
|
||||
console.log(">>>>>>>>>>>>>>>>> get_calendar_event: " + get_calendar_event);
|
||||
console.log(">>>>>>>>>>>>>>>>> get_task: " + get_task);
|
||||
console.log(">>>>>>>>>>>>>>>>> _ok_sparks: " + _ok_sparks);
|
||||
// console.log(">>>>>>>>>>>>>>>>> add_tags: " + add_tags);
|
||||
// console.log(">>>>>>>>>>>>>>>>> get_calendar_event: " + get_calendar_event);
|
||||
// console.log(">>>>>>>>>>>>>>>>> get_task: " + get_task);
|
||||
// console.log(">>>>>>>>>>>>>>>>> _ok_sparks: " + _ok_sparks);
|
||||
searchPrompt(active_prompts, tabId, tabType);
|
||||
i18n.updateDocument();
|
||||
|
||||
|
|
@ -127,18 +127,18 @@ async function searchPrompt(allPrompts, tabId, tabType){
|
|||
let do_get_calendar_event = checkDoCalendarEvent();
|
||||
let do_get_task = checkDoTask();
|
||||
|
||||
console.log(">>>>>>>>>>> do_add_tags: " + do_add_tags);
|
||||
console.log(">>>>>>>>>>> do_get_calendar_event: " + do_get_calendar_event);
|
||||
console.log(">>>>>>>>>>> do_get_task: " + do_get_task);
|
||||
console.log(">>>>>>>>>>> filteredData: " + JSON.stringify(filteredData));
|
||||
// console.log(">>>>>>>>>>> do_add_tags: " + do_add_tags);
|
||||
// console.log(">>>>>>>>>>> do_get_calendar_event: " + do_get_calendar_event);
|
||||
// console.log(">>>>>>>>>>> do_get_task: " + do_get_task);
|
||||
// console.log(">>>>>>>>>>> filteredData: " + JSON.stringify(filteredData));
|
||||
|
||||
num_special_menu_items = (do_add_tags ? 1 : 0) + (do_get_calendar_event ? 1 : 0) + (do_get_task ? 1 : 0);
|
||||
// console.log(">>>>>>>>>>>> num_special_menu_items: " + num_special_menu_items);
|
||||
if(num_special_menu_items > 0){
|
||||
max_num_el -= num_special_menu_items;
|
||||
first_num_el = num_special_menu_items;
|
||||
console.log(">>>>>>>>>>>>> max_num_el: " + max_num_el);
|
||||
console.log(">>>>>>>>>>>>> first_num_el: " + first_num_el);
|
||||
// console.log(">>>>>>>>>>>>> max_num_el: " + max_num_el);
|
||||
// console.log(">>>>>>>>>>>>> first_num_el: " + first_num_el);
|
||||
if(do_add_tags){
|
||||
filteredData = ensurePromptAddTagsFirst(filteredData);
|
||||
if (!filteredData[0].numberPrepended) {
|
||||
|
|
@ -164,7 +164,7 @@ async function searchPrompt(allPrompts, tabId, tabType){
|
|||
}
|
||||
}
|
||||
|
||||
console.log(">>>>>>>>>>> filteredData after special items check: " + JSON.stringify(filteredData));
|
||||
// console.log(">>>>>>>>>>> filteredData after special items check: " + JSON.stringify(filteredData));
|
||||
|
||||
Array.from(filteredData).slice(first_num_el, max_num_el).forEach((item, index) => {
|
||||
let number = (index + first_num_el).toString();
|
||||
|
|
|
|||
Loading…
Reference in a new issue