Skip to content

Commit ca18527

Browse files
committed
Replaced Element.innerText assignments w/ faster .textContent
1 parent 8913398 commit ca18527

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

chatgpt.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const chatgpt = {
181181
modalStyle.setAttribute('last-updated', thisUpdated.toString())
182182
document.head.append(modalStyle)
183183
}
184-
modalStyle.innerText = ( // update prev/new style contents
184+
modalStyle.textContent = ( // update prev/new style contents
185185
`.chatgpt-modal { /* vars */
186186
--transition: opacity 0.65s cubic-bezier(.165,.84,.44,1), /* for fade-in */
187187
transform 0.55s cubic-bezier(.165,.84,.44,1) ; /* for move-in */
@@ -271,7 +271,7 @@ const chatgpt = {
271271
}
272272

273273
// Insert text into elems
274-
modalTitle.innerText = title || '' ; modalMessage.innerText = msg || '' ; chatgpt.renderHTML(modalMessage)
274+
modalTitle.textContent = title || '' ; modalMessage.textContent = msg || '' ; chatgpt.renderHTML(modalMessage)
275275

276276
// Create/append buttons (if provided) to buttons div
277277
const modalButtons = document.createElement('div')
@@ -1300,7 +1300,7 @@ const chatgpt = {
13001300
const notificationDiv = document.createElement('div') // make div
13011301
notificationDiv.id = Math.floor(chatgpt.randomFloat() * 1000000) + Date.now()
13021302
notificationDiv.classList.add('chatgpt-notif')
1303-
notificationDiv.innerText = msg // insert msg
1303+
notificationDiv.textContent = msg // insert msg
13041304
document.body.append(notificationDiv) // insert into DOM
13051305

13061306
// Create/append close button
@@ -1333,7 +1333,7 @@ const chatgpt = {
13331333
notifStyle.setAttribute('last-updated', thisUpdated.toString())
13341334
document.head.append(notifStyle)
13351335
}
1336-
notifStyle.innerText = ( // update prev/new style contents
1336+
notifStyle.textContent = ( // update prev/new style contents
13371337
'.chatgpt-notif {'
13381338
+ 'font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",'
13391339
+ '"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif ;'

docs/assets/js/src/onload-hacks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const iObserver = new IntersectionObserver(entries => entries.forEach(entry => {
3737
// Reset colors
3838
document.querySelector('#kudoai a').style.color = 'white'
3939
window.starColor = 'white';
40-
(document.querySelector('#scrollbar-style') || {}).innerText = (
40+
(document.querySelector('#scrollbar-style') || {}).textContent = (
4141
':root { scrollbar-color: rgb(210,210,210) #1a1a1a }'
4242
+ 'body::-webkit-scrollbar-thumb { background-color: white }')
4343

@@ -279,12 +279,12 @@ const onLoadObserver = new MutationObserver(() => {
279279
scrollbarStyle.setAttribute('id', 'scrollbar-style')
280280
document.head.append(scrollbarStyle)
281281
}
282-
scrollbarStyle.innerText = (
282+
scrollbarStyle.textContent = (
283283
`:root { scrollbar-color: ${ sectionColor } #1a1a1a }`
284284
+ `body::-webkit-scrollbar-thumb { background-color: ${ sectionColor } }`)
285285
setTimeout(() => { // schedule color reset
286286
if (window.starVelocity.z <= iniStarZvelocity) {
287-
scrollbarStyle.innerText = (
287+
scrollbarStyle.textContent = (
288288
':root { scrollbar-color: rgb(210,210,210) #1a1a1a }'
289289
+ 'body::-webkit-scrollbar-thumb { background-color: white }')
290290
}}, warpDuration + 5)

0 commit comments

Comments
 (0)