Add validation function for ChatGPT Web custom data and update related logic. see #277 and #168

This commit is contained in:
Mic 2025-04-24 01:37:00 +02:00
parent 2195d03f98
commit bdd4d7ffc7
3 changed files with 6 additions and 3 deletions

View file

@ -411,6 +411,9 @@ export async function checkSparksPresence() {
}
}
export function validateChatGPTWebCustomData(data) {
return data.startsWith('/g/') || data == '';
}
// The following methods are a modified version derived from https://github.com/ali-raheem/Aify/blob/13ff87583bc520fb80f555ab90a90c5c9df797a7/plugin/content_scripts/compose.js

View file

@ -171,7 +171,7 @@
</tr>
<tr class="conntype_chatgpt_web">
<td><label>
<span class="opt_title">__MSG_OpenChatGPTTab_Info__</span>
<span>__MSG_OpenChatGPTTab_Info__</span>
</label></td>
<td>
<button id="btnChatGPTWeb_Tab">__MSG_OpenChatGPTTab__</button>

View file

@ -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, validateChatGPTWebCustomData } from '../js/mzta-utils.js';
let taLog = new taLogger("mzta-options",true);
let _isThunderbird128OrGreater = true;
@ -314,7 +314,7 @@ async function disable_GetCalendarEvent(){
}
function validateCustomData_ChatGPTWeb(event) {
let is_valid = event.target.value.startsWith('/g/') || event.target.value == '';
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';
}