Skip to content

Commit 9e737df

Browse files
committed
Condensed elem replacement routines ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/googlegpt]
1 parent eeefdea commit 9e737df

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

chatgpt/googlegpt/googlegpt.user.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
// @description:zu Yengeza izimpendulo ze-AI ku-Google Search (inikwa amandla yi-Google Gemma + GPT-4o!)
150150
// @author KudoAI
151151
// @namespace https://kudoai.com
152-
// @version 2025.3.3
152+
// @version 2025.3.3.1
153153
// @license MIT
154154
// @icon https://assets.googlegpt.io/images/icons/googlegpt/black/icon48.png?v=59409b2
155155
// @icon64 https://assets.googlegpt.io/images/icons/googlegpt/black/icon64.png?v=59409b2
@@ -981,8 +981,7 @@
981981

982982
// Replace link buttons w/ clones that don't dismiss modal
983983
if (/support|discuss|extensions/i.test(btn.textContent)) {
984-
const btnClone = btn.cloneNode(true)
985-
btn.parentNode.replaceChild(btnClone, btn) ; btn = btnClone
984+
btn.replaceWith(btn = btn.cloneNode(true))
986985
btn.onclick = () => modals.safeWinOpen(app.urls[
987986
btn.textContent.includes(app.msgs.btnLabel_getSupport) ? 'support'
988987
: btn.textContent.includes(app.msgs.btnLabel_discuss) ? 'discuss' : 'relatedExtensions' ])
@@ -1175,10 +1174,9 @@
11751174
schemeModal.querySelector('h2').style.justifySelf = 'center'
11761175
schemeModal.querySelector('.modal-buttons').style.cssText = 'justify-content: center ; margin: 20px 0 9px !important'
11771176

1178-
// Re-format each button
1179-
const buttons = schemeModal.querySelectorAll('button'),
1180-
schemeEmojis = { 'light': '☀️', 'dark': '🌘', 'auto': '🌗'}
1181-
for (const btn of buttons) {
1177+
// Hack buttons
1178+
const schemeEmojis = { 'light': '☀️', 'dark': '🌘', 'auto': '🌗'}
1179+
schemeModal.querySelectorAll('button').forEach(btn => {
11821180
const btnScheme = btn.textContent.toLowerCase()
11831181

11841182
// Emphasize active scheme
@@ -1194,19 +1192,19 @@
11941192
else btn.style.display = 'none' // hide Dismiss button
11951193

11961194
// Clone button to replace listener to not dismiss modal on click
1197-
const newBtn = btn.cloneNode(true) ; btn.parentNode.replaceChild(newBtn, btn)
1198-
newBtn.onclick = () => {
1195+
btn.replaceWith(btn = btn.cloneNode(true))
1196+
btn.onclick = () => {
11991197
const newScheme = btnScheme == 'auto' ? getScheme() : btnScheme
12001198
settings.save('scheme', btnScheme == 'auto' ? false : newScheme)
12011199
schemeModal.querySelectorAll('button').forEach(btn =>
12021200
btn.classList = '') // clear prev emphasized active scheme
1203-
newBtn.classList = 'primary-modal-btn' // emphasize newly active scheme
1204-
newBtn.style.cssText = 'pointer-events: none' // disable hover fx to show emphasis
1205-
setTimeout(() => { newBtn.style.pointerEvents = 'auto' }, // re-enable hover fx
1201+
btn.classList = 'primary-modal-btn' // emphasize newly active scheme
1202+
btn.style.cssText = 'pointer-events: none' // disable hover fx to show emphasis
1203+
setTimeout(() => { btn.style.pointerEvents = 'auto' }, // re-enable hover fx
12061204
100) // ...after 100ms to flicker emphasis
12071205
update.scheme(newScheme) ; schemeNotify(btnScheme)
12081206
}
1209-
}
1207+
})
12101208

12111209
log.debug('Success! Scheme modal shown')
12121210

@@ -4117,10 +4115,10 @@
41174115
: copyBtn.parentNode.parentNode ) // code container
41184116
const textToCopy = textContainer.textContent.replace(/^>> /, '').trim()
41194117
copyBtn.style.cursor = 'default' // remove finger
4120-
copyBtn.replaceChild(copySVGs.copied, copySVGs.copy) // change to Copied icon
4118+
copySVGs.copy.replaceWith(copySVGs.copied) // change to Copied icon
41214119
toggle.tooltip(event) // update tooltip
41224120
setTimeout(() => { // restore icon/cursor/tooltip after a bit
4123-
copyBtn.replaceChild(copySVGs.copy, copySVGs.copied)
4121+
copySVGs.copied.replaceWith(copySVGs.copy)
41244122
copyBtn.style.cursor = 'pointer' ; copyBtn.dispatchEvent(new Event('mouseenter'))
41254123
}, 1355)
41264124
navigator.clipboard.writeText(textToCopy) // copy text to clipboard

0 commit comments

Comments
 (0)