Skip to content

Commit

Permalink
Re-added chat.openai.com support in case they get funny and change mi…
Browse files Browse the repository at this point in the history
…nd again ↞ [auto-sync from `adamlui/chatgpt-widescreen`]
  • Loading branch information
adamlui authored and kudo-sync-bot committed May 4, 2024
1 parent 8cd4355 commit db3faaa
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 83 deletions.
2 changes: 1 addition & 1 deletion chatgpt-widescreen/chrome/extension/background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const allowedHosts = ['chatgpt.com', 'poe.com']
const allowedHosts = ['chatgpt.com', 'chat.openai.com', 'poe.com']

// Add install/update actions
chrome.runtime.onInstalled.addListener(details => {
Expand Down
34 changes: 17 additions & 17 deletions chatgpt-widescreen/chrome/extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@

// Selectively disable content or user script
const site = /:\/\/(.*?\.)?(.*)\.[^/]+/.exec(document.location.href)[2]
if (!['chatgpt', 'poe'].includes(site)) return
if (!/chatgpt|openai|poe/.test(site)) return
document.documentElement.setAttribute('cwm-extension-installed', true) // for userscript auto-disable

// Wait for site load
if (site == 'chatgpt') await chatgpt.isLoaded()
if (/chatgpt|openai/.test(site)) await chatgpt.isLoaded()

// Define UI element selectors
const headerSelector = site == 'chatgpt' ? 'main .sticky' : '',
footerSelector = site == 'chatgpt' ? 'main form ~ div' : '',
chatbarSelector = site == 'chatgpt' ? 'div[class*="textarea:focus"'
const headerSelector = /chatgpt|openai/.test(site) ? 'main .sticky' : '',
footerSelector = /chatgpt|openai/.test(site) ? 'main form ~ div' : '',
chatbarSelector = /chatgpt|openai/.test(site) ? 'div[class*="textarea:focus"'
: site == 'poe' ? 'div[class*="ChatMessageInputContainer"]' : ''

// Save full-window + full screen states
config.fullWindow = site == 'chatgpt' ? chatgpt.sidebar.isOff() : settings.load('fullWindow')
config.fullWindow = /chatgpt|openai/.test(site) ? chatgpt.sidebar.isOff() : settings.load('fullWindow')
config.fullScreen = chatgpt.isFullScreen()

// Collect button classes
const sendBtnSelector = site == 'chatgpt' ? 'form button[class*="bottom"]' : null,
const sendBtnSelector = /chatgpt|openai/.test(site) ? 'form button[class*="bottom"]' : null,
sendBtnClasses = document.querySelector(sendBtnSelector)?.classList || [],
sendImgClasses = document.querySelector('form button[class*="bottom"] svg')?.classList || []

Expand All @@ -71,7 +71,7 @@
const tweaksStyle = document.createElement('style'),
tcbStyle = inputSelector + '{ max-height: 68vh !important }', // heighten chatbox
hhStyle = headerSelector + '{ display: none !important }' // hide header
+ ( site == 'chatgpt' ? 'main { padding-top: 12px }' : '' ), // increase top-padding
+ ( /chatgpt|openai/.test(site) ? 'main { padding-top: 12px }' : '' ), // increase top-padding
hfStyle = footerSelector + '{ color: transparent !important ;' // hide footer text
+ ' padding: .1rem 0 0 !important }' // reduce v-padding

Expand All @@ -81,7 +81,7 @@
const wideScreenStyle = document.createElement('style')
wideScreenStyle.id = 'wideScreen-mode' // for syncMode()
const wcbStyle = ( // Wider Chatbox for updateWidescreenStyle()
site == 'chatgpt' ? 'main form { max-width: 96% !important }'
/chatgpt|openai/.test(site) ? 'main form { max-width: 96% !important }'
: site == 'poe' ? '[class^="ChatMessageInputFooter"] { max-width: 100% }' : '' )
updateWidescreenStyle()

Expand All @@ -108,7 +108,7 @@
window[buttonName].setAttribute('class', sendBtnClasses)
else if (site == 'poe') // lift buttons slightly
window[buttonName].style.marginBottom = ( buttonType == 'newChat' ? '0.45' : '0.2' ) + 'rem'
if (site == 'chatgpt') { // style tweaks for OpenAI Gizmo UI
if (/chatgpt|openai/.test(site)) { // style tweaks for OpenAI Gizmo UI
window[buttonName].style.backgroundColor = 'transparent' // remove dark mode overlay
window[buttonName].style.borderColor = 'transparent' // remove dark mode overlay
window[buttonName].querySelector('svg').setAttribute('width', 18) // fix disappearing width in dark mode
Expand All @@ -118,7 +118,7 @@
// Add click/hover listeners
window[buttonName].addEventListener('click', () => {
if (buttonType == 'newChat') {
if (site == 'chatgpt') chatgpt.startNewChat()
if (/chatgpt|openai/.test(site)) chatgpt.startNewChat()
else if (site == 'poe') document.querySelector('header a[class*="button"]').click()
} else toggleMode(buttonType) })
window[buttonName].addEventListener('mouseover', toggleTooltip)
Expand All @@ -141,7 +141,7 @@
if (!prevSessionChecked) { // restore previous session's state
if (config.wideScreen) toggleMode('wideScreen', 'ON')
if (config.fullWindow) { toggleMode('fullWindow', 'ON')
if (site == 'chatgpt') { // sidebar observer doesn't trigger
if (/chatgpt|openai/.test(site)) { // sidebar observer doesn't trigger
syncFullerWindows(true) // so sync Fuller Windows...
if (!config.notifDisabled) // ... + notify
notify(chrome.i18n.getMessage('mode_fullWindow') + ' ON')
Expand All @@ -168,7 +168,7 @@
}})}) ; schemeObserver.observe(document.documentElement, { attributes: true })

// Monitor sidebar button to update full-window setting
if (site == 'chatgpt') {
if (/chatgpt|openai/.test(site)) {
const sidebarObserver = new MutationObserver(() => {
settings.load(['extensionDisabled']).then(() => {
if (!config.extensionDisabled) {
Expand Down Expand Up @@ -219,14 +219,14 @@
// Define BUTTON functions

function setBtnColor() { return (
site == 'chatgpt' ? ( chatgpt.isDarkMode() ? 'white' : '#202123' ) : 'currentColor' )}
/chatgpt|openai/.test(site) ? ( chatgpt.isDarkMode() ? 'white' : '#202123' ) : 'currentColor' )}

function insertBtns() {
const chatbar = document.querySelector(chatbarSelector)
if (chatbar.contains(wideScreenBtn)) return // if buttons aren't missing, exit
const elemsToInsert = [newChatBtn, wideScreenBtn, fullWindowBtn, fullScreenBtn, tooltipDiv],
leftMostBtn = chatbar.querySelector('button' + ( site != 'poe' ? '[class*="right"]' : ''))
if (site == 'chatgpt') // allow tooltips to overflow
if (/chatgpt|openai/.test(site)) // allow tooltips to overflow
chatbar.classList.remove('overflow-hidden')
else if (site == 'poe') // elevate nested non-send button to chatbar
chatbar.insertBefore(leftMostBtn, chatbar.lastChild)
Expand Down Expand Up @@ -384,7 +384,7 @@

function updateTweaksStyle() {
tweaksStyle.innerText = (
site == 'chatgpt' ? (
/chatgpt|openai/.test(site) ? (
inputSelector + `{ padding-right: ${ config.ncbDisabled ? 126 : 152 }px }` // narrow input to accomodate btns
+ 'div.group > div > div > div > div:nth-child(2) { ' // move response paginator
+ 'position: relative ; left: 66px ; top: 7px } ' // ...below avatar to avoid cropping
Expand All @@ -396,7 +396,7 @@

function updateWidescreenStyle() {
wideScreenStyle.innerText = (
site == 'chatgpt' ? (
/chatgpt|openai/.test(site) ? (
'.text-base { max-width: 100% !important }' // widen outer container
+ '.text-base:nth-of-type(2) { max-width: 97% !important }' // widen inner container
+ '#__next > div > div.flex { width: 100px }' ) // prevent sidebar shrinking when zoomed
Expand Down
4 changes: 2 additions & 2 deletions chatgpt-widescreen/chrome/extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,

Check warning on line 2 in chatgpt-widescreen/chrome/extension/manifest.json

View workflow job for this annotation

GitHub Actions / eslint

"manifest_version" must be equal to 2
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"version": "2024.5.3",
"version": "2024.5.3.1",
"author": "Adam Lui",
"default_locale": "en",
"icons": {
Expand All @@ -20,7 +20,7 @@
"resources": ["lib/settings-utils.js", "lib/chatgpt.js"]
}],
"content_scripts": [{
"matches": ["https://chatgpt.com/*", "https://poe.com/*"],
"matches": ["https://chatgpt.com/*", "https://chat.openai.com/*", "https://poe.com/*"],
"js": ["content.js"]
}],
"background": { "service_worker": "background.js" }
Expand Down
2 changes: 1 addition & 1 deletion chatgpt-widescreen/edge/extension/background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const allowedHosts = ['chatgpt.com', 'poe.com']
const allowedHosts = ['chatgpt.com', 'chat.openai.com', 'poe.com']

// Add install/update actions
chrome.runtime.onInstalled.addListener(details => {
Expand Down
34 changes: 17 additions & 17 deletions chatgpt-widescreen/edge/extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@

// Selectively disable content or user script
const site = /:\/\/(.*?\.)?(.*)\.[^/]+/.exec(document.location.href)[2]
if (!['chatgpt', 'poe'].includes(site)) return
if (!/chatgpt|openai|poe/.test(site)) return
document.documentElement.setAttribute('cwm-extension-installed', true) // for userscript auto-disable

// Wait for site load
if (site == 'chatgpt') await chatgpt.isLoaded()
if (/chatgpt|openai/.test(site)) await chatgpt.isLoaded()

// Define UI element selectors
const headerSelector = site == 'chatgpt' ? 'main .sticky' : '',
footerSelector = site == 'chatgpt' ? 'main form ~ div' : '',
chatbarSelector = site == 'chatgpt' ? 'div[class*="textarea:focus"'
const headerSelector = /chatgpt|openai/.test(site) ? 'main .sticky' : '',
footerSelector = /chatgpt|openai/.test(site) ? 'main form ~ div' : '',
chatbarSelector = /chatgpt|openai/.test(site) ? 'div[class*="textarea:focus"'
: site == 'poe' ? 'div[class*="ChatMessageInputContainer"]' : ''

// Save full-window + full screen states
config.fullWindow = site == 'chatgpt' ? chatgpt.sidebar.isOff() : settings.load('fullWindow')
config.fullWindow = /chatgpt|openai/.test(site) ? chatgpt.sidebar.isOff() : settings.load('fullWindow')
config.fullScreen = chatgpt.isFullScreen()

// Collect button classes
const sendBtnSelector = site == 'chatgpt' ? 'form button[class*="bottom"]' : null,
const sendBtnSelector = /chatgpt|openai/.test(site) ? 'form button[class*="bottom"]' : null,
sendBtnClasses = document.querySelector(sendBtnSelector)?.classList || [],
sendImgClasses = document.querySelector('form button[class*="bottom"] svg')?.classList || []

Expand All @@ -71,7 +71,7 @@
const tweaksStyle = document.createElement('style'),
tcbStyle = inputSelector + '{ max-height: 68vh !important }', // heighten chatbox
hhStyle = headerSelector + '{ display: none !important }' // hide header
+ ( site == 'chatgpt' ? 'main { padding-top: 12px }' : '' ), // increase top-padding
+ ( /chatgpt|openai/.test(site) ? 'main { padding-top: 12px }' : '' ), // increase top-padding
hfStyle = footerSelector + '{ color: transparent !important ;' // hide footer text
+ ' padding: .1rem 0 0 !important }' // reduce v-padding

Expand All @@ -81,7 +81,7 @@
const wideScreenStyle = document.createElement('style')
wideScreenStyle.id = 'wideScreen-mode' // for syncMode()
const wcbStyle = ( // Wider Chatbox for updateWidescreenStyle()
site == 'chatgpt' ? 'main form { max-width: 96% !important }'
/chatgpt|openai/.test(site) ? 'main form { max-width: 96% !important }'
: site == 'poe' ? '[class^="ChatMessageInputFooter"] { max-width: 100% }' : '' )
updateWidescreenStyle()

Expand All @@ -108,7 +108,7 @@
window[buttonName].setAttribute('class', sendBtnClasses)
else if (site == 'poe') // lift buttons slightly
window[buttonName].style.marginBottom = ( buttonType == 'newChat' ? '0.45' : '0.2' ) + 'rem'
if (site == 'chatgpt') { // style tweaks for OpenAI Gizmo UI
if (/chatgpt|openai/.test(site)) { // style tweaks for OpenAI Gizmo UI
window[buttonName].style.backgroundColor = 'transparent' // remove dark mode overlay
window[buttonName].style.borderColor = 'transparent' // remove dark mode overlay
window[buttonName].querySelector('svg').setAttribute('width', 18) // fix disappearing width in dark mode
Expand All @@ -118,7 +118,7 @@
// Add click/hover listeners
window[buttonName].addEventListener('click', () => {
if (buttonType == 'newChat') {
if (site == 'chatgpt') chatgpt.startNewChat()
if (/chatgpt|openai/.test(site)) chatgpt.startNewChat()
else if (site == 'poe') document.querySelector('header a[class*="button"]').click()
} else toggleMode(buttonType) })
window[buttonName].addEventListener('mouseover', toggleTooltip)
Expand All @@ -141,7 +141,7 @@
if (!prevSessionChecked) { // restore previous session's state
if (config.wideScreen) toggleMode('wideScreen', 'ON')
if (config.fullWindow) { toggleMode('fullWindow', 'ON')
if (site == 'chatgpt') { // sidebar observer doesn't trigger
if (/chatgpt|openai/.test(site)) { // sidebar observer doesn't trigger
syncFullerWindows(true) // so sync Fuller Windows...
if (!config.notifDisabled) // ... + notify
notify(chrome.i18n.getMessage('mode_fullWindow') + ' ON')
Expand All @@ -168,7 +168,7 @@
}})}) ; schemeObserver.observe(document.documentElement, { attributes: true })

// Monitor sidebar button to update full-window setting
if (site == 'chatgpt') {
if (/chatgpt|openai/.test(site)) {
const sidebarObserver = new MutationObserver(() => {
settings.load(['extensionDisabled']).then(() => {
if (!config.extensionDisabled) {
Expand Down Expand Up @@ -219,14 +219,14 @@
// Define BUTTON functions

function setBtnColor() { return (
site == 'chatgpt' ? ( chatgpt.isDarkMode() ? 'white' : '#202123' ) : 'currentColor' )}
/chatgpt|openai/.test(site) ? ( chatgpt.isDarkMode() ? 'white' : '#202123' ) : 'currentColor' )}

function insertBtns() {
const chatbar = document.querySelector(chatbarSelector)
if (chatbar.contains(wideScreenBtn)) return // if buttons aren't missing, exit
const elemsToInsert = [newChatBtn, wideScreenBtn, fullWindowBtn, fullScreenBtn, tooltipDiv],
leftMostBtn = chatbar.querySelector('button' + ( site != 'poe' ? '[class*="right"]' : ''))
if (site == 'chatgpt') // allow tooltips to overflow
if (/chatgpt|openai/.test(site)) // allow tooltips to overflow
chatbar.classList.remove('overflow-hidden')
else if (site == 'poe') // elevate nested non-send button to chatbar
chatbar.insertBefore(leftMostBtn, chatbar.lastChild)
Expand Down Expand Up @@ -384,7 +384,7 @@

function updateTweaksStyle() {
tweaksStyle.innerText = (
site == 'chatgpt' ? (
/chatgpt|openai/.test(site) ? (
inputSelector + `{ padding-right: ${ config.ncbDisabled ? 126 : 152 }px }` // narrow input to accomodate btns
+ 'div.group > div > div > div > div:nth-child(2) { ' // move response paginator
+ 'position: relative ; left: 66px ; top: 7px } ' // ...below avatar to avoid cropping
Expand All @@ -396,7 +396,7 @@

function updateWidescreenStyle() {
wideScreenStyle.innerText = (
site == 'chatgpt' ? (
/chatgpt|openai/.test(site) ? (
'.text-base { max-width: 100% !important }' // widen outer container
+ '.text-base:nth-of-type(2) { max-width: 97% !important }' // widen inner container
+ '#__next > div > div.flex { width: 100px }' ) // prevent sidebar shrinking when zoomed
Expand Down
4 changes: 2 additions & 2 deletions chatgpt-widescreen/edge/extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"version": "2024.5.3",
"version": "2024.5.3.1",
"author": "Adam Lui",
"default_locale": "en",
"icons": {
Expand All @@ -20,7 +20,7 @@
"resources": ["lib/settings-utils.js", "lib/chatgpt.js"]
}],
"content_scripts": [{
"matches": ["https://chatgpt.com/*", "https://poe.com/*"],
"matches": ["https://chatgpt.com/*", "https://chat.openai.com/*", "https://poe.com/*"],
"js": ["content.js"]
}],
"background": { "service_worker": "background.js" }
Expand Down
Loading

0 comments on commit db3faaa

Please sign in to comment.