diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index 7c0eb305..d4080c9c 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -1660,5 +1660,9 @@
"chatgpt_click_force_completion": {
"message": "It seems that it's not possible to get if ChatGPT has finished. Click here to force the completion of the job.",
"description": ""
+ },
+ "warn_API_needed": {
+ "message": "To use this feature, you need an API integration rather than the ChatGPT Web Integration. You can define a specific API in the feature settings page by first checking the checkbox above and then clicking the button on the left.",
+ "description": ""
}
}
\ No newline at end of file
diff --git a/js/mzta-utils.js b/js/mzta-utils.js
index c28c1814..66fa50be 100644
--- a/js/mzta-utils.js
+++ b/js/mzta-utils.js
@@ -606,6 +606,7 @@ export function isAPIKeyValue(id){
}
export function getConnectionType(conntype, prompt) {
+ console.log(">>>>>>>>>>> getConnectionType conntype: " + conntype + " prompt: " + JSON.stringify(prompt));
if (prompt?.api != null && prompt.api !== '') {
return prompt.api;
} else {
diff --git a/options/mzta-options.css b/options/mzta-options.css
index f2f53464..e2721e13 100644
--- a/options/mzta-options.css
+++ b/options/mzta-options.css
@@ -104,6 +104,11 @@ div#miczTranslate{
font-size:smaller;
}
+.warn_API_needed{
+ display: none;
+ font-weight: bold;
+}
+
#no_sparks td{
text-align: center;
padding: 1em !important;
diff --git a/options/mzta-options.html b/options/mzta-options.html
index 9b1b9d58..0e24f172 100644
--- a/options/mzta-options.html
+++ b/options/mzta-options.html
@@ -132,6 +132,7 @@
@@ -142,6 +143,7 @@
diff --git a/options/mzta-options.js b/options/mzta-options.js
index 1924e3c4..aeb16f64 100644
--- a/options/mzta-options.js
+++ b/options/mzta-options.js
@@ -18,8 +18,21 @@
import { prefs_default } from './mzta-options-default.js';
import { taLogger } from '../js/mzta-logger.js';
-import { ChatGPTWeb_models, checkSparksPresence, isThunderbird128OrGreater, openTab, getChatGPTWebModelsList_HTML, isAPIKeyValue } from '../js/mzta-utils.js';
-import { injectConnectionUI, varConnectionUI, showConnectionOptions, updateWarnings } from '../pages/_lib/connection-ui.js';
+import {
+ ChatGPTWeb_models,
+ checkSparksPresence,
+ isThunderbird128OrGreater,
+ openTab,
+ getChatGPTWebModelsList_HTML,
+ isAPIKeyValue,
+ getConnectionType,
+} from '../js/mzta-utils.js';
+import {
+ injectConnectionUI,
+ varConnectionUI,
+ showConnectionOptions,
+ updateWarnings
+} from '../pages/_lib/connection-ui.js';
let taLog = new taLogger("mzta-options",true);
let _isThunderbird128OrGreater = true;
@@ -111,39 +124,36 @@ function disable_MaxPromptLength(){
maxPromptLength_tr.style.display = (maxPromptLength.disabled) ? 'none' : 'table-row';
}
-function disable_AddTags(){
+function disable_AddTags(prefs_opt){
let add_tags = document.getElementById('add_tags');
let conntype_select = document.getElementById("connection_type");
- add_tags.disabled = (conntype_select.value === "chatgpt_web");
- add_tags.checked = add_tags.disabled ? false : add_tags.checked;
+ let add_tags_disabled = (getConnectionType(conntype_select.value, {api: prefs_opt.add_tags_use_specific_integration ? prefs_opt.add_tags_connection_type : ''}) === "chatgpt_web");
+ console.log('>>>>>>>>>>>>> add_tags_disabled: ' + add_tags_disabled);
+ add_tags.checked = add_tags_disabled ? false : add_tags.checked;
let add_tags_checked_original = add_tags.checked;
if(!add_tags.checked){
let add_tags_info_btn = document.getElementById('btnManageTagsInfo');
add_tags_info_btn.disabled = 'disabled';
}
- let add_tags_tr_elements = document.querySelectorAll('.add_tags_tr');
- add_tags_tr_elements.forEach(add_tags_tr => {
- add_tags_tr.style.display = (add_tags.disabled) ? 'none' : 'table-row';
- });
+ let add_tags_warn_API_needed = document.getElementById('add_tags_warn_API_needed');
+ add_tags_warn_API_needed.style.display = (add_tags_disabled) ? 'inline-block' : 'none';
if(add_tags_checked_original != add_tags.checked){
browser.storage.sync.set({add_tags: add_tags.checked});
}
}
-function disable_SpamFilter(){
+function disable_SpamFilter(prefs_opt){
let spamfilter = document.getElementById('spamfilter');
let conntype_select = document.getElementById("connection_type");
- spamfilter.disabled = (conntype_select.value === "chatgpt_web");
+ let spamfilter_disabled = (getConnectionType(conntype_select.value, {api: prefs_opt.spamfilter_use_specific_integration ? prefs_opt.spamfilter_connection_type : ''}) === "chatgpt_web");;
let spamfilter_checked_original = spamfilter.checked;
- spamfilter.checked = spamfilter.disabled ? false : spamfilter.checked;
+ spamfilter.checked = spamfilter_disabled ? false : spamfilter.checked;
if(!spamfilter.checked){
let spamfilter_info_btn = document.getElementById('btnManageSpamFilterInfo');
spamfilter_info_btn.disabled = 'disabled';
}
- let spamfilter_tr_elements = document.querySelectorAll('.spamfilter_tr');
- spamfilter_tr_elements.forEach(spamfilter_tr => {
- spamfilter_tr.style.display = (spamfilter.disabled) ? 'none' : 'table-row';
- });
+ let spamfilter_warn_API_needed = document.getElementById('spamfilter_warn_API_needed');
+ spamfilter_warn_API_needed.style.display = (spamfilter_disabled) ? 'inline-block' : 'none';
if(spamfilter_checked_original != spamfilter.checked){
browser.storage.sync.set({spamfilter: spamfilter.checked});
}
@@ -291,16 +301,23 @@ document.addEventListener('DOMContentLoaded', async () => {
});
});
+ let prefs_opt = await browser.storage.sync.get({
+ add_tags_use_specific_integration: prefs_default.add_tags_use_specific_integration,
+ add_tags_connection_type: prefs_default.add_tags_connection_type,
+ spamfilter_use_specific_integration: prefs_default.spamfilter_use_specific_integration,
+ spamfilter_connection_type: prefs_default.spamfilter_connection_type,
+ });
+
let conntype_select = document.getElementById("connection_type");
conntype_select.addEventListener("change", disable_MaxPromptLength);
- conntype_select.addEventListener("change", disable_AddTags);
- conntype_select.addEventListener("change", disable_SpamFilter);
+ conntype_select.addEventListener("change", () => disable_AddTags(prefs_opt));
+ conntype_select.addEventListener("change", () => disable_SpamFilter(prefs_opt));
conntype_select.addEventListener("change", disable_GetCalendarEvent);
showConnectionOptions(conntype_select);
disable_MaxPromptLength();
- disable_AddTags();
- disable_SpamFilter();
+ disable_AddTags(prefs_opt);
+ disable_SpamFilter(prefs_opt);
disable_GetCalendarEvent();
document.getElementById('reset_max_prompt_length').addEventListener('click', resetMaxPromptLength);