Skip to content

Commit 789fa98

Browse files
committed
Re-styled chatgpt.alert() border/transitions + hard-coded styles for futureproofing ↞ [auto-sync from https://github.com/KudoAI/chatgpt.js]
1 parent 9045979 commit 789fa98

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

starters/chrome/extension/lib/chatgpt.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const chatgpt = {
7676
modalMessage = document.createElement('p');
7777

7878
// Create/append/update modal style (if missing or outdated)
79-
const thisUpdated = 20231203; // datestamp of last edit for this file's `modalStyle`
79+
const thisUpdated = 1734685032942; // timestamp of last edit for this file's `modalStyle`
8080
let modalStyle = document.querySelector('#chatgpt-modal-style'); // try to select existing style
8181
if (!modalStyle || parseInt(modalStyle.getAttribute('last-updated'), 10) < thisUpdated) { // if missing or outdated
8282
if (!modalStyle) { // outright missing, create/id/attr/append it first
@@ -89,25 +89,29 @@ const chatgpt = {
8989

9090
// Background styles
9191
+ '.chatgpt-modal {'
92+
+ 'pointer-events: auto ;' // override any disabling from site modals (like guest login spam)
9293
+ 'position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;' // expand to full view-port
93-
+ 'background-color: rgba(67, 70, 72, 0) ;' // init dim bg but no opacity
94-
+ 'transition: background-color 0.05s ease ;' // speed to transition in show alert routine
94+
+ 'transition: background-color 0.25s ease !important ;' // speed to show bg dim
9595
+ 'display: flex ; justify-content: center ; align-items: center ; z-index: 9999 }' // align
9696

9797
// Alert styles
9898
+ '.chatgpt-modal > div {'
99-
+ 'opacity: 0 ; transform: translateX(-2px) translateY(5px) ; max-width: 75vw ; word-wrap: break-word ;'
100-
+ 'transition: opacity 0.1s cubic-bezier(.165,.84,.44,1), transform 0.2s cubic-bezier(.165,.84,.44,1) ;'
101-
+ `background-color: ${ scheme == 'dark' ? 'black' : 'white' } ;`
102-
+ ( scheme != 'dark' ? 'border: 1px solid rgba(0, 0, 0, 0.3) ;' : '' )
99+
+ 'opacity: 0 ;' // to fade-in
100+
+ `border: 1px solid ${ scheme == 'dark' ? 'white' : '#b5b5b5' };`
101+
+ `color: ${ scheme == 'dark' ? 'white' : 'black' };`
102+
+ `background-color: ${ scheme == 'dark' ? 'black' : 'white' };`
103+
+ 'transform: translateX(-3px) translateY(7px) ;' // offset to move-in from
104+
+ 'transition: opacity 0.65s cubic-bezier(.165,.84,.44,1),' // for fade-ins
105+
+ 'transform 0.55s cubic-bezier(.165,.84,.44,1) ;' // for move-ins
106+
+ 'max-width: 75vw ; word-wrap: break-word ;'
103107
+ 'padding: 20px ; margin: 12px 23px ; border-radius: 15px ; box-shadow: 0 30px 60px rgba(0, 0, 0, .12) ;'
104108
+ ' -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ; }'
105109
+ '.chatgpt-modal h2 { margin-bottom: 9px }'
106110
+ `.chatgpt-modal a { color: ${ scheme == 'dark' ? '#00cfff' : '#1e9ebb' }}`
107-
+ '.chatgpt-modal.animated > div { opacity: 1 ; transform: translateX(0) translateY(0) }'
108-
+ '@keyframes alert-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }'
109-
+ '50% { opacity: 0.25 ; transform: scale(1.05) }'
110-
+ '100% { opacity: 0 ; transform: scale(1.35) }}'
111+
+ '.chatgpt-modal.animated > div { z-index: 13456 ; opacity: 0.98 ; transform: translateX(0) translateY(0) }'
112+
+ '@keyframes alert-zoom-fade-out {'
113+
+ '0% { opacity: 1 } 50% { opacity: 0.25 ; transform: scale(1.05) }'
114+
+ '100% { opacity: 0 ; transform: scale(1.35) }}'
111115

112116
// Button styles
113117
+ '.modal-buttons { display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;'
@@ -221,10 +225,10 @@ const chatgpt = {
221225
modalContainer.style.display = 'none';
222226
if (alertQueue.length === 1) {
223227
modalContainer.style.display = '';
224-
setTimeout(() => { // delay non-0 opacity's for transition fx
225-
modalContainer.style.backgroundColor = (
226-
`rgba(67, 70, 72, ${ scheme === 'dark' ? 0.62 : 0.1 })`);
227-
modalContainer.classList.add('animated'); }, 100);
228+
setTimeout(() => { // dim bg
229+
modal.parentNode.style.backgroundColor = `rgba(67, 70, 72, ${ scheme == 'dark' ? 0.62 : 0.33 })`
230+
modal.parentNode.classList.add('animated')
231+
}, 100) // delay for transition fx
228232
}
229233

230234
// Define click/key handlers
@@ -251,7 +255,7 @@ const chatgpt = {
251255
// Define alert dismisser
252256
const dismissAlert = () => {
253257
modalContainer.style.backgroundColor = 'transparent';
254-
modal.style.animation = 'alert-zoom-fade-out 0.075s ease-out';
258+
modal.style.animation = 'alert-zoom-fade-out 0.135s ease-out';
255259
setTimeout(() => { // delay removal for fade-out
256260

257261
// Remove alert
@@ -270,7 +274,7 @@ const chatgpt = {
270274
}, 500);
271275
}
272276

273-
}, 50);
277+
}, 135);
274278
};
275279

276280
return modalContainer.id; // if assignment used

0 commit comments

Comments
 (0)