talk-to-chatgpt
talk-to-chatgpt copied to clipboard
New OpenAI model update solution
Hey guys! again OpenAI changed its selectors for chatgpt and broke the extension, I managed to fixed it, check out the fork I made at my profile, well work to keep it updated and bring some cool new functions in the near future
If you dont really want to check the fork and youre a bit code-wise heres the updated functions u need to change on content.js to update it:
1st, look for function CN_CheckNewMessages() and replace the entire function with:
// Check for new messages the bot has sent. If a new message is found, it will be read out loud
function CN_CheckNewMessages() {
// Any new messages?
var currentMessageCount = document.querySelectorAll('.text-message').length
if (currentMessageCount > CN_MESSAGE_COUNT) {
// New message!
console.log("New message detected! current message count: " + currentMessageCount);
CN_MESSAGE_COUNT = currentMessageCount;
CN_CURRENT_MESSAGE = document.querySelectorAll('.text-message')[currentMessageCount - 1];
CN_CURRENT_MESSAGE_SENTENCES = []; // Reset list of parts already spoken
CN_CURRENT_MESSAGE_SENTENCES_NEXT_READ = 0;
}
// Split current message into parts
if (CN_CURRENT_MESSAGE) {
var currentText = document.querySelectorAll('.text-message')[currentMessageCount - 1].innerText + "";
//console.log("currentText:" + currentText);
// Remove code blocks?
if (CN_IGNORE_CODE_BLOCKS) {
currentText = ""
document.querySelectorAll('.text-message')[currentMessageCount - 1].querySelectorAll(".markdown > :not(pre)").forEach(n => {
currentText += n.innerText
});
////console.log("[CODE] currentText:" + currentText);
}
var newSentences = CN_SplitIntoSentences(currentText);
if (newSentences != null && newSentences.length != CN_CURRENT_MESSAGE_SENTENCES.length) {
////console.log("[NEW SENTENCES] newSentences:" + newSentences.length);
// There is a new part of a sentence!
var nextRead = CN_CURRENT_MESSAGE_SENTENCES_NEXT_READ;
for (let i = nextRead; i < newSentences.length; i++) {
CN_CURRENT_MESSAGE_SENTENCES_NEXT_READ = i+1;
var lastPart = newSentences[i];
//console.log("Will say sentence out loud: "+lastPart);
CN_SayOutLoud(lastPart);
}
CN_CURRENT_MESSAGE_SENTENCES = newSentences;
}
}
setTimeout(CN_CheckNewMessages, 100);
}
2nd: look for var currentMessageCount = document.querySelectorAll('.text-base .items-start').length; and replace it with
var currentMessageCount = document.querySelectorAll('.text-message').length;