Skip to content

Commit

Permalink
Bumped chatgpt.js to 2.6.9 ↞ [auto-sync from `adamlui/chatgpt-widescr…
Browse files Browse the repository at this point in the history
…een`]
  • Loading branch information
adamlui authored and kudo-sync-bot committed May 1, 2024
1 parent 6a468fa commit 91da36f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 49 deletions.
53 changes: 6 additions & 47 deletions chatgpt-widescreen/chrome/extension/lib/chatgpt.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// This library is a condensed version of chatgpt.js v2.6.7
// © 2023–2024 KudoAI & contributors under the MIT license
// This library is a condensed version of chatgpt.js v2.6.9
// © 2023–2024 KudoAI & contributors under the MIT license.
// Source: https://github.com/KudoAI/chatgpt.js
// User guide: https://chatgptjs.org/userguide
// Latest minified release: https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js/chatgpt.min.js

// Init endpoints
const endpoints = { assets: 'https://raw.githubusercontent.com/KudoAI/chatgpt.js/main' }
const endpoints = { assets: 'https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js' }

// Init feedback properties
localStorage.alertQueue = JSON.stringify([]);
Expand All @@ -16,38 +17,6 @@ const isChromeUserScript = navigator.userAgent.includes('Chrome') && typeof unsa
isFFuserScript = navigator.userAgent.includes('Firefox') && typeof unsafeWindow != 'undefined',
isFFtmScript = isFFuserScript && GM_info.scriptHandler == 'Tampermonkey';

// Define messages
let cjsMessages;
if (!isChromeUserScript && !(isFFuserScript && !isFFtmScript)) { (async () => {
const cjsMsgsLoaded = new Promise(resolve => {
const userLanguage = navigator.languages[0] || navigator.language || navigator.browserLanguage ||
navigator.systemLanguage || navigator.userLanguage || '',
msgHostDir = endpoints.assets + '/data/_locales/',
msgLocaleDir = ( userLanguage ? userLanguage.replace('-', '_') : 'en' ) + '/';
let msgHref = msgHostDir + msgLocaleDir + 'messages.json', msgXHRtries = 0;
(function loadMsgs() {
const xhr = new XMLHttpRequest();
xhr.open('GET', msgHref); xhr.send();
xhr.onload = () => {
try { // to return localized messages.json
const messages = new Proxy(JSON.parse(xhr.responseText), {
get(target, prop) { // remove need to ref nested keys
if (typeof target[prop] == 'object' && target[prop] !== null && 'message' in target[prop]) {
return target[prop].message;
}}}); resolve(messages);
} catch (err) {
msgXHRtries++; if (msgXHRtries === 3) resolve({}); // try up to 3X (original/region-stripped/EN) only
msgHref = userLanguage.includes('-') && msgXHRtries === 1 ? // if regional lang on 1st try...
msgHref.replace(/([^_]*)_[^/]*(\/.*)/, '$1$2') // ...strip region before retrying
: ( msgHostDir + 'en/messages.json' ); // else use default English messages
loadMsgs();
}
};
xhr.onerror = () => { resolve({}); };
})();
}); cjsMessages = await cjsMsgsLoaded;
})();}

const chatgpt = {

alert: function(title, msg, btns, checkbox, width) {
Expand Down Expand Up @@ -183,7 +152,7 @@ const chatgpt = {

// Create close button
const closeBtn = document.createElement('div');
closeBtn.title = cjsMessages?.tooltip_close || 'Close'; closeBtn.classList.add('modal-close-btn');
closeBtn.title = 'Close'; closeBtn.classList.add('modal-close-btn');
const closeSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
closeSVG.setAttribute('height', '10px');
closeSVG.setAttribute('viewBox', '0 0 14 14');
Expand Down Expand Up @@ -281,16 +250,6 @@ const chatgpt = {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); }
},

history: {
isOn: function() {
const navDivs = document.querySelectorAll('nav div'),
offDiv = [...navDivs].find(div => div.textContent.includes('Chat History is off')) || {};
return offDiv.classList.toString().includes('invisible');
},

isOff: function() { return !this.isOn(); }
},

isDarkMode: function() { return document.documentElement.classList.toString().includes('dark'); },
isFullScreen: function() { return chatgpt.browser.isFullScreen(); },

Expand All @@ -315,7 +274,7 @@ const chatgpt = {

// Create/append close button
const closeBtn = document.createElement('div');
closeBtn.title = cjsMessages?.tooltip_dismiss || 'Dismiss'; closeBtn.classList.add('notif-close-btn');
closeBtn.title = 'Dismiss'; closeBtn.classList.add('notif-close-btn');
const closeSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
closeSVG.setAttribute('height', '8px');
closeSVG.setAttribute('viewBox', '0 0 14 14');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
// @description:zu Engeza izinhlobo zezimodi ze-Widescreen + Fullscreen ku-ChatGPT ukuze kube nokubonakala + ukuncitsha ukusukela
// @author Adam Lui
// @namespace https://github.com/adamlui
// @version 2024.5.1.1
// @version 2024.5.1.2
// @license MIT
// @compatible chrome
// @compatible firefox
Expand All @@ -237,7 +237,7 @@
// @match *://poe.com/*
// @icon https://media.chatgptwidescreen.com/images/icons/widescreen-robot-emoji/icon48.png
// @icon64 https://media.chatgptwidescreen.com/images/icons/widescreen-robot-emoji/icon64.png
// @require https://cdn.jsdelivr.net/npm/@kudoai/[email protected].8/dist/chatgpt.min.js#sha256-veeaKpmLF7CZ6kxNfn8SMjD36ijLffGCzel9G4ykpPI=
// @require https://cdn.jsdelivr.net/npm/@kudoai/[email protected].9/dist/chatgpt.min.js#sha256-pl2y5K/m1OovCuCUxK8yh2aA+y+A9uesk3HMBRBQSiE=
// @connect cdn.jsdelivr.net
// @connect greasyfork.org
// @grant GM_setValue
Expand Down

0 comments on commit 91da36f

Please sign in to comment.