Skip to content

Commit 05601b9

Browse files
committed
Added replace Plus icon of Poe Attach File button w/ Paperclip to not confuse w/ my New Chat button ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/chatgpt-widescreen]
1 parent a659911 commit 05601b9

File tree

10 files changed

+58
-16
lines changed

10 files changed

+58
-16
lines changed

chromium/extension/components/icons.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ window.icons = {
2929
]
3030
},
3131

32+
paperclip: {
33+
type: 'svg', viewBox: '0 0 448 512',
34+
elems: [
35+
[ 'path', { d: 'M375 73c-26-26-68.1-26-94.1 0L89 265C45.3 308.6 45.3 379.4 89 423s114.4 43.6 158.1 0L399 271c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L281 457c-62.4 62.4-163.5 62.4-225.9 0S-7.4 293.4 55 231L247 39C291.7-5.7 364.3-5.7 409 39s44.7 117.2 0 161.9L225.2 384.7c-31.6 31.6-83.6 28.7-111.5-6.2c-23.8-29.8-21.5-72.8 5.5-99.8L271 127c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L153.2 312.7c-9.7 9.7-10.6 25.1-2 35.8c10 12.5 28.7 13.6 40 2.2L375 167c26-26 26-68.1 0-94.1z' }]
36+
]
37+
},
38+
3239
plus: {
3340
type: 'svg', viewBox: '0 0 1024 1024',
3441
elems: [

chromium/extension/content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// Import JS resources
2525
for (const resource of [
2626
'lib/chatbar.js', 'lib/chatgpt.js', 'lib/dom.js', 'lib/settings.js', 'lib/ui.js',
27-
'components/buttons.js', 'components/modals.js', 'components/tooltip.js'
27+
'components/buttons.js', 'components/icons.js', 'components/modals.js', 'components/tooltip.js'
2828
]) await import(chrome.runtime.getURL(resource))
2929

3030
// Init ENV context

chromium/extension/lib/chatbar.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Requires lib/dom.js + components/buttons.js + site: env.site + sites
1+
// Requires lib/dom.js + components/<buttons|icons>.js + site: env.site + sites
22

33
window.chatbar = {
44
import(deps) { Object.assign(this.imports = this.imports || {}, deps) },
@@ -36,13 +36,19 @@ window.chatbar = {
3636
})
3737
chatbarDiv.querySelector('button').closest('div').style.marginRight = '' // reset gap
3838
}
39-
} else if (site == 'poe') { // restore Poe Mic button position
39+
} else if (site == 'poe') { // restore Attach File button icon + Poe Mic button position
40+
['attachFile', 'mic'].forEach(btnType => {
41+
const btn = chatbarDiv.querySelector(selectors.btns[btnType]) ; if (!btn) return
42+
if (btnType == 'attachFile')
43+
btn.querySelector('svg').replaceWith(buttons.poe.attachFile.icon.cloneNode(true))
44+
else /* Mic */ btn.style.marginRight = ''
45+
})
4046
const micBtn = chatbarDiv.querySelector(selectors.btns.mic) ; if (!micBtn) return
4147
micBtn.style.marginRight = ''
4248
}
4349
},
4450

45-
async tweak() { // update ChatGPT chatbar inner width or left-align Perplexity btns or move Poe Mic btn right
51+
async tweak() { // update ChatGPT chatbar inner width or hack Perplexity/Poe buttons
4652
const site = this.imports.site
4753
const chatbarDiv = await this.get() ; if (!chatbarDiv) return
4854
const selectors = this.imports.sites[site].selectors
@@ -72,8 +78,16 @@ window.chatbar = {
7278
btn.setAttribute('left-aligned', true) // for this.reset()
7379
})
7480
if (chatbarDiv.querySelector('[left-aligned]')) modelSelectorDiv.style.marginRight = '3px' // close gap
75-
} else if (site == 'poe') // move Mic btn closer to Send
76-
dom.get.loadedElem(selectors.btns.mic, { timeout: 5000 })
81+
} else if (site == 'poe') { // replace Attach File btn icon + move Mic btn closer to Send
82+
const btnLoadTimeout = 5000
83+
dom.get.loadedElem(selectors.btns.attachFile, { timeout: btnLoadTimeout }).then(btn => {
84+
if (!btn) return
85+
buttons.poe = buttons.poe || { attachFile: { icon: btn.querySelector('svg') }}
86+
btn.querySelector('svg').replaceWith(icons.create('paperclip', {
87+
style: 'height: 15px !important ; width: 15px !important' }))
88+
})
89+
dom.get.loadedElem(selectors.btns.mic, { timeout: btnLoadTimeout })
7790
.then(btn => { if (btn) btn.style.marginRight = '-7px' })
91+
}
7892
}
7993
};

chromium/extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"web_accessible_resources": [{
2020
"matches": [ "<all_urls>" ],
2121
"resources": [
22-
"components/buttons.js", "components/modals.js", "components/tooltip.js",
22+
"components/buttons.js", "components/icons.js", "components/modals.js", "components/tooltip.js",
2323
"lib/chatbar.js", "lib/chatgpt.js", "lib/dom.js", "lib/settings.js", "lib/ui.js"
2424
]
2525
}],

chromium/extension/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ chrome.runtime.onMessage.addListener(async req => {
3232
// Init APP data
3333
const app = {
3434
version: chrome.runtime.getManifest().version,
35-
latestResourceCommitHash: '1eba036', // for cached app.json + sites.json5 + icons.questionMark.src
35+
latestResourceCommitHash: 'a659911', // for cached app.json + sites.json5 + icons.questionMark.src
3636
urls: {},
3737
chatgptJSver: /v(\d+\.\d+\.\d+)/.exec(await (await fetch(chrome.runtime.getURL('lib/chatgpt.js'))).text())[1]
3838
}

firefox/extension/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ chrome.runtime.onMessage.addListener(async req => {
3232
// Init APP data
3333
const app = {
3434
version: chrome.runtime.getManifest().version,
35-
latestResourceCommitHash: '1eba036', // for cached app.json + sites.json5 + icons.questionMark.src
35+
latestResourceCommitHash: 'a659911', // for cached app.json + sites.json5 + icons.questionMark.src
3636
urls: {},
3737
chatgptJSver: /v(\d+\.\d+\.\d+)/.exec(await (await fetch(chrome.runtime.getURL('lib/chatgpt.js'))).text())[1]
3838
}

firefox/extension/components/icons.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ window.icons = {
2929
]
3030
},
3131

32+
paperclip: {
33+
type: 'svg', viewBox: '0 0 448 512',
34+
elems: [
35+
[ 'path', { d: 'M375 73c-26-26-68.1-26-94.1 0L89 265C45.3 308.6 45.3 379.4 89 423s114.4 43.6 158.1 0L399 271c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L281 457c-62.4 62.4-163.5 62.4-225.9 0S-7.4 293.4 55 231L247 39C291.7-5.7 364.3-5.7 409 39s44.7 117.2 0 161.9L225.2 384.7c-31.6 31.6-83.6 28.7-111.5-6.2c-23.8-29.8-21.5-72.8 5.5-99.8L271 127c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L153.2 312.7c-9.7 9.7-10.6 25.1-2 35.8c10 12.5 28.7 13.6 40 2.2L375 167c26-26 26-68.1 0-94.1z' }]
36+
]
37+
},
38+
3239
plus: {
3340
type: 'svg', viewBox: '0 0 1024 1024',
3441
elems: [

firefox/extension/content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// Import JS resources
2525
for (const resource of [
2626
'lib/chatbar.js', 'lib/chatgpt.js', 'lib/dom.js', 'lib/settings.js', 'lib/ui.js',
27-
'components/buttons.js', 'components/modals.js', 'components/tooltip.js'
27+
'components/buttons.js', 'components/icons.js', 'components/modals.js', 'components/tooltip.js'
2828
]) await import(chrome.runtime.getURL(resource))
2929

3030
// Init ENV context

firefox/extension/lib/chatbar.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Requires lib/dom.js + components/buttons.js + site: env.site + sites
1+
// Requires lib/dom.js + components/<buttons|icons>.js + site: env.site + sites
22

33
window.chatbar = {
44
import(deps) { Object.assign(this.imports = this.imports || {}, deps) },
@@ -36,13 +36,19 @@ window.chatbar = {
3636
})
3737
chatbarDiv.querySelector('button').closest('div').style.marginRight = '' // reset gap
3838
}
39-
} else if (site == 'poe') { // restore Poe Mic button position
39+
} else if (site == 'poe') { // restore Attach File button icon + Poe Mic button position
40+
['attachFile', 'mic'].forEach(btnType => {
41+
const btn = chatbarDiv.querySelector(selectors.btns[btnType]) ; if (!btn) return
42+
if (btnType == 'attachFile')
43+
btn.querySelector('svg').replaceWith(buttons.poe.attachFile.icon.cloneNode(true))
44+
else /* Mic */ btn.style.marginRight = ''
45+
})
4046
const micBtn = chatbarDiv.querySelector(selectors.btns.mic) ; if (!micBtn) return
4147
micBtn.style.marginRight = ''
4248
}
4349
},
4450

45-
async tweak() { // update ChatGPT chatbar inner width or left-align Perplexity btns or move Poe Mic btn right
51+
async tweak() { // update ChatGPT chatbar inner width or hack Perplexity/Poe buttons
4652
const site = this.imports.site
4753
const chatbarDiv = await this.get() ; if (!chatbarDiv) return
4854
const selectors = this.imports.sites[site].selectors
@@ -72,8 +78,16 @@ window.chatbar = {
7278
btn.setAttribute('left-aligned', true) // for this.reset()
7379
})
7480
if (chatbarDiv.querySelector('[left-aligned]')) modelSelectorDiv.style.marginRight = '3px' // close gap
75-
} else if (site == 'poe') // move Mic btn closer to Send
76-
dom.get.loadedElem(selectors.btns.mic, { timeout: 5000 })
81+
} else if (site == 'poe') { // replace Attach File btn icon + move Mic btn closer to Send
82+
const btnLoadTimeout = 5000
83+
dom.get.loadedElem(selectors.btns.attachFile, { timeout: btnLoadTimeout }).then(btn => {
84+
if (!btn) return
85+
buttons.poe = buttons.poe || { attachFile: { icon: btn.querySelector('svg') }}
86+
btn.querySelector('svg').replaceWith(icons.create('paperclip', {
87+
style: 'height: 15px !important ; width: 15px !important' }))
88+
})
89+
dom.get.loadedElem(selectors.btns.mic, { timeout: btnLoadTimeout })
7790
.then(btn => { if (btn) btn.style.marginRight = '-7px' })
91+
}
7892
}
7993
};

firefox/extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"web_accessible_resources": [{
2020
"matches": [ "<all_urls>" ],
2121
"resources": [
22-
"components/buttons.js", "components/modals.js", "components/tooltip.js",
22+
"components/buttons.js", "components/icons.js", "components/modals.js", "components/tooltip.js",
2323
"lib/chatbar.js", "lib/chatgpt.js", "lib/dom.js", "lib/settings.js", "lib/ui.js"
2424
]
2525
}],

0 commit comments

Comments
 (0)