Skip to content

Commit 9d9de4a

Browse files
committed
Added chatgpt.isTyping() check before handling Esc pressed + notif
1 parent 6f417f4 commit 9d9de4a

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

chatgpt-widescreen/chromium/extension/content.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@
368368
// Add KEY LISTENER to enable flag on F11 + stop generating text on ESC
369369
document.addEventListener('keydown', event => {
370370
if ((event.key == 'F11' || event.keyCode == 122) && !config.fullScreen) config.f11 = true
371-
else if ((event.key.startsWith('Esc') || event.keyCode == 27)) try { chatgpt.stop() } catch (err) {}
371+
else if ((event.key.startsWith('Esc') || event.keyCode == 27) && chatgpt.isTyping())
372+
try { chatgpt.stop() ; notify(getMsg('notif_chatStopped'), 'bottom-right') } catch (err) {}
372373
})
373374

374375
})()

chatgpt-widescreen/chromium/extension/lib/chatgpt.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ const chatgpt = {
336336
},
337337

338338
isFullScreen() { return chatgpt.browser.isFullScreen(); },
339+
isTyping() { return !!this.getStopButton() },
339340

340341
notify(msg, position, notifDuration, shadow) {
341342
notifDuration = notifDuration ? +notifDuration : 1.75; // sec duration to maintain notification visibility

chatgpt-widescreen/firefox/extension/content.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@
368368
// Add KEY LISTENER to enable flag on F11 + stop generating text on ESC
369369
document.addEventListener('keydown', event => {
370370
if ((event.key == 'F11' || event.keyCode == 122) && !config.fullScreen) config.f11 = true
371-
else if ((event.key.startsWith('Esc') || event.keyCode == 27)) try { chatgpt.stop() } catch (err) {}
371+
else if ((event.key.startsWith('Esc') || event.keyCode == 27) && chatgpt.isTyping())
372+
try { chatgpt.stop() ; notify(getMsg('notif_chatStopped'), 'bottom-right') } catch (err) {}
372373
})
373374

374375
})()

chatgpt-widescreen/firefox/extension/lib/chatgpt.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ const chatgpt = {
336336
},
337337

338338
isFullScreen() { return chatgpt.browser.isFullScreen(); },
339+
isTyping() { return !!this.getStopButton() },
339340

340341
notify(msg, position, notifDuration, shadow) {
341342
notifDuration = notifDuration ? +notifDuration : 1.75; // sec duration to maintain notification visibility

chatgpt-widescreen/greasemonkey/chatgpt-widescreen-mode.user.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@
235235
// @description:zu Thuthukisa iChatGPT ngemodi zesikrini ezibanzi/egcwele/ephezulu + imodi yokuvimbela i-spam. Futhi isebenza ku-perplexity.ai + poe.com!
236236
// @author Adam Lui
237237
// @namespace https://github.com/adamlui
238-
// @version 2025.2.18
238+
// @version 2025.2.19
239239
// @license MIT
240240
// @icon https://assets.chatgptwidescreen.com/images/icons/widescreen-robot-emoji/icon48.png?v=844b16e
241241
// @icon64 https://assets.chatgptwidescreen.com/images/icons/widescreen-robot-emoji/icon64.png?v=844b16e
@@ -379,6 +379,7 @@
379379
alert_tyForSupport: 'Thank you for your support',
380380
alert_pressF11: 'Press F11 to exit full screen',
381381
alert_f11reason: 'F11 was used to enter full screen, and due to browser security reasons, the same key must be used to exit it',
382+
notif_chatStopped: 'Chat stopped',
382383
btnLabel_moreAIextensions: 'More AI Extensions',
383384
btnLabel_rateUs: 'Rate Us',
384385
btnLabel_discuss: 'Discuss',
@@ -937,7 +938,8 @@
937938
// Add KEY LISTENER to enable flag on F11 + stop generating text on ESC
938939
document.addEventListener('keydown', event => {
939940
if ((event.key == 'F11' || event.keyCode == 122) && !config.fullScreen) config.f11 = true
940-
else if ((event.key.startsWith('Esc') || event.keyCode == 27)) try { chatgpt.stop() } catch (err) {}
941+
else if ((event.key.startsWith('Esc') || event.keyCode == 27) && chatgpt.isTyping())
942+
try { chatgpt.stop() ; notify(app.msgs.notif_chatStopped, 'bottom-right') } catch (err) {}
941943
})
942944

943945
})()

0 commit comments

Comments
 (0)