Skip to content

Commit 2649ac9

Browse files
committed
Condensed elem replacement routines ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/bravegpt]
1 parent a8935da commit 2649ac9

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

chatgpt/bravegpt/bravegpt.user.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
// @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!)
149149
// @author KudoAI
150150
// @namespace https://kudoai.com
151-
// @version 2025.3.3
151+
// @version 2025.3.3.1
152152
// @license MIT
153153
// @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0
154154
// @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0
@@ -796,8 +796,7 @@
796796

797797
// Replace link buttons w/ clones that don't dismiss modal
798798
if (/support|extensions/i.test(btn.textContent)) {
799-
const btnClone = btn.cloneNode(true)
800-
btn.parentNode.replaceChild(btnClone, btn) ; btn = btnClone
799+
btn.replaceWith(btn = btn.cloneNode(true))
801800
btn.onclick = () => modals.safeWinOpen(app.urls[
802801
btn.textContent.includes(app.msgs.btnLabel_getSupport) ? 'support' : 'relatedExtensions' ])
803802
}
@@ -854,8 +853,7 @@
854853
btn.style.marginTop = btn.style.marginBottom = '5px' // v-pad btns
855854

856855
// Replace buttons w/ clones that don't dismiss modal
857-
const btnClone = btn.cloneNode(true)
858-
btn.parentNode.replaceChild(btnClone, btn) ; btn = btnClone
856+
btn.replaceWith(btn = btn.cloneNode(true))
859857
btn.onclick = () => modals.safeWinOpen(
860858
btn.textContent == 'Product Hunt' ? app.urls.review.productHunt
861859
: btn.textContent == 'Alternativeto' ? app.urls.review.alternativeTo
@@ -1031,10 +1029,9 @@
10311029
schemeModal.querySelector('.modal-buttons')
10321030
.style.cssText = 'justify-content: center ; margin: 18px 0 14px !important'
10331031

1034-
// Re-format each button
1035-
const buttons = schemeModal.querySelectorAll('button'),
1036-
schemeEmojis = { 'light': '☀️', 'dark': '🌘', 'auto': '🌗'}
1037-
for (const btn of buttons) {
1032+
// Hack buttons
1033+
const schemeEmojis = { 'light': '☀️', 'dark': '🌘', 'auto': '🌗'}
1034+
schemeModal.querySelectorAll('button').forEach(btn => {
10381035
const btnScheme = btn.textContent.toLowerCase()
10391036

10401037
// Emphasize active scheme
@@ -1050,19 +1047,19 @@
10501047
else btn.style.display = 'none' // hide Dismiss button
10511048

10521049
// Clone button to replace listener to not dismiss modal on click
1053-
const newBtn = btn.cloneNode(true) ; btn.parentNode.replaceChild(newBtn, btn)
1054-
newBtn.onclick = () => {
1050+
btn.replaceWith(btn = btn.cloneNode(true))
1051+
btn.onclick = () => {
10551052
const newScheme = btnScheme == 'auto' ? getScheme() : btnScheme
10561053
settings.save('scheme', btnScheme == 'auto' ? false : newScheme)
10571054
schemeModal.querySelectorAll('button').forEach(btn =>
10581055
btn.classList = '') // clear prev emphasized active scheme
1059-
newBtn.classList = 'primary-modal-btn' // emphasize newly active scheme
1060-
newBtn.style.cssText = 'pointer-events: none' // disable hover fx to show emphasis
1061-
setTimeout(() => { newBtn.style.pointerEvents = 'auto' }, // re-enable hover fx
1056+
btn.classList = 'primary-modal-btn' // emphasize newly active scheme
1057+
btn.style.cssText = 'pointer-events: none' // disable hover fx to show emphasis
1058+
setTimeout(() => { btn.style.pointerEvents = 'auto' }, // re-enable hover fx
10621059
100) // ...after 100ms to flicker emphasis
10631060
update.scheme(newScheme) ; schemeNotify(btnScheme)
10641061
}
1065-
}
1062+
})
10661063

10671064
log.debug('Success! Scheme modal shown')
10681065

@@ -3938,10 +3935,10 @@
39383935
: copyBtn.parentNode.parentNode ) // code container
39393936
const textToCopy = textContainer.textContent.replace(/^>> /, '').trim()
39403937
copyBtn.style.cursor = 'default' // remove finger
3941-
copyBtn.replaceChild(copySVGs.copied, copySVGs.copy) // change to Copied icon
3938+
copySVGs.copy.replaceWith(copySVGs.copied) // change to Copied icon
39423939
toggle.tooltip(event) // update tooltip
39433940
setTimeout(() => { // restore icon/cursor/tooltip after a bit
3944-
copyBtn.replaceChild(copySVGs.copy, copySVGs.copied)
3941+
copySVGs.copied.replaceWith(copySVGs.copy)
39453942
copyBtn.style.cursor = 'pointer' ; copyBtn.dispatchEvent(new Event('mouseenter'))
39463943
}, 1355)
39473944
navigator.clipboard.writeText(textToCopy) // copy text to clipboard

0 commit comments

Comments
 (0)