Skip to content

Commit 4deb39a

Browse files
committed
Moved div/style inits from tooltip.update().toggle() + changed mouse<over|out> to mouse<enter|leave>` to align w/ KudoAI scripts for easier maintenance, condensed opacity update
1 parent 8f7cbb1 commit 4deb39a

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

chatgpt-widescreen/chromium/extension/components/buttons.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ window.buttons = {
8888
}
8989

9090
// Add hover/click listeners
91-
btn.onmouseover = btn.onmouseout = tooltip.toggle
91+
btn.onmouseenter = btn.onmouseleave = tooltip.toggle
9292
btn.onclick = () => {
9393
if (btnType == 'newChat') {
9494
document.querySelector(this.imports.sites[site].selectors.btns.newChat)?.click()
@@ -100,8 +100,8 @@ window.buttons = {
100100
tooltip.div.style.opacity = 0;
101101
['fullWindow', 'fullscreen'].forEach(btnType => {
102102
const btn = this[btnType]
103-
btn.onmouseover = btn.onmouseout = null
104-
setTimeout(() => btn.onmouseover = btn.onmouseout = tooltip.toggle, 300)
103+
btn.onmouseenter = btn.onmouseleave = null
104+
setTimeout(() => btn.onmouseenter = btn.onmouseleave = tooltip.toggle, 300)
105105
})
106106
}
107107
}

chatgpt-widescreen/chromium/extension/components/tooltip.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ window.tooltip = {
2626
},
2727

2828
toggle(event) {
29+
if (!tooltip.div) tooltip.div = dom.create.elem('div', { class: 'cwm-tooltip' })
30+
if (!tooltip.div.isConnected) event.currentTarget?.before(tooltip.div)
31+
if (!tooltip.styles) tooltip.stylize()
2932
tooltip.update(event.currentTarget.id.replace(/-btn$/, ''))
30-
tooltip.div.style.opacity = event.type == 'mouseover' ? 1 : 0
33+
tooltip.div.style.opacity = +(event.type == 'mouseenter')
3134
},
3235

3336
async update(btnType) { // text & position
34-
if (!tooltip.div) tooltip.div = dom.create.elem('div', { class: 'cwm-tooltip' })
35-
if (!tooltip.div.isConnected) buttons[btnType]?.before(tooltip.div)
36-
if (!tooltip.styles) tooltip.stylize()
37+
if (!this.div) return // since nothing to update
3738
const site = this.imports.env.site
3839
const rects = {
3940
btn: buttons[btnType]?.getBoundingClientRect(), chatbar: (await chatbar.get())?.getBoundingClientRect() }

chatgpt-widescreen/firefox/extension/components/buttons.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ window.buttons = {
8888
}
8989

9090
// Add hover/click listeners
91-
btn.onmouseover = btn.onmouseout = tooltip.toggle
91+
btn.onmouseenter = btn.onmouseleave = tooltip.toggle
9292
btn.onclick = () => {
9393
if (btnType == 'newChat') {
9494
document.querySelector(this.imports.sites[site].selectors.btns.newChat)?.click()
@@ -100,8 +100,8 @@ window.buttons = {
100100
tooltip.div.style.opacity = 0;
101101
['fullWindow', 'fullscreen'].forEach(btnType => {
102102
const btn = this[btnType]
103-
btn.onmouseover = btn.onmouseout = null
104-
setTimeout(() => btn.onmouseover = btn.onmouseout = tooltip.toggle, 300)
103+
btn.onmouseenter = btn.onmouseleave = null
104+
setTimeout(() => btn.onmouseenter = btn.onmouseleave = tooltip.toggle, 300)
105105
})
106106
}
107107
}

chatgpt-widescreen/firefox/extension/components/tooltip.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ window.tooltip = {
2626
},
2727

2828
toggle(event) {
29+
if (!tooltip.div) tooltip.div = dom.create.elem('div', { class: 'cwm-tooltip' })
30+
if (!tooltip.div.isConnected) event.currentTarget?.before(tooltip.div)
31+
if (!tooltip.styles) tooltip.stylize()
2932
tooltip.update(event.currentTarget.id.replace(/-btn$/, ''))
30-
tooltip.div.style.opacity = event.type == 'mouseover' ? 1 : 0
33+
tooltip.div.style.opacity = +(event.type == 'mouseenter')
3134
},
3235

3336
async update(btnType) { // text & position
34-
if (!tooltip.div) tooltip.div = dom.create.elem('div', { class: 'cwm-tooltip' })
35-
if (!tooltip.div.isConnected) buttons[btnType]?.before(tooltip.div)
36-
if (!tooltip.styles) tooltip.stylize()
37+
if (!this.div) return // since nothing to update
3738
const site = this.imports.env.site
3839
const rects = {
3940
btn: buttons[btnType]?.getBoundingClientRect(), chatbar: (await chatbar.get())?.getBoundingClientRect() }

0 commit comments

Comments
 (0)