@@ -31,9 +31,10 @@ import NotificationForChatGPTWeb from '../components/NotificationForChatGPTWeb'
3131
3232/**
3333 * @param {SiteConfig } siteConfig
34- * @param {UserConfig } userConfig
3534 */
36- async function mountComponent ( siteConfig , userConfig ) {
35+ async function mountComponent ( siteConfig ) {
36+ const userConfig = await getUserConfig ( )
37+
3738 if ( ! userConfig . alwaysFloatingSidebar ) {
3839 const retry = 10
3940 let oldUrl = location . href
@@ -74,17 +75,19 @@ async function mountComponent(siteConfig, userConfig) {
7475 e . remove ( )
7576 } )
7677
77- const position = {
78- x : window . innerWidth - 300 - Math . floor ( ( 20 / 100 ) * window . innerWidth ) ,
79- y : window . innerHeight / 2 - 200 ,
80- }
81- const toolbarContainer = createElementAtPosition ( position . x , position . y )
82- toolbarContainer . className = 'chatgptbox-toolbar-container-not-queryable'
8378 if ( userConfig . alwaysFloatingSidebar && question ) {
79+ const position = {
80+ x : window . innerWidth - 300 - Math . floor ( ( 20 / 100 ) * window . innerWidth ) ,
81+ y : window . innerHeight / 2 - 200 ,
82+ }
83+ const toolbarContainer = createElementAtPosition ( position . x , position . y )
84+ toolbarContainer . className = 'chatgptbox-toolbar-container-not-queryable'
85+
8486 let triggered = false
8587 if ( userConfig . triggerMode === 'always' ) triggered = true
8688 else if ( userConfig . triggerMode === 'questionMark' && endsWithQuestionMark ( question . trim ( ) ) )
8789 triggered = true
90+
8891 render (
8992 < FloatingToolbar
9093 session = { initSession ( { modelName : userConfig . modelName } ) }
@@ -98,6 +101,7 @@ async function mountComponent(siteConfig, userConfig) {
98101 )
99102 return
100103 }
104+
101105 const container = document . createElement ( 'div' )
102106 container . id = 'chatgptbox-container'
103107 render (
@@ -313,7 +317,7 @@ async function prepareForStaticCard() {
313317 }
314318 }
315319
316- if ( initSuccess ) mountComponent ( siteConfig [ siteName ] , userConfig )
320+ if ( initSuccess ) mountComponent ( siteConfig [ siteName ] )
317321 }
318322}
319323
0 commit comments