Skip to content

Commit 58aac6c

Browse files
committed
Separated toast styles to persist on master toggle-off
1 parent e253fcb commit 58aac6c

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

chatgpt-widescreen/chromium/extension/content.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
function getMsg(key) { return chrome.i18n.getMessage(key) }
5252

5353
function notify(msg, pos = '', notifDuration = '', shadow = '') {
54+
if (!styles.toast.node) styles.toast.update()
5455
if (config.notifDisabled && !new RegExp(`${getMsg('menuLabel_notifs')}|${getMsg('mode_toast')}`).test(msg))
5556
return
5657

@@ -158,7 +159,8 @@
158159
supressNotifs() ; toggleMode('fullWindow') }
159160
sync.fullerWin() // sync Fuller Windows
160161
}
161-
styles.tweaks.update() // sync HH/HF/TCB/NCB/BA/TM
162+
styles.tweaks.update() // sync HH/HF/TCB/NCB/BA
163+
styles.toast.update() // sync TM
162164
styles.chatbar.update() // sync WCB
163165
if (env.site != 'perplexity') chatbar.tweak() // update ChatGPT chatbar inner width or hack Poe btn pos
164166
buttons[config.btnsVisible ? 'insert' : 'remove']() // update button visibility

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

+13-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ window.styles = {
2222
(this.node ||= dom.create.style()).textContent = sites[env.site].selectors.sidebar + '{ display: none }' }
2323
},
2424

25+
toast: {
26+
update() { // auto-appends to <head>
27+
if (!this.node?.isConnected) document.head.append(this.node ||= dom.create.style())
28+
this.node.textContent = `
29+
${ !config.toastMode ? '' : // shrink/center notifs into toast bubbles
30+
`div.${app.slug}.chatgpt-notif {
31+
position: absolute ; left: 50% ; right: 21% !important ; text-align: center ;
32+
transform: translate(-50%, -50%) scale(0.6) !important }
33+
div.${app.slug}.chatgpt-notif > div.notif-close-btn {
34+
top: 18px ; right: 7px ; transform: scale(2) }` }`
35+
}
36+
},
37+
2538
tweaks: {
2639
update() { // auto-appends to <head>
2740
const { site } = env, { [site]: { selectors }} = sites;
@@ -43,12 +56,6 @@ window.styles = {
4356
${ config.btnAnimationsDisabled ? '' : // zoom chatbar buttons on hover
4457
`.${buttons.class} { will-change: transform } /* prevent wobble */
4558
.${buttons.class}:hover { transform: scale(${ site == 'poe' ? 1.15 : 1.285 }) }` }
46-
${ !config.toastMode ? '' : // shrink/center notifs into toast bubbles
47-
`div.${app.slug}.chatgpt-notif {
48-
position: absolute ; left: 50% ; right: 21% !important ; text-align: center ;
49-
transform: translate(-50%, -50%) scale(0.6) !important }
50-
div.${app.slug}.chatgpt-notif > div.notif-close-btn {
51-
top: 18px ; right: 7px ; transform: scale(2) }` }
5259
${ site == 'perplexity' ? // prevent overlay
5360
`.${buttons.class} { background: none !important }` : '' }
5461
${ config.blockSpamDisabled ? ''

chatgpt-widescreen/firefox/extension/content.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
function getMsg(key) { return chrome.i18n.getMessage(key) }
5252

5353
function notify(msg, pos = '', notifDuration = '', shadow = '') {
54+
if (!styles.toast.node) styles.toast.update()
5455
if (config.notifDisabled && !new RegExp(`${getMsg('menuLabel_notifs')}|${getMsg('mode_toast')}`).test(msg))
5556
return
5657

@@ -158,7 +159,8 @@
158159
supressNotifs() ; toggleMode('fullWindow') }
159160
sync.fullerWin() // sync Fuller Windows
160161
}
161-
styles.tweaks.update() // sync HH/HF/TCB/NCB/BA/TM
162+
styles.tweaks.update() // sync HH/HF/TCB/NCB/BA
163+
styles.toast.update() // sync TM
162164
styles.chatbar.update() // sync WCB
163165
if (env.site != 'perplexity') chatbar.tweak() // update ChatGPT chatbar inner width or hack Poe btn pos
164166
buttons[config.btnsVisible ? 'insert' : 'remove']() // update button visibility

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

+13-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ window.styles = {
2222
(this.node ||= dom.create.style()).textContent = sites[env.site].selectors.sidebar + '{ display: none }' }
2323
},
2424

25+
toast: {
26+
update() { // auto-appends to <head>
27+
if (!this.node?.isConnected) document.head.append(this.node ||= dom.create.style())
28+
this.node.textContent = `
29+
${ !config.toastMode ? '' : // shrink/center notifs into toast bubbles
30+
`div.${app.slug}.chatgpt-notif {
31+
position: absolute ; left: 50% ; right: 21% !important ; text-align: center ;
32+
transform: translate(-50%, -50%) scale(0.6) !important }
33+
div.${app.slug}.chatgpt-notif > div.notif-close-btn {
34+
top: 18px ; right: 7px ; transform: scale(2) }` }`
35+
}
36+
},
37+
2538
tweaks: {
2639
update() { // auto-appends to <head>
2740
const { site } = env, { [site]: { selectors }} = sites;
@@ -43,12 +56,6 @@ window.styles = {
4356
${ config.btnAnimationsDisabled ? '' : // zoom chatbar buttons on hover
4457
`.${buttons.class} { will-change: transform } /* prevent wobble */
4558
.${buttons.class}:hover { transform: scale(${ site == 'poe' ? 1.15 : 1.285 }) }` }
46-
${ !config.toastMode ? '' : // shrink/center notifs into toast bubbles
47-
`div.${app.slug}.chatgpt-notif {
48-
position: absolute ; left: 50% ; right: 21% !important ; text-align: center ;
49-
transform: translate(-50%, -50%) scale(0.6) !important }
50-
div.${app.slug}.chatgpt-notif > div.notif-close-btn {
51-
top: 18px ; right: 7px ; transform: scale(2) }` }
5259
${ site == 'perplexity' ? // prevent overlay
5360
`.${buttons.class} { background: none !important }` : '' }
5461
${ config.blockSpamDisabled ? ''

0 commit comments

Comments
 (0)