Skip to content

Commit

Permalink
Merge pull request #242 from ionetodeleon/fix/fix-custom-gpts
Browse files Browse the repository at this point in the history
Fix custom GPTs and setting new Chat GPT url
  • Loading branch information
PxPerfectMike authored May 10, 2024
2 parents bab6202 + dac5ea4 commit 145de81
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The extension can be downloaded from here:
* From the **Edge Web store** here: https://microsoftedge.microsoft.com/addons/detail/talktochatgpt/bkkdkngklccknmoalpoakglipbibafpn
* Manual installation option, detailed further below

After installing the extension, open or reload the ChatGPT page ( https://chat.openai.com/ ) and you should be seeing a 'Start' button on the top right corner of the page. After you click Start, you will be asked for permission to use your Microphone. This is required to enable voice recognition.
After installing the extension, open or reload the ChatGPT page ( https://chatgpt.com/ ) and you should be seeing a 'Start' button on the top right corner of the page. After you click Start, you will be asked for permission to use your Microphone. This is required to enable voice recognition.

![Talk-to-GPT Widget](/images/260-main.png?raw=true "Talk-to-ChatGPT Widget")

Expand Down
46 changes: 28 additions & 18 deletions chrome-extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Author : C. NEDELCU
// Version : 2.9.0 (17/09/2023)
// Git repo : https://github.com/C-Nedelcu/talk-to-chatgpt
// Chat GPT URL : https://chat.openai.com/chat
// Chat GPT URL : https://chatgpt.com
// How to use : https://www.youtube.com/watch?v=VXkLQMEs3lA
// Credits : C. NEDELCU (code), pixelsoda (GUI), S. James (GUI)

Expand Down Expand Up @@ -955,28 +955,38 @@ function CN_ToggleButtonClick() {

return;
}
// Global descriptor caches to avoid repeated definitions
let textareaDescriptorCache = null;
let prototypeDescriptorCache = null;

// Function to set native value with descriptor caching
function setNativeValue(element, value) {
if (!textareaDescriptorCache || !prototypeDescriptorCache) {
textareaDescriptorCache = Object.getOwnPropertyDescriptor(element, 'value') || {};
const prototype = Object.getPrototypeOf(element);
prototypeDescriptorCache = Object.getOwnPropertyDescriptor(prototype, 'value') || {};
}

const { set: valueSetter } = textareaDescriptorCache;
const { set: prototypeValueSetter } = prototypeDescriptorCache;

if (prototypeValueSetter && valueSetter !== prototypeValueSetter) {
prototypeValueSetter.call(element, value);
} else if (valueSetter) {
valueSetter.call(element, value);
} else {
throw new Error('The given element does not have a value setter');
}
}


// Function to set textarea value and dispatch input event
function CN_SetTextareaValue(text) {
const textarea = jQuery("#prompt-textarea")[0];
function setNativeValue(element, value) {
const { set: valueSetter } = Object.getOwnPropertyDescriptor(element, 'value') || {}
const prototype = Object.getPrototypeOf(element)
const { set: prototypeValueSetter } = Object.getOwnPropertyDescriptor(prototype, 'value') || {}

if (prototypeValueSetter && valueSetter !== prototypeValueSetter) {
prototypeValueSetter.call(element, value)
} else if (valueSetter) {
valueSetter.call(element, value)
} else {
throw new Error('The given element does not have a value setter')
}
}
setNativeValue(textarea, text)
textarea.dispatchEvent(new Event('input', { bubbles: true }))
const textarea = jQuery("#prompt-textarea")[0];
setNativeValue(textarea, text);
textarea.dispatchEvent(new Event('input', { bubbles: true }));
}


function CN_PlaySound(audioData, onEnded, transcript) {
//console.log("PlaySound - "+onEnded);
chrome.runtime.sendMessage({
Expand Down
2 changes: 1 addition & 1 deletion chrome-extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"content_scripts":[
{
"matches":[
"https://chat.openai.com/*"
"https://chatgpt.com/*"
],
"js": ["jquery.min.js", "fontawesome.min.js", "content.js"]
}
Expand Down
2 changes: 1 addition & 1 deletion chrome-extension/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1><img src='https://edunext.com.sg/ttgpt.png' alt='' height=32 style='float: l

<p>
<b>To start using this extension,
you need to open the <a href='https://chat.openai.com/chat' target=_blank>ChatGPT home page</a></b>.
you need to open the <a href='https://chatgpt.com' target=_blank>ChatGPT home page</a></b>.

Once you are logged in, a box will display at the top right corner of your screen with a 'START' button.
Click START to start talking.
Expand Down
Binary file modified legacy/talk-to-chatgpt.js
Binary file not shown.

0 comments on commit 145de81

Please sign in to comment.