chore: parse config method

This commit is contained in:
Simon
2025-10-10 17:46:40 +08:00
parent abe58e5950
commit 3415e0bc3b
3 changed files with 15 additions and 16 deletions

View File

@@ -2,7 +2,6 @@
* Auto-run entry for page-agent.js. Insert this script into your page to get page-agent functionality.
*/
import { PageAgent, type PageAgentConfig } from './PageAgent'
import { DEFAULT_MODEL_NAME } from './config/constants'
// Clean up existing instances to prevent multiple injections from bookmarklet
if (window.pageAgent) {
@@ -20,7 +19,7 @@ console.log('🚀 page-agent.js loaded!')
const currentScript = document.currentScript as HTMLScriptElement | null
if (currentScript) {
const url = new URL(currentScript.src)
const modelName = url.searchParams.get('model') || DEFAULT_MODEL_NAME
const modelName = url.searchParams.get('model')
const language = (url.searchParams.get('lang') as 'zh-CN' | 'en-US') || 'zh-CN'
const config = { modelName, language } as PageAgentConfig
window.pageAgent = new PageAgent(config)