@@ -409,7 +409,7 @@ const chatgpt = {
409409 }
410410 scheduleRefreshes ( interval )
411411 } , ( interval + randomDelay ) * 1000 )
412- } ;
412+ }
413413 scheduleRefreshes ( interval ? parseInt ( interval , 10 ) : 30 )
414414 console . log ( `↻ ChatGPT >> [${ chatgpt . autoRefresh . nowTimeStamp ( ) } ] Auto refresh activated` )
415415
@@ -432,7 +432,7 @@ const chatgpt = {
432432 const now = new Date ( )
433433 const hours = now . getHours ( ) % 12 || 12 // convert to 12h format
434434 let minutes = now . getMinutes ( ) , seconds = now . getSeconds ( )
435- if ( minutes < 10 ) minutes = '0' + minutes ; if ( seconds < 10 ) seconds = '0' + seconds
435+ if ( minutes < 10 ) minutes = '0' + minutes ; if ( seconds < 10 ) seconds = '0' + seconds
436436 const meridiem = now . getHours ( ) < 12 ? 'AM' : 'PM'
437437 return `${ hours } :${ minutes } :${ seconds } ${ meridiem } `
438438 } ,
@@ -574,7 +574,7 @@ const chatgpt = {
574574
575575 async refactor ( code , objective ) {
576576 if ( ! code ) return console . error ( 'Code (1st) argument not supplied. Pass some code!' )
577- for ( let i = 0 ; i < arguments . length ; i ++ ) if ( typeof arguments [ i ] != 'string' )
577+ for ( let i = 0 ; i < arguments . length ; i ++ ) if ( typeof arguments [ i ] != 'string' )
578578 return console . error ( `Argument ${ i + 1 } must be a string.` )
579579 chatgpt . send ( `Refactor the following code for ${ objective || 'brevity' } :\n\n${ code } ` )
580580 console . info ( 'Refactoring code...' )
@@ -603,7 +603,7 @@ const chatgpt = {
603603 async write ( prompt , outputLang ) {
604604 if ( ! prompt ) return console . error ( 'Prompt (1st) argument not supplied. Pass a prompt!' )
605605 if ( ! outputLang ) return console . error ( 'outputLang (2nd) argument not supplied. Pass a language!' )
606- for ( let i = 0 ; i < arguments . length ; i ++ ) if ( typeof arguments [ i ] != 'string' )
606+ for ( let i = 0 ; i < arguments . length ; i ++ ) if ( typeof arguments [ i ] != 'string' )
607607 return console . error ( `Argument ${ i + 1 } must be a string.` )
608608 chatgpt . send ( `${ prompt } \n\nWrite this as code in ${ outputLang } ` )
609609 console . info ( 'Writing code...' )
@@ -657,7 +657,7 @@ const chatgpt = {
657657 if ( ! chatDivs . length ) return console . error ( 'Chat is empty!' )
658658 const msgs = [ ] ; let isUserMsg = true
659659 chatDivs . forEach ( div => {
660- const sender = isUserMsg ? 'USER' : 'CHATGPT' ; isUserMsg = ! isUserMsg
660+ const sender = isUserMsg ? 'USER' : 'CHATGPT' ; isUserMsg = ! isUserMsg
661661 const msg = [ ...div . childNodes ] . map ( node => node . innerText )
662662 . join ( '\n\n' ) // insert double line breaks between paragraphs
663663 . replace ( 'Copy code' , '' )
@@ -686,7 +686,7 @@ const chatgpt = {
686686 cssLinks . forEach ( link => {
687687 const href = link . getAttribute ( 'href' )
688688 if ( href ?. startsWith ( '/' ) ) link . setAttribute ( 'href' , 'https://chat.openai.com' + href )
689- } ) ;
689+ } )
690690
691691 // Serialize updated HTML to string
692692 transcript = new XMLSerializer ( ) . serializeToString ( parsedHtml )
@@ -711,7 +711,7 @@ const chatgpt = {
711711
712712 if ( format == 'md' ) { // remove extraneous HTML + fix file extension
713713 const mdMatch = / < .* < h 1 ( .| \n ) * ?h r e f = " .* ?c o n t i n u e [ ^ " ] * " .* ?\/ a > .* ?< [ ^ / ] / . exec ( transcript ) [ 1 ]
714- transcript = mdMatch || transcript ; filename = filename . replace ( '.html' , '.md' )
714+ transcript = mdMatch || transcript ; filename = filename . replace ( '.html' , '.md' )
715715 }
716716 const blob = new Blob ( [ transcript ] ,
717717 { type : 'text/' + ( format == 'html' ? 'html' : format == 'md' ? 'markdown' : 'plain' ) } )
@@ -959,7 +959,8 @@ const chatgpt = {
959959 msgsToReturn . push ( userMessages [ userMessage ] . msg . content . parts [ 0 ] )
960960 else if ( sender == 'chatgpt' ) // Fill [msgsToReturn] with ChatGPT responses
961961 for ( const chatGPTMessage of chatGPTMessages )
962- msgsToReturn . push ( msgToGet == 'latest' ? chatGPTMessages [ chatGPTMessages . length - 1 ] : chatGPTMessage ) ;
962+ msgsToReturn . push ( msgToGet == 'latest' ? chatGPTMessages [ chatGPTMessages . length - 1 ]
963+ : chatGPTMessage )
963964 else { // Fill [msgsToReturn] with objects of user messages and chatgpt response(s)
964965 let i = 0
965966 for ( const message in userMessages ) {
@@ -1075,9 +1076,9 @@ const chatgpt = {
10751076 else if ( target == 'chatgpt' ) instructionsData . about_model_message += instruction
10761077
10771078 await this . sendRequest ( 'POST' , token , instructionsData )
1078- return resolve ( ) ;
1079- } ) ;
1080- } ) ;
1079+ return resolve ( )
1080+ } )
1081+ } )
10811082 } ,
10821083
10831084 clear ( target ) {
@@ -1132,7 +1133,7 @@ const chatgpt = {
11321133 xhr . onload = ( ) => {
11331134 const responseData = JSON . parse ( xhr . responseText )
11341135 if ( xhr . status == 422 )
1135- return reject ( '🤖 chatgpt.js >> Character limit exceeded. Custom instructions can have a maximum length of 1500 characters.' ) ;
1136+ return reject ( '🤖 chatgpt.js >> Character limit exceeded. Custom instructions can have a maximum length of 1500 characters.' )
11361137 else if ( xhr . status == 403 && responseData . detail . reason == 'content_policy' )
11371138 return reject ( '🤖 chatgpt.js >> ' + responseData . detail . description )
11381139 else if ( xhr . status != 200 )
@@ -1257,7 +1258,7 @@ const chatgpt = {
12571258 if ( ! attrs . items . every ( el => typeof el == 'object' ) ) // the entries of the array are not objects
12581259 return console . error ( '\'items\' must be an array of objects!' )
12591260
1260- newElem . style = 'background-color: #000; width: 100%; border: none; '
1261+ newElem . style = 'background-color: #000 ; width: 100% ; border: none'
12611262
12621263 attrs . items . forEach ( item => {
12631264 const optionElement = document . createElement ( 'option' )
@@ -1300,15 +1301,15 @@ const chatgpt = {
13001301 }
13011302 } ,
13021303
1303- minify ( ) { chatgpt . code . minify ( ) ; } ,
1304+ minify ( ) { chatgpt . code . minify ( ) } ,
13041305
13051306 notify ( ...args ) {
13061307 const scheme = chatgpt . isDarkMode ( ) ? 'dark' : 'light'
13071308 let msg , position , notifDuration , shadow , toast
13081309 if ( typeof args [ 0 ] == 'object' && ! Array . isArray ( args [ 0 ] ) )
13091310 ( { msg, position, notifDuration, shadow, toast } = args [ 0 ] )
13101311 else [ msg , position , notifDuration , shadow ] = args
1311- notifDuration = notifDuration ? + notifDuration : 1.75 ; // sec duration to maintain notification visibility
1312+ notifDuration = notifDuration ? + notifDuration : 1.75 // sec duration to maintain notification visibility
13121313 const fadeDuration = 0.35 , // sec duration of fade-out
13131314 vpYoffset = 23 , vpXoffset = 27 // px offset from viewport border
13141315
@@ -1321,7 +1322,7 @@ const chatgpt = {
13211322
13221323 // Create/append close button
13231324 const closeBtn = document . createElement ( 'div' )
1324- closeBtn . title = 'Dismiss' ; closeBtn . classList . add ( 'notif-close-btn' , 'no-mobile-tap-outline' )
1325+ closeBtn . title = 'Dismiss' ; closeBtn . classList . add ( 'notif-close-btn' , 'no-mobile-tap-outline' )
13251326 const closeSVG = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'svg' )
13261327 closeSVG . setAttribute ( 'height' , '8px' )
13271328 closeSVG . setAttribute ( 'viewBox' , '0 0 14 14' )
@@ -1331,7 +1332,7 @@ const chatgpt = {
13311332 closeSVGpath . setAttribute ( 'fill-rule' , 'evenodd' )
13321333 closeSVGpath . setAttribute ( 'clip-rule' , 'evenodd' )
13331334 closeSVGpath . setAttribute ( 'fill' , 'white' )
1334- closeSVGpath . setAttribute ( 'd' , 'M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z' ) ;
1335+ closeSVGpath . setAttribute ( 'd' , 'M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z' )
13351336 closeSVG . append ( closeSVGpath ) ; closeBtn . append ( closeSVG ) ; notificationDiv . append ( closeBtn )
13361337
13371338 // Determine div position/quadrant
@@ -1418,7 +1419,7 @@ const chatgpt = {
14181419
14191420 // Add notification dismissal to timeout schedule + button clicks
14201421 const dismissNotif = ( ) => {
1421- notificationDiv . style . animation = `notif-zoom-fade-out ${ fadeDuration } s ease-out` ;
1422+ notificationDiv . style . animation = `notif-zoom-fade-out ${ fadeDuration } s ease-out`
14221423 clearTimeout ( dismissFuncTID )
14231424 }
14241425 const dismissFuncTID = setTimeout ( dismissNotif , hideDelay * 1000 ) // maintain visibility for `hideDelay` secs, then dismiss
@@ -1470,7 +1471,7 @@ const chatgpt = {
14701471
14711472 // Print methods
14721473 const isDarkMode = window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ,
1473- baseFontStyles = 'font-family: monospace ; font-size: larger ; '
1474+ baseFontStyles = 'font-family: monospace ; font-size: larger ;'
14741475 console . log ( '\n%c🤖 chatgpt.js methods\n' , 'font-family: sans-serif ; font-size: xxx-large ; font-weight: bold' )
14751476 for ( const functionName of functionNames ) {
14761477 const isChatGptObjParent = / c h a t g p t | o t h e r / . test ( functionName [ 0 ] ) ,
@@ -1583,7 +1584,7 @@ const chatgpt = {
15831584 // chatToGet = index|title|id of chat to get (defaults to latest if '' or unpassed)
15841585 // responseToGet = index of response to get (defaults to latest if '' or unpassed)
15851586
1586- chatToGet = chatToGet || 'latest' ; responseToGet = responseToGet || 'latest'
1587+ chatToGet = chatToGet || 'latest' ; responseToGet = responseToGet || 'latest'
15871588 return chatgpt . getChatData ( chatToGet , 'msg' , 'chatgpt' , responseToGet )
15881589 } ,
15891590
@@ -1636,7 +1637,7 @@ const chatgpt = {
16361637 return console . error ( `Argument ${ i + 1 } must be a string!` )
16371638 const textArea = chatgpt . getChatBox ( )
16381639 if ( ! textArea ) return console . error ( 'Chatbar element not found!' )
1639- const msgP = document . createElement ( 'p' ) ; msgP . textContent = msg
1640+ const msgP = document . createElement ( 'p' ) ; msgP . textContent = msg
16401641 textArea . querySelector ( 'p' ) . replaceWith ( msgP )
16411642 textArea . dispatchEvent ( new Event ( 'input' , { bubbles : true } ) ) // enable send button
16421643 setTimeout ( function delaySend ( ) {
@@ -1686,7 +1687,7 @@ const chatgpt = {
16861687 } ,
16871688
16881689 async sentiment ( text , entity ) {
1689- for ( let i = 0 ; i < arguments . length ; i ++ ) if ( typeof arguments [ i ] != 'string' )
1690+ for ( let i = 0 ; i < arguments . length ; i ++ ) if ( typeof arguments [ i ] != 'string' )
16901691 return console . error ( `Argument ${ i + 1 } must be a string.` )
16911692 chatgpt . send ( 'What is the sentiment of the following text'
16921693 + ( entity ? ` towards the entity ${ entity } ,` : '' )
@@ -1881,7 +1882,7 @@ const chatgpt = {
18811882 return newElem . id // Return the element id
18821883 } ,
18831884
1884- exists ( ) { return ! ! chatgpt . getNewChatLink ( ) ; } ,
1885+ exists ( ) { return ! ! chatgpt . getNewChatLink ( ) } ,
18851886 hide ( ) { this . isOn ( ) ? this . toggle ( ) : console . info ( 'Sidebar already hidden!' ) } ,
18861887 show ( ) { this . isOff ( ) ? this . toggle ( ) : console . info ( 'Sidebar already shown!' ) } ,
18871888 isOff ( ) { return ! this . isOn ( ) } ,
@@ -1915,12 +1916,12 @@ const chatgpt = {
19151916 } ,
19161917
19171918 startNewChat ( ) { try { chatgpt . getNewChatBtn ( ) . click ( ) } catch ( err ) { console . error ( err . message ) } } ,
1918- stop ( ) { chatgpt . response . stopGenerating ( ) ; } ,
1919+ stop ( ) { chatgpt . response . stopGenerating ( ) } ,
19191920
19201921 async suggest ( ideaType , details ) {
19211922 if ( ! ideaType ) return console . error ( 'ideaType (1st argument) not supplied'
19221923 + `(e.g. 'gifts', 'names', 'recipes', etc.)` )
1923- for ( let i = 0 ; i < arguments . length ; i ++ ) if ( typeof arguments [ i ] != 'string' )
1924+ for ( let i = 0 ; i < arguments . length ; i ++ ) if ( typeof arguments [ i ] != 'string' )
19241925 return console . error ( `Argument ${ i + 1 } must be a string.` )
19251926 chatgpt . send ( 'Suggest some names. ' + ( details || '' ) )
19261927 console . info ( `Creating ${ ideaType } ...` )
@@ -1964,7 +1965,7 @@ const chatgpt = {
19641965 return chatgpt . getChatData ( 'active' , 'msg' , 'chatgpt' , 'latest' )
19651966 } ,
19661967
1967- toggleScheme ( ) { chatgpt . settings . scheme . toggle ( ) ; } ,
1968+ toggleScheme ( ) { chatgpt . settings . scheme . toggle ( ) } ,
19681969
19691970 async translate ( text , outputLang ) {
19701971 if ( ! text ) return console . error ( 'Text (1st) argument not supplied. Pass some text!' )
@@ -1989,7 +1990,7 @@ const chatgpt = {
19891990 const r = ( // generate random nibble
19901991 ( d + ( window . crypto . getRandomValues ( new Uint32Array ( 1 ) ) [ 0 ] / ( Math . pow ( 2 , 32 ) - 1 ) ) * 16 ) % 16 | 0 )
19911992 d = Math . floor ( d / 16 ) // correspond each UUID digit to unique 4-bit chunks of timestamp
1992- return ( c == 'x' ? r : ( r & 0x3 | 0x8 ) ) . toString ( 16 ) ; // generate random hexadecimal digit
1993+ return ( c == 'x' ? r : ( r & 0x3 | 0x8 ) ) . toString ( 16 ) // generate random hexadecimal digit
19931994 } )
19941995 return uuid
19951996 }
@@ -2090,8 +2091,8 @@ const cjsFuncSynonyms = [
20902091 [ 'temp' , 'temporary' ] ,
20912092 [ 'typing' , 'generating' ] ,
20922093 [ 'unminify' , 'beautify' , 'prettify' , 'prettyPrint' ]
2093- ] ;
2094- ( function createCJSaliasFuncs ( obj = chatgpt ) {
2094+ ]
2095+ ; ( function createCJSaliasFuncs ( obj = chatgpt ) {
20952096 for ( const prop in obj ) {
20962097 if ( ! Object . prototype . hasOwnProperty . call ( obj , prop ) ) continue // skip inherited props
20972098 if ( typeof obj [ prop ] == 'object' ) createCJSaliasFuncs ( obj [ prop ] ) // recurse thru objs to find deeper functions
@@ -2138,7 +2139,7 @@ console.error = (...args) => {
21382139 } else ogError ( consolePrefix , ...args )
21392140}
21402141console . info = ( msg ) => {
2141- if ( ! msg . startsWith ( consolePrefix ) ) ogInfo ( consolePrefix + msg ) ;
2142+ if ( ! msg . startsWith ( consolePrefix ) ) ogInfo ( consolePrefix + msg )
21422143 else ogInfo ( msg )
21432144}
21442145
0 commit comments