Skip to content

Commit

Permalink
Bumped chatgpt.js to 2.9.3 ↞ [auto-sync from `adamlui/chatgpt-apps/ch…
Browse files Browse the repository at this point in the history
…atgpt-infinity/greasemonkey`]
  • Loading branch information
adamlui authored and kudo-sync-bot committed May 24, 2024
1 parent c9782e0 commit 1578263
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
9 changes: 5 additions & 4 deletions chrome/extension/lib/chatgpt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This library is a condensed version of chatgpt.js v2.9.2
// This library is a condensed version of chatgpt.js v2.9.3
// © 2023–2024 KudoAI & contributors under the MIT license.
// Source: https://github.com/KudoAI/chatgpt.js
// User guide: https://chatgptjs.org/userguide
Expand Down Expand Up @@ -236,7 +236,8 @@ const chatgpt = {

getNewChatButton: function() {
for (const navBtnSVG of document.querySelectorAll('nav button svg'))
if (navBtnSVG.querySelector('path[d*="M15.673 3.913a3.121"]')) // new chat icon found
if (navBtnSVG.querySelector('path[d*="M15.673 3.913a3.121"], ' // pencil-on-pad icon
+ 'path[d*="M3.07 10.876C3.623"]')) // refresh icon if temp chat
return navBtnSVG.parentNode;
},

Expand Down Expand Up @@ -265,15 +266,15 @@ const chatgpt = {
return new Promise(resolve => {
(function checkIsIdle() {
if (chatgpt.getRegenerateButton()) resolve(true);
else setTimeout(checkIsIdle, 100);
else setTimeout(checkIsIdle, 200);
})();
});},

isLoaded: function() {
return new Promise(resolve => {
(function checkIsLoaded() {
if (chatgpt.getNewChatButton()) resolve(true);
else setTimeout(checkIsLoaded, 100);
else setTimeout(checkIsLoaded, 200);
})();
});},

Expand Down
20 changes: 10 additions & 10 deletions edge/extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

(async () => {

// Import libs
// Import LIBS
const { config, settings } = await import(chrome.runtime.getURL('lib/settings-utils.js')),
{ chatgpt } = await import(chrome.runtime.getURL('lib/chatgpt.js'))

// Add Chrome msg listener
// Add CHROME MSG listener
let fromMsg = false // to prevent double notifications blocked by popup
chrome.runtime.onMessage.addListener(request => {
fromMsg = true
Expand All @@ -28,11 +28,11 @@
function alert(title = '', msg = '', btns = '', checkbox = '', width = '') {
return chatgpt.alert(`${ config.appSymbol } ${ title }`, msg, btns, checkbox, width )}

// Selectively disable content or user script
// Selectively DISABLE content or user script
if (!/chat(?:gpt|\.openai)\.com/.test(window.location.hostname)) return
document.documentElement.setAttribute('cif-extension-installed', true) // for userscript auto-disable

// Init settings
// Init SETTINGS
settings.save('userLanguage', (await chrome.i18n.getAcceptLanguages())[0])
settings.save('infinityMode', false) // to reset popup toggle
settings.load(['autoScrollDisabled', 'replyInterval', 'replyLanguage', 'replyTopic', 'toggleHidden']).then(() => {
Expand All @@ -53,7 +53,7 @@
const isGPT4oUI = document.documentElement.className.includes(' '),
firstLink = document.querySelector('nav a[href="/"]')

// Add listener to auto-disable Infinity Mode
// Add LISTENER to auto-disable Infinity Mode
if (document.hidden !== undefined) { // ...if Page Visibility API supported
document.addEventListener('visibilitychange', () => {
if (config.infinityMode) {
Expand All @@ -62,7 +62,7 @@
else infinityMode.deactivate()
}})}

// Add/update tweaks style
// Add/update TWEAKS style
const tweaksStyleUpdated = 202405171 // datestamp of last edit for this file's `tweaksStyle`
let tweaksStyle = document.getElementById('tweaks-style') // try to select existing style
if (!tweaksStyle || parseInt(tweaksStyle.getAttribute('last-updated'), 10) < tweaksStyleUpdated) { // if missing or outdated
Expand All @@ -81,7 +81,7 @@
)
}

// Create nav toggle div, add styles
// Create NAV TOGGLE div, add styles
const navToggleDiv = document.createElement('div')
navToggleDiv.style.height = '37px'
navToggleDiv.style.margin = '2px 0' // add v-margins
Expand All @@ -98,7 +98,7 @@

settings.load(['extensionDisabled']).then(() => { if (!config.extensionDisabled) insertToggle() })

// Add listener to toggle switch/label/config/menu
// Add LISTENER to toggle switch/label/config/menu
navToggleDiv.addEventListener('click', () => {
const toggleInput = document.querySelector('#infToggleInput')
toggleInput.checked = !toggleInput.checked
Expand All @@ -107,7 +107,7 @@
infinityMode.toggle()
})

// Monitor node changes to update sidebar toggle visibility
// Monitor NODE CHANGES to update sidebar toggle visibility
const nodeObserver = new MutationObserver(mutations => {
mutations.forEach(mutation => {
if (mutation.type == 'childList' && mutation.addedNodes.length) {
Expand Down Expand Up @@ -154,7 +154,7 @@
if (gptsLink) resolve(gptsLink.parentNode.parentNode)
else setTimeout(checkGPTsLinkLoaded, 200)
})()
}), new Promise(resolve => setTimeout(resolve(parentToInsertInto.children[1]), 2000))])
}), new Promise(resolve => setTimeout(() => resolve(parentToInsertInto.children[1]), 2000))])
if (!parentToInsertInto.contains(navToggleDiv))
parentToInsertInto.insertBefore(navToggleDiv, childToInsertBefore)

Expand Down
4 changes: 2 additions & 2 deletions greasemonkey/chatgpt-infinity.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
// @description:zh-TW 從無所不知的 ChatGPT 生成無窮無盡的答案 (用任何語言!)
// @author Adam Lui
// @namespace https://github.com/adamlui
// @version 2024.5.24
// @version 2024.5.24.1
// @license MIT
// @match *://chatgpt.com/*
// @match *://chat.openai.com/*
Expand All @@ -217,7 +217,7 @@
// @compatible qq
// @compatible whale
// @compatible kiwi
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.2/dist/chatgpt.min.js#sha256-5K/Bxm9bvGpV6dIHShz4o0fwPmIbIJxZAcddpzGFhck=
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.3/dist/chatgpt.min.js#sha256-EDN+mCc+0Y4YVzJEoNikd4/rAIaJDLAdb+erWvupXTM=
// @connect cdn.jsdelivr.net
// @connect greasyfork.org
// @grant GM_setValue
Expand Down

0 comments on commit 1578263

Please sign in to comment.