From 556c737991c9ec1d4e203ea1837dbe77fecb8b1f Mon Sep 17 00:00:00 2001 From: "adamlui@protonmail.com" Date: Thu, 21 Nov 2024 15:09:17 -0800 Subject: [PATCH] Stripped trailing whitespace --- chatgpt.js | 44 +++++++++---------- docs/assets/js/src/back-to-top-button.js | 6 +-- docs/assets/js/src/onload-hacks.js | 36 +++++++-------- docs/assets/js/src/starry-background.js | 10 ++--- starters/chrome/extension/components/icons.js | 2 +- starters/chrome/extension/content.js | 2 +- starters/chrome/extension/lib/chatgpt.js | 44 +++++++++---------- starters/chrome/extension/popup/controller.js | 4 +- 8 files changed, 74 insertions(+), 74 deletions(-) diff --git a/chatgpt.js b/chatgpt.js index e759afd73..11dcf534c 100644 --- a/chatgpt.js +++ b/chatgpt.js @@ -76,7 +76,7 @@ const chatgpt = { modalMessage = document.createElement('p'); // Create/append/update modal style (if missing or outdated) - const thisUpdated = 20231203; // datestamp of last edit for this file's `modalStyle` + const thisUpdated = 20231203; // datestamp of last edit for this file's `modalStyle` let modalStyle = document.querySelector('#chatgpt-modal-style'); // try to select existing style if (!modalStyle || parseInt(modalStyle.getAttribute('last-updated'), 10) < thisUpdated) { // if missing or outdated if (!modalStyle) { // outright missing, create/id/attr/append it first @@ -88,7 +88,7 @@ const chatgpt = { '.no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }' // Background styles - + '.chatgpt-modal {' + + '.chatgpt-modal {' + 'position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;' // expand to full view-port + 'background-color: rgba(67, 70, 72, 0) ;' // init dim bg but no opacity + 'transition: background-color 0.05s ease ;' // speed to transition in show alert routine @@ -140,7 +140,7 @@ const chatgpt = { + `border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' } ;` + 'background-color: black ; position: inherit }' + '.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }' - ); + ); } // Insert text into elements @@ -210,7 +210,7 @@ const chatgpt = { const modalElems = [closeBtn, modalTitle, modalMessage, modalButtons, checkboxDiv]; modalElems.forEach((elem) => { modal.append(elem); }); modal.style.width = `${ width || 458 }px`; - modalContainer.append(modal); document.body.append(modalContainer); + modalContainer.append(modal); document.body.append(modalContainer); // Enqueue alert let alertQueue = JSON.parse(localStorage.alertQueue); @@ -222,7 +222,7 @@ const chatgpt = { if (alertQueue.length === 1) { modalContainer.style.display = ''; setTimeout(() => { // delay non-0 opacity's for transition fx - modalContainer.style.backgroundColor = ( + modalContainer.style.backgroundColor = ( `rgba(67, 70, 72, ${ scheme === 'dark' ? 0.62 : 0.1 })`); modalContainer.classList.add('animated'); }, 100); } @@ -557,7 +557,7 @@ const chatgpt = { .replace('Copy code', ''); msgs.push(sender + ': ' + msg); }); - transcript = msgs.join('\n\n'); + transcript = msgs.join('\n\n'); // ...or from getChatData(chatToGet) } else { @@ -623,7 +623,7 @@ const chatgpt = { footer: { get() { return document.querySelector('main form')?.parentNode.parentNode.nextElementSibling; }, - hide() { + hide() { const footer = chatgpt.footer.get(); if (!footer) return console.error('Footer element not found!'); if (footer.style.visibility == 'hidden') return console.info('Footer already hidden!'); @@ -634,7 +634,7 @@ const chatgpt = { const footer = chatgpt.footer.get(); if (!footer) return console.error('Footer element not found!'); if (footer.style.visibility != 'hidden') return console.info('Footer already shown!'); - footer.style.visibility = footer.style.height = 'inherit'; + footer.style.visibility = footer.style.height = 'inherit'; } }, @@ -893,7 +893,7 @@ const chatgpt = { getRegenerateButton() { return document.querySelector('button:has([d^="M3.06957"])'); }, getResponse() { - // * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args: + // * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args: // chatToGet = index|title|id of chat to get (defaults to latest if '' unpassed) // responseToGet = index of response to get (defaults to latest if '' unpassed) // regenResponseToGet = index of regenerated response to get (defaults to latest if '' unpassed) @@ -1147,7 +1147,7 @@ const chatgpt = { } else if (element == 'dropdown') { - if (!attrs?.items || // there no are options to add + if (!attrs?.items || // there no are options to add !Array.isArray(attrs.items) || // it's not an array !attrs.items.length) // the array is empty attrs.items = [{ text: '🤖 chatgpt.js option', value: 'chatgpt.js option value' }]; // set default dropdown entry @@ -1168,7 +1168,7 @@ const chatgpt = { const addElementsToMenu = () => { const optionButtons = document.querySelectorAll('a[role="menuitem"]'); let cssClasses; - + for (const navLink of optionButtons) if (navLink.textContent == 'Settings') { cssClasses = navLink.classList; @@ -1240,7 +1240,7 @@ const chatgpt = { + (notificationDiv.isRight ? 'Right' : 'Left'); // Create/append/update notification style (if missing or outdated) - const thisUpdated = 20231110; // datestamp of last edit for this file's `notifStyle` + const thisUpdated = 20231110; // datestamp of last edit for this file's `notifStyle` let notifStyle = document.querySelector('#chatgpt-notif-style'); // try to select existing style if (!notifStyle || parseInt(notifStyle.getAttribute('last-updated'), 10) < thisUpdated) { // if missing or outdated if (!notifStyle) { // outright missing, create/id/attr/append it first @@ -1263,7 +1263,7 @@ const chatgpt = { + '45% { opacity: 0.05 ; transform: rotateX(-81deg) }' + '100% { opacity: 0 ; transform: rotateX(-180deg) scale(1.15) }}' ); - } + } // Enqueue notification let notifyProps = JSON.parse(localStorage.notifyProps); @@ -1296,7 +1296,7 @@ const chatgpt = { notificationDiv.style.transition = 'transform 0.15s ease, opacity 0.15s ease'; }, 10); - // Init delay before hiding + // Init delay before hiding const hideDelay = fadeDuration > notifDuration ? 0 // don't delay if fade exceeds notification duration : notifDuration - fadeDuration; // otherwise delay for difference @@ -1305,7 +1305,7 @@ const chatgpt = { notificationDiv.style.animation = `notif-zoom-fade-out ${ fadeDuration }s ease-out`; clearTimeout(dismissFuncTID); }; - const dismissFuncTID = setTimeout(dismissNotif, hideDelay * 1000); // maintain visibility for `hideDelay` secs, then dismiss + const dismissFuncTID = setTimeout(dismissNotif, hideDelay * 1000); // maintain visibility for `hideDelay` secs, then dismiss closeSVG.onclick = dismissNotif; // add to close button clicks // Destroy notification @@ -1453,7 +1453,7 @@ const chatgpt = { continue() { try { chatgpt.getContinueBtn().click(); } catch (err) { console.error(err.message); }}, get() { - // * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args: + // * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args: // chatToGet = index|title|id of chat to get (defaults to latest if '' unpassed) // responseToGet = index of response to get (defaults to latest if '' unpassed) // regenResponseToGet = index of regenerated response to get (defaults to latest if '' unpassed) @@ -1682,14 +1682,14 @@ const chatgpt = { break; } } - + // Apply CSS to make the added elements look like they belong to the website this.elements.forEach(element => { element.setAttribute('class', cssClasses); element.style.maxHeight = element.style.minHeight = '44px'; // Fix the height of the element element.style.margin = '2px 0'; }); - + // Create MutationObserver instance const navBar = document.querySelector('nav'); if (!navBar) return console.error('Sidebar element not found!'); @@ -1746,7 +1746,7 @@ const chatgpt = { } else if (element == 'dropdown') { - if (!attrs?.items || // There no are options to add + if (!attrs?.items || // There no are options to add !Array.isArray(attrs.items) || // It's not an array !attrs.items.length) // The array is empty attrs.items = [{ text: '🤖 chatgpt.js option', value: 'chatgpt.js option value' }]; // Set default dropdown entry @@ -1761,7 +1761,7 @@ const chatgpt = { newElement.add(optionElement); }); } - + // Fix for blank background on dropdown elements if (element == 'dropdown') newElement.style.backgroundColor = 'var(--gray-900, rgb(32, 33, 35))'; @@ -1862,7 +1862,7 @@ const chatgpt = { if (!outputLang) return console.error('outputLang (2nd) argument not supplied. Pass a language!'); for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string') return console.error(`Argument ${ i + 1 } must be a string!`); - chatgpt.send('Translate the following text to ' + outputLang + chatgpt.send('Translate the following text to ' + outputLang + '. Only reply with the translation.\n\n' + text); console.info('Translating text...'); await chatgpt.isIdle(); @@ -2016,7 +2016,7 @@ for (const prop in chatgpt) { // Prefix console logs w/ '🤖 chatgpt.js >> ' const consolePrefix = '🤖 chatgpt.js >> ', ogError = console.error, ogInfo = console.info; console.error = (...args) => { - if (!args[0].startsWith(consolePrefix)) ogError(consolePrefix + args[0], ...args.slice(1)); + if (!args[0].startsWith(consolePrefix)) ogError(consolePrefix + args[0], ...args.slice(1)); else ogError(...args); }; console.info = (msg) => { diff --git a/docs/assets/js/src/back-to-top-button.js b/docs/assets/js/src/back-to-top-button.js index d03d69bcd..1c903a385 100644 --- a/docs/assets/js/src/back-to-top-button.js +++ b/docs/assets/js/src/back-to-top-button.js @@ -24,8 +24,8 @@ function fadeIn(el, duration) { let last = +new Date(); const tick = () => { el.style.opacity = +el.style.opacity + (new Date() - last) / duration; - last = +new Date(); - if (+el.style.opacity < 1) + last = +new Date(); + if (+el.style.opacity < 1) (window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16); else el.style.display = 'block'; @@ -56,7 +56,7 @@ function scrollToTop() { } } button.addEventListener('click', scrollToTop); - + window.addEventListener('scroll', () => { const scrollTop = window.scrollY || document.documentElement.scrollTop; if (scrollTop > 0) fadeIn(button, 500); diff --git a/docs/assets/js/src/onload-hacks.js b/docs/assets/js/src/onload-hacks.js index 5dfb118e4..f479728cd 100644 --- a/docs/assets/js/src/onload-hacks.js +++ b/docs/assets/js/src/onload-hacks.js @@ -30,7 +30,7 @@ const iObserver = new IntersectionObserver(entries => { entries.forEach(entry => const key = entry.target.id || entry.target.className; visibilityMap[key] = entry.isIntersecting; - // Handle COVER + // Handle COVER if (entry.target.className === 'cover-main') { if (entry.isIntersecting) { @@ -108,7 +108,7 @@ const onLoadObserver = new MutationObserver(() => { function updateTGvisibility() { topGradient.style.display = ( // hide/show when fold is 85% at top window.scrollY > 0.85 * cover.offsetHeight ? '' : 'none' ); } - + mdLoaded.then(() => { // Scroll slightly to overcome Chromium bug preventing parallax @@ -155,7 +155,7 @@ const onLoadObserver = new MutationObserver(() => { ghDemo.parentNode.replaceChild(ytDemo, ghDemo); ytDemo.parentNode.style.textAlign = 'center'; - // Strip blockquote wrappers from showcase app descriptions + // Strip blockquote wrappers from showcase app descriptions document.querySelectorAll('blockquote').forEach(blockquote => { const parent = blockquote.parentNode, content = blockquote.innerHTML; parent.replaceChild(document.createRange().createContextualFragment(content), blockquote); @@ -196,7 +196,7 @@ const onLoadObserver = new MutationObserver(() => { activeNavItem = (document.querySelector( `a[title="${ headingText }"]`) || {}).parentElement; - // Add `nav-active` class to matched nav item + // Add `nav-active` class to matched nav item if (activeNavItem) { sideNavItems.forEach(item => item.classList.remove('nav-active')); activeNavItem.classList.add('nav-active'); @@ -233,12 +233,12 @@ const onLoadObserver = new MutationObserver(() => { // Exit if still in 1st two sections if (visibilityMap['cover-main'] || visibilityMap['feature-list']) return; - + // Determine current section let currentSection = 0; - while (window.scrollY > triggerPoints[currentSection] && + while (window.scrollY > triggerPoints[currentSection] && currentSection < triggerPoints.length) - currentSection++; + currentSection++; // Color/animate logo/stars + color scrollbar if section changed const sectionColor = sectionColors[currentSection - 2]; @@ -349,7 +349,7 @@ const onLoadObserver = new MutationObserver(() => { scaleDelay = 285, // px from trigger.y to delay scaling scaleFactor = topGap > -scaleDelay ? 1 : 1 - Math.abs(topGap + scaleDelay) / 5 / window.innerHeight; - + try { elem.classList.remove('content-fadeup'); } catch (err) {} elem.style.opacity = newOpacity; elem.style.transform = `translateY(${parallaxOffset}px) scale(${scaleFactor})`; @@ -390,22 +390,22 @@ function validateIntArg(arg, name, defaultVal) { if (arg === undefined) return defaultVal; // no validation required if (!Number.isInteger(arg) && !/^\d+$/.test(arg)) throw new Error(name + ' must be an integer.'); - return parseInt(arg, 10); + return parseInt(arg, 10); } function smoothScroll(target, speed, smooth) { // Init target if (target === document) - target = (document.scrollingElement - || document.documentElement - || document.body.parentNode + target = (document.scrollingElement + || document.documentElement + || document.body.parentNode || document.body); // cross browser support for document scrolling // Init variables let moving = false, pos = target.scrollTop; - const frame = target === document.body && document.documentElement - ? document.documentElement + const frame = target === document.body && document.documentElement + ? document.documentElement : target; // safari // Add listeners target.addEventListener('mousewheel', scrolled, { passive: false }); @@ -429,8 +429,8 @@ function smoothScroll(target, speed, smooth) { } function update() { - moving = true; - const delta = (pos - target.scrollTop) / smooth; + moving = true; + const delta = (pos - target.scrollTop) / smooth; target.scrollTop += delta; if (Math.abs(delta) > 0.5) requestFrame(update); else moving = false; @@ -512,7 +512,7 @@ function typeText(txtToType, destination, typeDelay, iniTxtToType, iniTxtPos, li iniTxtPos, 'Initial text string position', 3); linesToScrollAt = validateIntArg( // lines reached before scrolling up linesToScrollAt, 'Lines to scroll at', 5); - + // Init variables let typeContent = ' ', iniRow = Math.max(0, iniTxtToType - linesToScrollAt); @@ -588,7 +588,7 @@ langSelector.onmouseover = langSelector.onmouseout = langMenu.onmouseover = lang clearTimeout(hideTimeout); if (event.type == 'mouseover') langMenu.style.display = 'block'; else if (event.type == 'mouseout') - hideTimeout = setTimeout(() => langMenu.style.display = 'none', 55); + hideTimeout = setTimeout(() => langMenu.style.display = 'none', 55); }; document.querySelectorAll('#language-selector a').forEach(link => { // add listener to hide tooltips link.addEventListener('mouseenter', () => { link.removeAttribute('title'); });}); diff --git a/docs/assets/js/src/starry-background.js b/docs/assets/js/src/starry-background.js index cf329950e..9b55c08b0 100644 --- a/docs/assets/js/src/starry-background.js +++ b/docs/assets/js/src/starry-background.js @@ -1,5 +1,5 @@ -/* * . * . * * . - . * Add starry background to +/* * . * . * * . + . * Add starry background to * . . . * . . * */ // Init variables @@ -56,10 +56,10 @@ function animateStars() { star.x += (star.x - width/2) * window.starVelocity.z * star.z; star.y += (star.y - height/2) * window.starVelocity.z * star.z; star.z += window.starVelocity.z; - + // Recycle star when out-of-bounds if (star.x < -overflowThreshold || star.x > width + overflowThreshold || - star.y < -overflowThreshold || star.y > height + overflowThreshold) { + star.y < -overflowThreshold || star.y > height + overflowThreshold) { let direction = 'z', vx = Math.abs(window.starVelocity.x), vy = Math.abs(window.starVelocity.y); if (vx > 1 || vy > 1) { let axis; @@ -76,7 +76,7 @@ function animateStars() { else if (direction === 'b') { star.x = width * Math.random(); star.y = height + overflowThreshold; } } }); - + // Render stars stars.forEach((star) => { context.beginPath(); diff --git a/starters/chrome/extension/components/icons.js b/starters/chrome/extension/components/icons.js index 7e7d1fec2..0f1a0b36c 100644 --- a/starters/chrome/extension/components/icons.js +++ b/starters/chrome/extension/components/icons.js @@ -8,7 +8,7 @@ const icons = { if (iconData.type == 'svg') { const svg = dom.create.svgElem('svg', { viewBox: iconData.viewBox, ...iconAttrs }) iconData.elems.forEach(([tag, attrs]) => svg.append(dom.create.svgElem(tag, attrs))) - return svg + return svg } else // img w/ src return dom.create.elem('img', { src: iconData.src, ...iconAttrs }) }, diff --git a/starters/chrome/extension/content.js b/starters/chrome/extension/content.js index 1ce5c47ea..1c0b1d343 100644 --- a/starters/chrome/extension/content.js +++ b/starters/chrome/extension/content.js @@ -23,7 +23,7 @@ // Define FEEDBACK functions function notify(msg, pos = '', notifDuration = '', shadow = '') { - + // Strip state word to append colored one later const foundState = ['ON', 'OFF'].find(word => msg.includes(word)) if (foundState) msg = msg.replace(foundState, '') diff --git a/starters/chrome/extension/lib/chatgpt.js b/starters/chrome/extension/lib/chatgpt.js index e759afd73..11dcf534c 100644 --- a/starters/chrome/extension/lib/chatgpt.js +++ b/starters/chrome/extension/lib/chatgpt.js @@ -76,7 +76,7 @@ const chatgpt = { modalMessage = document.createElement('p'); // Create/append/update modal style (if missing or outdated) - const thisUpdated = 20231203; // datestamp of last edit for this file's `modalStyle` + const thisUpdated = 20231203; // datestamp of last edit for this file's `modalStyle` let modalStyle = document.querySelector('#chatgpt-modal-style'); // try to select existing style if (!modalStyle || parseInt(modalStyle.getAttribute('last-updated'), 10) < thisUpdated) { // if missing or outdated if (!modalStyle) { // outright missing, create/id/attr/append it first @@ -88,7 +88,7 @@ const chatgpt = { '.no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }' // Background styles - + '.chatgpt-modal {' + + '.chatgpt-modal {' + 'position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;' // expand to full view-port + 'background-color: rgba(67, 70, 72, 0) ;' // init dim bg but no opacity + 'transition: background-color 0.05s ease ;' // speed to transition in show alert routine @@ -140,7 +140,7 @@ const chatgpt = { + `border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' } ;` + 'background-color: black ; position: inherit }' + '.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }' - ); + ); } // Insert text into elements @@ -210,7 +210,7 @@ const chatgpt = { const modalElems = [closeBtn, modalTitle, modalMessage, modalButtons, checkboxDiv]; modalElems.forEach((elem) => { modal.append(elem); }); modal.style.width = `${ width || 458 }px`; - modalContainer.append(modal); document.body.append(modalContainer); + modalContainer.append(modal); document.body.append(modalContainer); // Enqueue alert let alertQueue = JSON.parse(localStorage.alertQueue); @@ -222,7 +222,7 @@ const chatgpt = { if (alertQueue.length === 1) { modalContainer.style.display = ''; setTimeout(() => { // delay non-0 opacity's for transition fx - modalContainer.style.backgroundColor = ( + modalContainer.style.backgroundColor = ( `rgba(67, 70, 72, ${ scheme === 'dark' ? 0.62 : 0.1 })`); modalContainer.classList.add('animated'); }, 100); } @@ -557,7 +557,7 @@ const chatgpt = { .replace('Copy code', ''); msgs.push(sender + ': ' + msg); }); - transcript = msgs.join('\n\n'); + transcript = msgs.join('\n\n'); // ...or from getChatData(chatToGet) } else { @@ -623,7 +623,7 @@ const chatgpt = { footer: { get() { return document.querySelector('main form')?.parentNode.parentNode.nextElementSibling; }, - hide() { + hide() { const footer = chatgpt.footer.get(); if (!footer) return console.error('Footer element not found!'); if (footer.style.visibility == 'hidden') return console.info('Footer already hidden!'); @@ -634,7 +634,7 @@ const chatgpt = { const footer = chatgpt.footer.get(); if (!footer) return console.error('Footer element not found!'); if (footer.style.visibility != 'hidden') return console.info('Footer already shown!'); - footer.style.visibility = footer.style.height = 'inherit'; + footer.style.visibility = footer.style.height = 'inherit'; } }, @@ -893,7 +893,7 @@ const chatgpt = { getRegenerateButton() { return document.querySelector('button:has([d^="M3.06957"])'); }, getResponse() { - // * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args: + // * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args: // chatToGet = index|title|id of chat to get (defaults to latest if '' unpassed) // responseToGet = index of response to get (defaults to latest if '' unpassed) // regenResponseToGet = index of regenerated response to get (defaults to latest if '' unpassed) @@ -1147,7 +1147,7 @@ const chatgpt = { } else if (element == 'dropdown') { - if (!attrs?.items || // there no are options to add + if (!attrs?.items || // there no are options to add !Array.isArray(attrs.items) || // it's not an array !attrs.items.length) // the array is empty attrs.items = [{ text: '🤖 chatgpt.js option', value: 'chatgpt.js option value' }]; // set default dropdown entry @@ -1168,7 +1168,7 @@ const chatgpt = { const addElementsToMenu = () => { const optionButtons = document.querySelectorAll('a[role="menuitem"]'); let cssClasses; - + for (const navLink of optionButtons) if (navLink.textContent == 'Settings') { cssClasses = navLink.classList; @@ -1240,7 +1240,7 @@ const chatgpt = { + (notificationDiv.isRight ? 'Right' : 'Left'); // Create/append/update notification style (if missing or outdated) - const thisUpdated = 20231110; // datestamp of last edit for this file's `notifStyle` + const thisUpdated = 20231110; // datestamp of last edit for this file's `notifStyle` let notifStyle = document.querySelector('#chatgpt-notif-style'); // try to select existing style if (!notifStyle || parseInt(notifStyle.getAttribute('last-updated'), 10) < thisUpdated) { // if missing or outdated if (!notifStyle) { // outright missing, create/id/attr/append it first @@ -1263,7 +1263,7 @@ const chatgpt = { + '45% { opacity: 0.05 ; transform: rotateX(-81deg) }' + '100% { opacity: 0 ; transform: rotateX(-180deg) scale(1.15) }}' ); - } + } // Enqueue notification let notifyProps = JSON.parse(localStorage.notifyProps); @@ -1296,7 +1296,7 @@ const chatgpt = { notificationDiv.style.transition = 'transform 0.15s ease, opacity 0.15s ease'; }, 10); - // Init delay before hiding + // Init delay before hiding const hideDelay = fadeDuration > notifDuration ? 0 // don't delay if fade exceeds notification duration : notifDuration - fadeDuration; // otherwise delay for difference @@ -1305,7 +1305,7 @@ const chatgpt = { notificationDiv.style.animation = `notif-zoom-fade-out ${ fadeDuration }s ease-out`; clearTimeout(dismissFuncTID); }; - const dismissFuncTID = setTimeout(dismissNotif, hideDelay * 1000); // maintain visibility for `hideDelay` secs, then dismiss + const dismissFuncTID = setTimeout(dismissNotif, hideDelay * 1000); // maintain visibility for `hideDelay` secs, then dismiss closeSVG.onclick = dismissNotif; // add to close button clicks // Destroy notification @@ -1453,7 +1453,7 @@ const chatgpt = { continue() { try { chatgpt.getContinueBtn().click(); } catch (err) { console.error(err.message); }}, get() { - // * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args: + // * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args: // chatToGet = index|title|id of chat to get (defaults to latest if '' unpassed) // responseToGet = index of response to get (defaults to latest if '' unpassed) // regenResponseToGet = index of regenerated response to get (defaults to latest if '' unpassed) @@ -1682,14 +1682,14 @@ const chatgpt = { break; } } - + // Apply CSS to make the added elements look like they belong to the website this.elements.forEach(element => { element.setAttribute('class', cssClasses); element.style.maxHeight = element.style.minHeight = '44px'; // Fix the height of the element element.style.margin = '2px 0'; }); - + // Create MutationObserver instance const navBar = document.querySelector('nav'); if (!navBar) return console.error('Sidebar element not found!'); @@ -1746,7 +1746,7 @@ const chatgpt = { } else if (element == 'dropdown') { - if (!attrs?.items || // There no are options to add + if (!attrs?.items || // There no are options to add !Array.isArray(attrs.items) || // It's not an array !attrs.items.length) // The array is empty attrs.items = [{ text: '🤖 chatgpt.js option', value: 'chatgpt.js option value' }]; // Set default dropdown entry @@ -1761,7 +1761,7 @@ const chatgpt = { newElement.add(optionElement); }); } - + // Fix for blank background on dropdown elements if (element == 'dropdown') newElement.style.backgroundColor = 'var(--gray-900, rgb(32, 33, 35))'; @@ -1862,7 +1862,7 @@ const chatgpt = { if (!outputLang) return console.error('outputLang (2nd) argument not supplied. Pass a language!'); for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string') return console.error(`Argument ${ i + 1 } must be a string!`); - chatgpt.send('Translate the following text to ' + outputLang + chatgpt.send('Translate the following text to ' + outputLang + '. Only reply with the translation.\n\n' + text); console.info('Translating text...'); await chatgpt.isIdle(); @@ -2016,7 +2016,7 @@ for (const prop in chatgpt) { // Prefix console logs w/ '🤖 chatgpt.js >> ' const consolePrefix = '🤖 chatgpt.js >> ', ogError = console.error, ogInfo = console.info; console.error = (...args) => { - if (!args[0].startsWith(consolePrefix)) ogError(consolePrefix + args[0], ...args.slice(1)); + if (!args[0].startsWith(consolePrefix)) ogError(consolePrefix + args[0], ...args.slice(1)); else ogError(...args); }; console.info = (msg) => { diff --git a/starters/chrome/extension/popup/controller.js b/starters/chrome/extension/popup/controller.js index 79884ab00..726a137ab 100644 --- a/starters/chrome/extension/popup/controller.js +++ b/starters/chrome/extension/popup/controller.js @@ -34,7 +34,7 @@ + 'icon' + dimension + '.png' }) chrome.action.setIcon({ path: iconPaths }) - + // Update menu contents document.querySelectorAll('div.logo, div.menu-title, div.menu') .forEach(elem => { @@ -52,7 +52,7 @@ const masterToggle = document.querySelector('input') await settings.load('extensionDisabled') masterToggle.checked = !config.extensionDisabled ; sync.fade() - masterToggle.onchange = () => { + masterToggle.onchange = () => { settings.save('extensionDisabled', !config.extensionDisabled) Object.keys(sync).forEach(key => sync[key]()) // sync fade + storage to UI notify(`${chrome.runtime.getManifest().name} ${ this.checked ? 'ON' : 'OFF' }`)