Skip to content

Commit 29f21d4

Browse files
committed
Replaced array.from() w/ shorter spread syntax
1 parent 028d611 commit 29f21d4

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

chatgpt.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ const chatgpt = {
648648
const msgs = [] ; let isUserMsg = true
649649
chatDivs.forEach(div => {
650650
const sender = isUserMsg ? 'USER' : 'CHATGPT'; isUserMsg = !isUserMsg
651-
const msg = Array.from(div.childNodes).map(node => node.innerText)
651+
const msg = [...div.childNodes].map(node => node.innerText)
652652
.join('\n\n') // insert double line breaks between paragraphs
653653
.replace('Copy code', '')
654654
msgs.push(`${sender}: ${msg}`)
@@ -1498,7 +1498,7 @@ const chatgpt = {
14981498
// Process text node
14991499
if (childNode.nodeType == Node.TEXT_NODE) {
15001500
const text = childNode.nodeValue,
1501-
elems = Array.from(text.matchAll(reTags))
1501+
elems = [...text.matchAll(reTags])
15021502

15031503
// Process 1st element to render
15041504
if (elems.length > 0) {
@@ -1507,7 +1507,7 @@ const chatgpt = {
15071507
tagNode = document.createElement(tagName) ; tagNode.textContent = tagText
15081508

15091509
// Extract/set attributes
1510-
const attrs = Array.from(tagAttrs.matchAll(reAttrs))
1510+
const attrs = [...tagAttrs.matchAll(reAttrs])
15111511
attrs.forEach(attr => {
15121512
const name = attr[1], value = attr[2].replace(/['"]/g, '')
15131513
tagNode.setAttribute(name, value)

0 commit comments

Comments
 (0)