ai-helper-agent 2.8.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{chat-export-CvuuXVcS.js → chat-export-erJC2N4g.js} +1 -1
- package/dist/assets/content.js +15 -15
- package/dist/assets/{markdown-render-ljX8y3-8.js → markdown-render-DcpWM3Re.js} +2 -2
- package/dist/assets/options.js +1 -1
- package/dist/assets/side_panel.js +8 -8
- package/dist/assets/{version-Bvlnn3Va.js → version-ChVGD97_.js} +1 -1
- package/dist/manifest.json +1 -1
- package/dist/options.html +1 -1
- package/dist/side_panel.html +2 -2
- package/package.json +1 -1
package/dist/assets/content.js
CHANGED
|
@@ -48,7 +48,7 @@ You will need to pair again after deletion.`,deleteAgentTitle:"Delete Agent",age
|
|
|
48
48
|
1. Step 1
|
|
49
49
|
2. Step 2`,existingResources:"Existing resource files",skillNameRequired:"Please enter the Skill name",skillMarkdownRequired:"Please enter the SKILL.md content",agentSkillSaved:'Agent Skill "{name}" saved successfully',saveFailedShort:"Save failed",saveFailed:"Save failed: {error}",viewSkillTitle:"View Skill: {name}",importSkillTitle:"Import Skill",importBtn:"Import",jsonImport:"JSON Import",newAuthoring:"New Authoring",zipPackage:"Zip",urlImport:"URL Import",jsonImportDesc:"Import a Workflow Skill in JSON format (deterministic automated flow)",clickOrDragJson:"Click to select a JSON file or drag it here",jsonFileHint:"Supports .json Workflow Skill definition files",markdownImportDesc:"Write SKILL.md content directly to create an Agent Skill (AI capability extension)",zipImportDesc:"Import a Zip archive containing SKILL.md, with optional scripts/templates/assets resources",clickOrDragZip:"Click to select a Zip file or drag it here",zipFileHint:"The Zip must contain a SKILL.md file; optional scripts/ templates/ assets/ subdirectories",urlImportDesc:"Download a Skill Zip from a remote URL and import automatically",downloadUrl:"Download URL",selectJsonFile:"Please select a JSON file",workflowSkillImported:'Workflow Skill "{name}" imported successfully',agentSkillCreated:'Agent Skill "{name}" created successfully',createFailedShort:"Create failed",selectZipFile:"Please select a Zip file",fileTooLarge:"File too large; max 50MB supported",fileReadFailed:"File read failed",agentSkillImported:'Agent Skill "{name}" imported successfully',urlRequired:"Please enter a URL",importFailed:"Import failed: {error}",searchMcpPlaceholder:"Search MCP servers...",searchSkillPlaceholder:"Search skills...",filterAll:"All",filterEnabled:"Enabled",filterDisabled:"Disabled",noMatchResult:"No matching results"},memoryPanel:{tabTitle:"Memory",title:"Memory Vectors",enabled:"Enabled",disabled:"Disabled",statusTitle:"Vector index status",statusLoading:"Loading\u2026",statusOffline:"Agent is not connected, vector status unavailable",statusFail:"Failed to read vector status",statusOldAgent:"This agent version has no such status endpoint \u2014 restart the agent",statusDetail:"Response",statusIndexed:"Indexed {indexed} of {total}",statusStored:"Stored vector fingerprint",statusCurrent:"Current config fingerprint",statusTier:"Active tier",statusStale:"Stale: model changed without rebuild",statusFresh:"Matches current config",staleHint:"Old vectors are incomparable with the new config, so semantic recall degrades silently. Click \u201CRebuild vector index\u201D (save unsaved edits first).",modeLabel:"Embedding source",modeRemote:"Remote service (OpenAI-compatible API)",modeLocal:"Local model",baseUrlLabel:"Endpoint",baseUrlPlaceholder:"https://api.openai.com/v1",modelLabel:"Model name",modelPlaceholder:"BAAI/bge-m3",apiKeyLabel:"API Key",apiKeyPlaceholder:"Leave blank to keep the stored key",apiKeyClearBtn:"Clear stored key",apiKeyClearConfirm:"Remote semantic recall stops (falls back to keywords) until a new key is saved. Clear the stored key?",apiKeyCleared:"Stored API key cleared",apiKeyClearFail:"Failed to clear key: {error}",configNotLoaded:"Config failed to load. Refresh the panel before saving so the agent\u2019s stored settings are not overwritten with blanks",dimsLabel:"Vector dimensions (blank is fine, detected on test)",prefixLabel:"Query prefix (optional)",localNotice:"Local mode needs no connectivity test: save, then rebuild the vector index (the first run downloads the model and may take tens of minutes). Embeddings are silently truncated at 512 tokens, so only the head of an over-long entry is indexed.",testBtn:"Test connectivity",testRunning:"Testing\u2026",testOk:"OK: {model} returns {dims} dimensions",testFail:"Test failed: {error}",scopeHint:"Clicking the bottom \u201CSave\u201D also writes this tab\u2019s config into the agent service config.json; when the agent is offline this item is skipped and only extension settings are saved",saveSkippedOffline:"Agent not connected \u2014 memory vector config was not saved (only extension settings saved)",saveSuccess:"Memory vector config saved",saveFail:"Save failed: {error}",toggleOnSaved:"Semantic vector recall enabled",toggleOffSaved:"Semantic vector recall disabled - recall falls back to keywords",toggleFail:"Failed to toggle: {error}",reindexBtn:"Rebuild vector index",reindexConfirm:"Rebuilding recomputes vectors for every memory with the current config. On local mode 41 entries measured about 23 minutes (remote about 2). Keep this page open. Continue?",reindexRunning:"Rebuilding, please keep this page open\u2026",reindexDone:"Rebuild done: indexed {indexed} of {total}",reindexBatchFail:" ({count} batches failed, see agent logs)",reindexOverWindow:" ({count} entries exceed the {window}-token window, their tails are not indexed)",reindexSkipped:"Rebuild skipped: vector tier is disabled",reindexFail:"Rebuild failed: {error}",gateAgentOffTitle:"Agent not connected",gateAgentOffBody:'Memory vector config is provided by the local agent. Connect an agent in the "Agent" tab first, then come back here.',gateRagTitle:"Local model dependency missing",gateRagMissing:'Local models require the RAG dependency. Install it in the "Extensions" panel first, then come back here.',goToAgentTab:'Go to "Agent" tab',goToToolboxTab:'Go to "Extensions" tab'},memoryEntries:{title:"Memory Entries",refreshBtn:"Refresh",searchPlaceholder:"Search content or tags\u2026",filterAll:"All types",filterFact:"Facts",filterSummary:"Summaries",sortCreatedDesc:"Created (newest first)",sortImportanceDesc:"Importance (high \u2192 low)",sortValueDesc:"Value (high \u2192 low)",sortValueAsc:"Value (low \u2192 high)",count:"{shown} of {total}",loading:"Loading\u2026",empty:"No memories yet",noMatch:"No entries match the filter",offline:"Agent not connected - memory entries unavailable",unsupported:"This agent version does not support memory entry management - upgrade and restart the agent",loadFail:"Failed to load memory entries: {error}",importanceShort:"Imp",valueShort:"Value",createdLabel:"Created",lastAccessLabel:"Last accessed",neverAccessed:"never",accessCount:"{count} accesses",tagsLabel:"Tags",editBtn:"Edit",deleteBtn:"Delete",editTitle:"Edit memory entry",typeLabel:"Type",contentLabel:"Content",importanceLabel:"Importance (1-10)",tagsPlaceholder:"comma-separated, e.g. environment, preference",saveBtn:"Save",cancelBtn:"Cancel",contentEmpty:"Content cannot be empty",saved:"Memory updated",saveFail:"Update failed: {error}",deleteConfirm:"Delete this memory? It cannot be undone, and its vector cache entry is dropped as well.",deleted:"Memory deleted",deleteFail:"Delete failed: {error}",candidatesHint:"{count} low-value memories are suggested for removal (value below 10)",compactBtn:"Compact now",compactConfirm:"Compacting deletes {count} memories with value below {threshold}. This cannot be undone. Continue?",compactDone:"Compact done: removed {facts} facts and {summaries} summaries",compactFail:"Compact failed: {error}"},knowledge:{tabTitle:"Knowledge",gateAgentOffTitle:"Agent not connected",gateAgentOffDesc:'Knowledge base is provided by the local agent. Connect an agent in the "Agent" tab first, then come back here.',gateRagOffTitle:"Knowledge base feature is disabled",gateRagOffDesc:'Turn on the "Knowledge Retrieval" master switch above to create and manage knowledge bases.',gateRagUnavailableTitle:"Agent capability not ready",gateRagUnavailableDesc:"RAG dependencies are not installed or the Node version is unsupported (Node 22+ required). See the install guide below.",goToAgentTab:'Go to "Agent" tab',goToToolboxTab:'Go to "Extensions" tab',enableNow:"Enable Now",title:"Knowledge Bases",createBtn:"+ New Knowledge Base",searchPlaceholder:"Search knowledge bases...",emptyTitle:"No knowledge base yet",emptyDesc:'Click "New Knowledge Base" to create one, then import documents to get started.',loadFailed:"Failed to load: {error}",retry:"Retry",statsSummary:"{docs} docs \xB7 {chunks} chunks",modeLocal:"Local model",modeRemote:"Remote service",actionEdit:"Edit",actionIngest:"Import",actionSearch:"Test Search",actionDocs:"Docs",actionDelete:"Delete",actionEnable:"Enable",actionDisable:"Disable",badgeDisabled:"Disabled",enableSuccess:'Knowledge base "{name}" enabled',disableSuccess:'Knowledge base "{name}" disabled',createTitle:"New Knowledge Base",nameLabel:"Name",namePlaceholder:"e.g. Product Docs",descLabel:"Description (optional)",descPlaceholder:"Briefly describe what this knowledge base contains",createConfirm:"Create",creating:"Creating...",createSuccess:'Knowledge base "{name}" created',nameRequired:"Please enter a name",editTitle:"Edit Knowledge Base",editConfirm:"Save",saving:"Saving...",editSuccess:"Knowledge base updated",vectorSectionTitle:"Embedding model",vectorModeLocal:"Local model (bundled BGE Chinese model)",vectorModeRemote:"Remote service (OpenAI-compatible API)",vectorModeLocalHint:"Use the agent-bundled BGE Chinese model. No extra config needed; the model file downloads on first import.",vectorModeRemoteHint:"Call a remote OpenAI-compatible embedding service (SiliconFlow, Zhipu, OpenAI, etc.).",vectorEndpointLabel:"Endpoint (Base URL with version segment)",vectorEndpointPlaceholder:"e.g. https://api.siliconflow.cn/v1",vectorApiKeyLabel:"API Key",vectorApiKeyPlaceholder:"Paste API key",vectorApiKeyKeep:"Leave empty to keep the saved key",vectorModelLabel:"Model name",vectorModelPlaceholder:"e.g. BAAI/bge-m3",vectorDimsLabel:"Dimensions (optional, auto-detected on test)",vectorDimsPlaceholder:"Auto",vectorTestBtn:"Test Connection",vectorTesting:"Testing...",vectorTestOk:"Connected: {model} ({dims} dims)",vectorDimsFilled:"Dimensions auto-filled: {dims}",vectorTestFailed:"Test failed: {error}",vectorEndpointRequired:"Remote endpoint is required",vectorModelRequired:"Model name is required",rebuildConfirmTitle:"Change Embedding Config",rebuildConfirm:"Changing the embedding model or chunk settings requires rebuilding the index (all documents will be re-embedded). The old index stays searchable during the rebuild and switches automatically when done. Continue?",rebuildStarted:"Index rebuild started, refreshing when complete...",progressRebuilding:"Rebuilding index {current}/{total} documents\u2026",rebuildDone:"Index rebuild complete",rebuildFailed:"Index rebuild failed: {error}",deleteConfirmTitle:"Delete Knowledge Base",deleteConfirm:'Delete "{name}"? Its {docs} documents and {chunks} chunks will be removed permanently.',deleteSuccess:"Knowledge base deleted",ingestTitle:'Import documents into "{name}"',tabFile:"File",tabText:"Text",tabUrl:"URL",dropHint:"Drag & drop files here, or click to choose (multiple allowed)",dropSupported:"Supports txt / md / pdf / docx / xlsx / html, up to 50MB per file, 20 files per batch",selectedFile:"Selected: {name}",selectedCount:"Selected {count} file(s) (max {max} per batch)",removeFile:"Remove",textContentLabel:"Text content",textContentPlaceholder:"Paste the text to import here...",textNameLabel:"Document name (optional)",textNamePlaceholder:"Leave empty to auto-name",urlLabel:"Web page URL",urlPlaceholder:"https://example.com/page",chunkSettingsTitle:"Chunk settings",chunkSizeLabel:"Chunk size (chars)",chunkOverlapLabel:"Overlap (chars)",ingestConfirm:"Start Import",ingesting:"Parsing and embedding. The first import may download the model, please wait...",progressParsing:"Parsing document\u2026",progressChunking:"Splitting into chunks\u2026",progressEmbedding:"Embedding chunks {current}/{total}\u2026",progressStoring:"Writing to index\u2026",ingestSuccess:"Imported: {name} ({chunks} chunks)",ingestFailed:"Import failed: {error}",fileRequired:"Please choose a file first",contentRequired:"Please enter the text content",urlRequired:"Please enter the URL",fileTooLarge:"File too large, 50MB max",fileTypeUnsupported:"Unsupported file type: {name}",maxBatchFiles:"Up to {max} files per batch; please import in smaller batches",importingBatch:"Importing {current}/{total}: {name}",batchAllSuccess:"Batch import done: {count} documents ({chunks} chunks)",batchPartial:"Import done: {success} succeeded, {fail} failed (first error: {error})",batchAllFailed:"All imports failed: {error}",docsTitle:'Documents in "{name}"',docsEmpty:"No documents imported yet",docChunkCount:"{count} chunks",docDeleteConfirmTitle:"Delete Document",docDeleteConfirm:'Delete document "{name}"? All its chunks will be removed from the knowledge base.',docDeleteSuccess:"Document deleted",docSourceFile:"File",docSourceUrl:"Web",docSourceText:"Text",docOriginalSize:"Original {size}",docOriginalName:"original file {name}",docNoOriginal:"original not kept",docNoOriginalText:"text-only import, no original file",docOriginalQuotaSkipped:"original skipped (quota exceeded)",docOriginalMissing:"No original file for this document; text view only",docOriginalSkippedToast:"Original not saved (quota exceeded); text and vectors were indexed",docView:"View",docViewTitle:"View Original Text",docViewCopy:"Copy",docViewCopied:"Copied to clipboard",docViewPreview:"Preview",docViewSource:"Source",docViewTruncated:"Text is long; showing the first {limit} of {total} characters. Download the full text instead.",docViewEmpty:"(no text content)",docCharCount:"{count} chars",docDownloadOriginal:"Download Original",docDownloadText:"Download Text",docDownloading:"Downloading...",docDownloadFailed:"Download failed, please retry",searchTitle:"Test Search",searchScope:'Scope: "{name}"',searchQueryPlaceholder:"Enter a query, e.g. How to export data?",searchBtn:"Search",searching:"Searching...",searchTopKLabel:"Top K",searchThresholdLabel:"Threshold",searchHitCount:"{count} hits",searchNoHits:"No hits. Try lowering the similarity threshold.",searchFallbackHint:"All scores are below the threshold. Best matches for reference:",searchFailed:"Search failed: {error}",expandFull:"Expand",collapse:"Collapse",scoreLabel:"Score",opFailed:"Operation failed: {error}"},contextBubble:{labelSelection:"Selection",labelQuoted:"Quote",labelSkill:"Skill",labelMcp:"MCP",labelPage:"Page",labelFile:"File",labelKnowledge:"Knowledge",clickToExpand:"Click to expand",bubbleSkill:"{name} \u{1F9E9}",bubbleMcp:"{name} \u{1F50C}",bubblePage:"{title} \u{1F310}",bubbleKnowledge:"{name} \u{1F4DA} \xB7 {count} hits",bubbleKnowledgeMiss:"{name} \u{1F4DA} \xB7 no match",bubbleKnowledgeFailed:"{name} \u{1F4DA} \xB7 retrieval failed",bubbleKnowledgeSearching:"Searching knowledge base\u2026",kbHitToggle:"Click to expand/collapse",kbHitTruncated:"\u2702 Truncated \xB7 {total} chars total, first {kept} sent",kbHitTruncatedTitle:"Truncated to fit the context window; what is shown here is exactly what the model received",kbHitTruncatedBadge:"\u2702 {count} truncated"},configDialog:{exportTitle:"Export Settings",includeSecrets:"Include API keys",secretWarn:"\u26A0 Sensitive information; keep the file safe",exportDesc:"The exported file contains all settings except Agent connection info (proxy URL and pairing token); check the option below to include API keys and connection info as well.",export:"Export",importTitle:"Import Settings",mergeImport:"Merge import \u2014 only overwrite settings present in the file; keep the rest",replaceImport:"Full replace \u2014 clear current settings and use the file content",confirmImport:"Confirm Import",exportSuccess:"Settings exported",exportFailed:"Export failed: {error}",unknownTime:"Unknown",importSummary:"Exported at: {time}, containing {count} settings",invalidFileFormat:"Invalid file format",unrecognizedFormat:"Unrecognized settings format",unknownConfigKey:"Unknown setting key: {key}",importFailed:"Import failed: {error}",importParseFailed:"Import failed: cannot parse file format",importedCount:"Imported {count} settings"},queue:{enqueueBtn:"Add to queue",enqueued:"Added to queue (position {position})",enqueueFailed:"Failed to queue, your text is kept in the input",queueFull:"Queue is full (limit {limit}), please clear some queued tasks first",noSession:"Not ready yet, please retry shortly",summary:"{count} queued",summaryEmpty:"Queue empty",summaryFailed:"{count} task(s) failed",summaryFailedHint:"Failed to run; open Recent to requeue",pausedTag:"Paused",pausedHint:"Auto relay is paused",pausedByStop:"You stopped the task, so auto relay is paused",resumeQueue:"Resume queue",resumed:"Auto relay resumed",stopAndSend:"Stop and send",stopAndSendTitle:"Drop this round and start the queue now (right-click / long-press the stop button)",stopAndSendEmpty:"Nothing is waiting in the queue",stopAndSendStarted:"Current task stopped; the queue is starting",recentTitle:"Recent",recentEmpty:"No processed items yet",requeue:"Re-queue",requeued:"Added back to the queue",deleted:"Removed from queue",movedTop:"Moved to top",withContext:"with context",withImages:"{count} image(s)",withFiles:"{count} file(s)",attachmentsVolatile:"Images/files are too large to persist; they will be lost if the panel reloads, so run this item soon",attachmentsMissing:"Attachments could not be recovered (panel closed or released); this item will send text only",editBackWithAttachments:"Restored to input, including images/files",requeuedNoAttachments:"Requeued (original attachments released, text only)",forgetRecent:"Remove from history",forgotRecent:"Removed from Recent",filesStillExtracting:"Attached files are still being parsed; wait until parsing finishes before queueing (queueing now would lose file content)",inputHasUnsavedContext:"Images/files/quotes attached without text would be cleared by this restore; send or clear them first",statusDispatching:"Running",statusInjecting:"Inserting",statusInjected:"Inserted",statusDone:"Done",statusFailed:"Failed",statusRecovered:"Interrupted",statusRunningHint:"This task is running (tool calls included); the next one starts after it finishes",inject:"Insert into the running task (no need to wait for it)",injectIdleHint:"No task is running; this item will run in queue order",injectAccepted:"Delivered \u2014 takes effect after the current step",injected:"Inserted into the running task",autoCarried:"Queued item carried into the running task (round {iteration})",injectNoTask:"The task just finished; this item is back in the queue",injectTimeout:"No insertion confirmation; this item is back in the queue",injectTimeoutAdhoc:"No insertion confirmation; your text is still in the input box",injectFailed:"Insertion failed; this item is back in the queue",injectNoAttachments:"Items with images/files cannot be inserted into a running task (text only); let them run in queue order",editBack:"Edit in input",editTailHint:"Last queued item restored to the input; press Enter to send when done",delete:"Delete",stopNow:"Stop current task",tooManyAttempts:"This item failed {count} automatic attempts in a row; retries stopped and it was moved to Recent so you can requeue it manually",badgeTitle:"This session has {count} queued task(s)",sessionDropped:"This session had {count} queued task(s); they were removed along with the session"}};function kt(){if(typeof chrome>"u"||!chrome.i18n)return"zh";try{let e=chrome.i18n.getUILanguage();if(e&&e.startsWith("zh"))return"zh"}catch{}return"en"}var $="zh",X={zh:To,en:So},Ze=new Set;function xt(e,t){if(!e||!t)return;let o=t.split("."),n=e;for(let a of o){if(typeof n!="object"||!n)return;n=n[a]}return typeof n=="string"?n:void 0}function Tt(e,t){return!t||typeof e!="string"?e:e.replace(/\{(\w+)\}/g,(o,n)=>t[n]!==void 0&&t[n]!==null?String(t[n]):o)}function u(e,t){let o=xt(X[$],e);if(o!==void 0)return Tt(o,t);if($!=="en"){let n=xt(X.en,e);if(n!==void 0)return Tt(n,t)}return e}function Ct(e){return typeof e=="function"&&Ze.add(e),()=>Ze.delete(e)}function A(e,t){X[e]||(X[e]={}),X[e]=At(X[e],t)}function At(e,t){for(let o of Object.keys(t||{}))t[o]&&typeof t[o]=="object"&&!Array.isArray(t[o])?((!e[o]||typeof e[o]!="object")&&(e[o]={}),At(e[o],t[o])):e[o]=t[o];return e}var St=!1;async function Et(){if(typeof chrome>"u"||!chrome.storage||!chrome.storage.local)return $;try{let e=await chrome.storage.local.get("language");if(e.language&&X[e.language])$=e.language;else{let t=kt();$=t,chrome.storage.local.set({language:t}).catch(()=>{})}}catch{$=kt()}if(!St){St=!0;try{chrome.storage.onChanged.addListener((e,t)=>{if(t!=="local"||!e.language)return;let o=e.language.newValue;if(o&&X[o]&&o!==$){$=o;for(let n of Ze)try{n(o)}catch{}}})}catch{}}return $}var z={fetchUrl:{fallback:15e3,min:1e3,max:12e4},tabLoad:{fallback:15e3,min:1e3,max:12e4},navigation:{fallback:3e4,min:1e3,max:12e4},waitElement:{fallback:1e4,min:200,max:6e4},selectOption:{fallback:5e3,min:200,max:6e4},actionWait:{fallback:2e3,min:200,max:3e4},actionMinWait:{fallback:300,min:200,max:5e3}};function V(e,t){let{fallback:o,min:n,max:a}=t,i=Number(e);return!Number.isFinite(i)||i<=0?o:Math.min(a,Math.max(n,Math.floor(i)))}A("zh",{pageInteraction:{refHint:"ref \u7F16\u53F7\u4EC5\u672C\u6B21\u67E5\u8BE2\u6709\u6548\uFF0C\u9875\u9762\u5BFC\u822A/\u5237\u65B0\u6216\u5207\u6362 tab \u540E\u9700\u91CD\u65B0 query_elements",snapshotHeader:"\u53EF\u4EA4\u4E92\u5143\u7D20\u5FEB\u7167\uFF1A{count} \u4E2A\u5143\u7D20",snapshotTruncated:"\uFF08\u5171 {total} \u4E2A\uFF0C\u5DF2\u622A\u65AD\uFF0C\u8BF7\u7528 filterByText \u7F29\u5C0F\u8303\u56F4\uFF09",snapshotPageInfo:"\uFF08\u7B2C {page}/{totalPages} \u9875\uFF0C\u672C\u6B21\u8F93\u51FA {count} \u4E2A\uFF09",snapshotHasMore:"\u8FD8\u6709\u66F4\u591A\u5143\u7D20\uFF1A\u8C03\u7528 query_elements \u65F6\u5E26 page={next} \u67E5\u770B",snapshotPageOutOfRange:"page={page} \u8D85\u51FA\u8303\u56F4\uFF08\u5171 {totalPages} \u9875\uFF09",snapshotOverlayBlock:"[\u6253\u5F00\u5C42]",snapshotBodyBlock:"[\u9875\u9762\u4E3B\u4F53]",snapshotFooter:"\uFF08ref \u7F16\u53F7\u4EC5\u5F53\u524D\u5FEB\u7167\u6709\u6548\uFF1B\u9875\u9762\u53D8\u5316\u540E\u8BF7\u91CD\u65B0\u8C03\u7528 query_elements\uFF09",snapshotHeaderFrames:"\uFF08\u542B {n} \u4E2A iframe\uFF09",snapshotFramesLimited:"\uFF08\u90E8\u5206 iframe \u8D85\u51FA\u6570\u91CF/\u6DF1\u5EA6\u4E0A\u9650\uFF0C\u672A\u5C55\u5F00\uFF09",snapshotFrameBlock:"[frame #{index}{title}{hostSeg}]",snapshotFramePlaceholder:"iframe #{index}{title}",snapshotFrameUnreachable:"\uFF08\u5185\u5BB9\u4E0D\u53EF\u8BBF\u95EE\uFF09"}}),A("en",{pageInteraction:{refHint:"ref numbers are only valid for the current query; re-run query_elements after page navigation/refresh or tab switch",snapshotHeader:"Interactive elements snapshot: {count} element(s)",snapshotTruncated:" (of {total} total; truncated \u2014 narrow down with filterByText)",snapshotPageInfo:" (page {page}/{totalPages}, {count} shown)",snapshotHasMore:"More elements available: call query_elements with page={next}",snapshotPageOutOfRange:"page={page} is out of range (only {totalPages} page(s))",snapshotOverlayBlock:"[Open overlays]",snapshotBodyBlock:"[Page body]",snapshotFooter:"(ref numbers are valid only for this snapshot; re-run query_elements after the page changes)",snapshotHeaderFrames:" ({n} iframe(s))",snapshotFramesLimited:" (some iframes exceed count/depth limits; not expanded)",snapshotFrameBlock:"[frame #{index}{title}{hostSeg}]",snapshotFramePlaceholder:"iframe #{index}{title}",snapshotFrameUnreachable:" (content inaccessible)"}});function Co(e){if(!e)return"";if(e==="about:srcdoc")return"srcdoc";if(e==="about:blank")return"blank";try{return new URL(e).hostname||""}catch{return""}}function Xe(e,t){for(let o of e)o.t==="el"&&o.localRef!=null&&t.push(o),o.children&&o.children.length&&Xe(o.children,t)}function Ao(e,t,o){if(e.status==="hidden"||e.status==="off")return!1;let n=e.title?` "${e.title}"`:"",a;return a=e.status==="ok"&&e.frameIndex!=null?u("pageInteraction.snapshotFramePlaceholder",{index:e.frameIndex,title:n}):e.status==="unreachable"&&e.frameIndex!=null?u("pageInteraction.snapshotFramePlaceholder",{index:e.frameIndex,title:n})+u("pageInteraction.snapshotFrameUnreachable"):`iframe${n}`,a=" ".repeat(e.depth||0)+a,o.budget-=a.length+1,t.push(a),!0}function Je(e,t,o){if(!e)return!1;if(e.t==="frame")return Ao(e,t,o);let n=[],a=!1;for(let i of e.children||[])Je(i,n,o)&&(a=!0);if(e.t==="el"){if(e.localRef!=null&&o.selected.has(e)){if(o.budget<=0)return o.truncated=!0,a;let i=e.role||"",r=e.name||"",l=e.attrs||"",s=e.depth+i.length+(r?r.length+2:0)+(l?l.length+1:0)+12;if(o.budget-s<0)return o.truncated=!0,a;let c=`${" ".repeat(e.depth)}${i}${r?` "${r}"`:""} [ref ${e.localRef}]${l?" "+l:""}`;return o.budget-=c.length+1,o.count+=1,t.push(c,...n),!0}return a?(t.push(...n),!0):!1}if(e.t==="container"){if(a){let i=`${" ".repeat(e.depth)}${e.role}${e.name?` "${e.name}"`:""}`;return o.budget-=i.length+1,t.push(i,...n),!0}return!1}return a?(t.push(...n),!0):!1}function Rt(e,t,o){let n=[];if((e.overlayTrees||[]).length){for(let a of e.overlayTrees)Je(a,n,o);n.length&&t.push(u("pageInteraction.snapshotOverlayBlock"),...n,u("pageInteraction.snapshotBodyBlock"))}for(let a of e.bodyTree||[])Je(a,t,o)}function It(e={}){let{frames:t=[],page:o=1,maxResults:n=100,maxChars:a=6e3,countOnly:i=!1,frameCount:r=0,framesLimited:l=0}=e||{},s=Number.isInteger(o)&&o>=1?o:1,c=Math.max(1,n),d=[];for(let C of t)Xe(C.overlayTrees||[],d),Xe(C.bodyTree||[],d);let p=d.length;if(i)return{success:!0,content:"",count:p,total:p,truncated:!1,hint:""};let m=Math.ceil(p/c),h=r>0?u("pageInteraction.snapshotHeaderFrames",{n:r}):"",f=l>0?u("pageInteraction.snapshotFramesLimited"):"";if(p>0&&s>m)return{success:!0,content:[u("pageInteraction.snapshotHeader",{count:p})+h+f,u("pageInteraction.snapshotPageOutOfRange",{page:s,totalPages:m}),u("pageInteraction.snapshotFooter")].join(`
|
|
50
50
|
`),count:0,total:p,page:s,totalPages:m,hasMore:!1,truncated:!1,hint:""};let y=(s-1)*c,w=new Set(d.slice(y,y+c)),v=s<m,S={selected:w,budget:a,truncated:!1,count:0},E=[],U=t.find(C=>C.isTop)||t[0];U&&Rt(U,E,S);for(let C of t.filter(O=>O!==U)){let O=[];if(Rt(C,O,S),!O.length)continue;let ie=" ".repeat(Math.max(0,(C.depth||1)-1)*2),de=C.frameInfo&&C.frameInfo.title?` "${C.frameInfo.title}"`:"",Z=Co(C.frameInfo&&C.frameInfo.url);E.push(ie+u("pageInteraction.snapshotFrameBlock",{index:C.frameIndex,title:de,hostSeg:Z?" \xB7 "+Z:""}),...O.map(Ye=>ie+" "+Ye))}let ae=m>1,Y=u("pageInteraction.snapshotHeader",{count:ae?p:S.count})+h+f+(ae?u("pageInteraction.snapshotPageInfo",{page:s,totalPages:m,count:S.count}):"")+(S.truncated?u("pageInteraction.snapshotTruncated",{total:p}):"");return E.unshift(Y),v&&E.push(u("pageInteraction.snapshotHasMore",{next:s+1})),E.push(u("pageInteraction.snapshotFooter")),{success:!0,content:E.join(`
|
|
51
|
-
`),count:S.count,total:p,page:s,totalPages:m,hasMore:v,truncated:S.truncated,hint:v?u("pageInteraction.snapshotHasMore",{next:s+1}):u("pageInteraction.refHint")}}var et="voiceShortcutConfig",be=Object.freeze({rightAlt:!1,rightCtrl:!1});Object.freeze(["rightAlt","rightCtrl"]);function Le(e){let t=e&&typeof e=="object"?e:{};return{rightAlt:t.rightAlt===!0,rightCtrl:t.rightCtrl===!0}}function Eo(e,t){if(!e||e.isComposing)return null;let o=Le(t);return o.rightAlt&&e.code==="AltRight"&&e.altKey&&!e.ctrlKey&&!e.shiftKey&&!e.metaKey?"rightAlt":o.rightCtrl&&e.code==="ControlRight"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey?"rightCtrl":null}var Ro=Object.freeze({rightAlt:"AltRight",rightCtrl:"ControlRight"});function Pt(e){let t=typeof e=="function"?e:()=>be,o=null;return{onKeyDown(n){if(!n)return null;if(o)return n.code!==o.code&&(o=null),null;let a=Eo(n,t());return a?(o={key:a,code:Ro[a]},"cancel"):null},onKeyUp(n){if(!o||!n||n.code!==o.code)return null;let{key:a}=o;return o=null,n.isComposing||!Le(t())[a]?null:"trigger"},reset(){o=null}}}function Io(){try{return globalThis.chrome?.storage?.local||null}catch{return null}}async function tt(){let e=Io();if(!e?.get)return{...be};try{return Le((await e.get(et))?.[et])}catch{return{...be}}}function Mt(e){let t=(o,n)=>{if(n&&n!=="local")return;let a=o?.[et];if(a)try{e(Le(a.newValue))}catch{}};try{globalThis.chrome?.storage?.onChanged?.addListener?.(t)}catch{return()=>{}}return()=>{try{globalThis.chrome?.storage?.onChanged?.removeListener?.(t)}catch{}}}function
|
|
51
|
+
`),count:S.count,total:p,page:s,totalPages:m,hasMore:v,truncated:S.truncated,hint:v?u("pageInteraction.snapshotHasMore",{next:s+1}):u("pageInteraction.refHint")}}var et="voiceShortcutConfig",be=Object.freeze({rightAlt:!1,rightCtrl:!1});Object.freeze(["rightAlt","rightCtrl"]);function Le(e){let t=e&&typeof e=="object"?e:{};return{rightAlt:t.rightAlt===!0,rightCtrl:t.rightCtrl===!0}}function Eo(e,t){if(!e||e.isComposing)return null;let o=Le(t);return o.rightAlt&&e.code==="AltRight"&&e.altKey&&!e.ctrlKey&&!e.shiftKey&&!e.metaKey?"rightAlt":o.rightCtrl&&e.code==="ControlRight"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey?"rightCtrl":null}var Ro=Object.freeze({rightAlt:"AltRight",rightCtrl:"ControlRight"});function Pt(e){let t=typeof e=="function"?e:()=>be,o=null;return{onKeyDown(n){if(!n)return null;if(o)return n.code!==o.code&&(o=null),null;let a=Eo(n,t());return a?(o={key:a,code:Ro[a]},"cancel"):null},onKeyUp(n){if(!o||!n||n.code!==o.code)return null;let{key:a}=o;return o=null,n.isComposing||!Le(t())[a]?null:"trigger"},reset(){o=null}}}function Io(){try{return globalThis.chrome?.storage?.local||null}catch{return null}}async function tt(){let e=Io();if(!e?.get)return{...be};try{return Le((await e.get(et))?.[et])}catch{return{...be}}}function Mt(e){let t=(o,n)=>{if(n&&n!=="local")return;let a=o?.[et];if(a)try{e(Le(a.newValue))}catch{}};try{globalThis.chrome?.storage?.onChanged?.addListener?.(t)}catch{return()=>{}}return()=>{try{globalThis.chrome?.storage?.onChanged?.removeListener?.(t)}catch{}}}function P(e,t=document,o=5,n=0){if(n>o)return null;try{if(t.querySelectorAll)for(let i of t.querySelectorAll("*")){if(i.shadowRoot){let r=P(e,i.shadowRoot,o,n+1);if(r)return r}if(i.tagName==="IFRAME"||i.tagName==="FRAME")try{let r=i.contentDocument||i.contentWindow?.document;if(r){let l=P(e,r,o,n+1);if(l)return l}}catch{}}let a=t.querySelector?.(e);if(a)return a}catch{}return null}function le(e,t=document,o=5,n=0,a=new Set){if(n>o)return[];try{t.querySelectorAll&&(t.querySelectorAll(e).forEach(i=>{a.add(i)}),t.querySelectorAll("*").forEach(i=>{if(i.shadowRoot&&le(e,i.shadowRoot,o,n+1,a),i.tagName==="IFRAME"||i.tagName==="FRAME")try{let r=i.contentDocument||i.contentWindow?.document;r&&le(e,r,o,n+1,a)}catch{}}))}catch{}return Array.from(a)}function ne(e=document,t=5,o=0){if(o>t)return{text:"",range:null};try{let n=e.getSelection?.();if(n&&!n.isCollapsed&&n.rangeCount>0){let a=n.toString().trim();if(a)return{text:a,range:n.getRangeAt(0),depth:o,source:"shadow"}}if(e.querySelectorAll){for(let a of e.querySelectorAll("*"))if(a.shadowRoot){let i=ne(a.shadowRoot,t,o+1);if(i.text)return i}}}catch{}return{text:"",range:null}}function Ce(e=document,t=5,o=0,n=new Set){if(o>t||n.has(e))return"";n.add(e);let a="";try{e.body?a+=e.body.innerText||"":e instanceof ShadowRoot&&(a+=e.textContent||""),e.querySelectorAll&&e.querySelectorAll("*").forEach(i=>{if(i.shadowRoot&&(a+=`
|
|
52
52
|
`+Ce(i.shadowRoot,t,o+1,n)),i.tagName==="IFRAME"||i.tagName==="FRAME")try{let r=i.contentDocument||i.contentWindow?.document;r&&r.body&&(a+=`
|
|
53
53
|
`+Ce(r,t,o+1,n))}catch{}})}catch{}return a.trim().replace(/\n{3,}/g,`
|
|
54
54
|
|
|
@@ -73,21 +73,21 @@ ${s}`)}}catch{}}),i.length>0&&(a+=`
|
|
|
73
73
|
padding: 1px 2px;
|
|
74
74
|
border-radius: 2px;
|
|
75
75
|
}
|
|
76
|
-
`,document.head.appendChild(f),Dt(document.body,new RegExp(s,c),r)}return{success:!0,pattern:s,mode:"regex",total:m.length,matches:m,highlighted:l}}catch(t){return{success:!1,error:t.message}}}A("zh",{pageInteraction:{invalidRefSuggest:"\u65E0\u6548\u6216\u5DF2\u8FC7\u671F\u7684\u5143\u7D20\u5F15\u7528 ref={ref}\u3002",invalidRefSuggestions:"\u6700\u8FD1\u5FEB\u7167\u4E2D\u7684\u6709\u6548\u5F15\u7528\uFF1A{list}\u3002",invalidRefTail:"\u5982\u9875\u9762\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u8C03\u7528 query_elements \u83B7\u53D6\u6700\u65B0\u5FEB\u7167",elementNotVisibleError:"\u5143\u7D20 ref={ref}\uFF08{tag}\uFF09\u5F53\u524D\u4E0D\u53EF\u89C1\uFF0C\u53EF\u80FD\u88AB\u9690\u85CF\u6216\u6298\u53E0",navChangeHint:"\uFF08\u68C0\u6D4B\u5230\u5BFC\u822A\u53D8\u5316\uFF0C\u5DF2\u7B49\u5F85 {ms}ms\uFF09",domChangeHint:"\uFF08\u68C0\u6D4B\u5230DOM\u53D8\u5316\uFF0C\u5DF2\u7B49\u5F85 {ms}ms\uFF09",hoveredByRef:"\u5DF2\u60AC\u505C\u5143\u7D20 ref={ref}\uFF08{tag}\uFF09{hint}",clickedByRef:"\u5DF2\u70B9\u51FB\u5143\u7D20 ref={ref}\uFF08{tag}\uFF09{hint}",typedByRef:"\u5DF2\u5411\u5143\u7D20 ref={ref}\uFF08{tag}\uFF09\u8F93\u5165\u6587\u672C{hint}",typeNotSupported:"\u5143\u7D20 {tag} \u4E0D\u652F\u6301\u6587\u672C\u8F93\u5165\uFF08checkbox/radio \u8BF7\u7528 fill_form \u6216 click\uFF09",valueRequired:"action=type \u65F6 value \u4E0D\u80FD\u4E3A\u7A7A",typeFailed:"\u6587\u672C\u8F93\u5165\u5931\u8D25",textRequired:"text \u4E0D\u80FD\u4E3A\u7A7A",scrolledToText:'\u5DF2\u6EDA\u52A8\u5230\u5305\u542B"{text}"\u7684\u5143\u7D20',scrollTextNotFound:'\u6EDA\u52A8 {count} \u6B21\u672A\u627E\u5230\u5305\u542B"{text}"\u7684\u6587\u672C'}}),A("en",{pageInteraction:{invalidRefSuggest:"Invalid or stale element ref={ref}. ",invalidRefSuggestions:"Nearest valid refs from the latest snapshot: {list}. ",invalidRefTail:"If the page has changed, re-run query_elements",elementNotVisibleError:"Element ref={ref} ({tag}) is not visible; it may be hidden or collapsed",navChangeHint:" (navigation change detected, waited {ms}ms)",domChangeHint:" (DOM change detected, waited {ms}ms)",hoveredByRef:"Hovered element ref={ref} ({tag}){hint}",clickedByRef:"Clicked element ref={ref} ({tag}){hint}",typedByRef:"Typed text into element ref={ref} ({tag}){hint}",typeNotSupported:"Element {tag} does not support text input (use fill_form or click for checkbox/radio)",valueRequired:"value is required when action=type",typeFailed:"Text input failed",textRequired:"text cannot be empty",scrolledToText:'Scrolled to element containing "{text}"',scrollTextNotFound:'Scrolled {count} times but did not find text containing "{text}"'}});var Lt=0,dt=new WeakMap,Re=new Map;function Qt(e,t,o){let n=dt.get(e);return n??(Lt+=1,n=Lt,dt.set(e,n)),Re.set(n,{element:e,selector:null,tag:e.tagName,role:t,name:o}),n}function Nt(e){if(e.selector==null)try{e.selector=Ee(e.element)}catch{e.selector=""}return e.selector}function yt(e){let t=parseInt(e,10);if(!t||!Re.has(t))return{error:Ft(t),suggestions:ut(t)};let o=Re.get(t);if(o.element&&o.element.isConnected)return Nt(o),{entry:o,element:o.element};let n=Nt(o),a=n?I(n):null;return a?(o.element=a,{entry:o,element:a}):{error:Ft(t),suggestions:ut(t)}}function ut(e){return[...Re.entries()].sort((t,o)=>Math.abs(t[0]-e)-Math.abs(o[0]-e)).slice(0,3).map(([t,o])=>({ref:t,role:o.role||o.tag&&o.tag.toLowerCase()||"?",name:o.name||""}))}function Ft(e){let t=u("pageInteraction.invalidRefSuggest",{ref:e}),o=ut(e);if(o.length){let n=o.map(a=>`ref ${a.ref} (${a.role}${a.name?` "${a.name}"`:""})`).join(", ");t+=u("pageInteraction.invalidRefSuggestions",{list:n})}return t+=u("pageInteraction.invalidRefTail"),t}function Oo(e){return yt(e).element||null}var Bo=new Set(["button","link","checkbox","radio","switch","tab","menuitem","menuitemcheckbox","menuitemradio","option","combobox","listbox","searchbox","slider","spinbutton","textbox","treeitem"]),qo=new Set(["dialog","form","navigation","main","banner","contentinfo","table","row","heading"]);function Yt(e){let t=e.getAttribute("role"),o=t?t.trim().split(/\s+/)[0]:"";if(o)return o;let n=e.tagName;if(n==="BUTTON")return"button";if(n==="A")return e.hasAttribute("href")?"link":"";if(n==="SELECT")return e.multiple||e.size>1?"listbox":"combobox";if(n==="TEXTAREA")return"textbox";if(n==="SUMMARY")return"button";if(/^H[1-6]$/.test(n))return"heading";if(n==="NAV")return"navigation";if(n==="MAIN")return"main";if(n==="DIALOG")return"dialog";if(n==="FORM")return"form";if(n==="TABLE")return"table";if(n==="TR")return"row";if(n==="INPUT"){let a=(e.type||"text").toLowerCase();return a==="hidden"?"":a==="checkbox"?"checkbox":a==="radio"?"radio":a==="submit"||a==="button"||a==="reset"?"button":a==="search"?"searchbox":a==="range"?"slider":a==="number"?"spinbutton":"textbox"}return""}function Zt(e){if(e.hasAttribute("hidden")||e.hasAttribute("inert")||e.getAttribute("aria-hidden")==="true"||e.style&&e.style.display==="none")return!0;let t=typeof getComputedStyle=="function"?getComputedStyle(e):null;return!!t&&t.display==="none"}function Ht(e){if(typeof e.checkVisibility=="function")return!e.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=typeof getComputedStyle=="function"?getComputedStyle(e):null;return t?t.display==="none"||t.visibility==="hidden":!1}function _o(){let e=new Set;try{for(let t of document.querySelectorAll('[aria-expanded="true"][aria-controls]'))e.add(t.getAttribute("aria-controls"))}catch{}return e}function Uo(e,t,o){if(e.tagName==="DIALOG"&&e.hasAttribute("open"))return!0;if(e.hasAttribute("popover"))try{if(e.matches(":popover-open"))return!0}catch{}if(e.tagName==="SELECT"||e.tagName==="INPUT"||e.tagName==="TEXTAREA")return!1;let n=document.activeElement;return!!((t==="dialog"||t==="alertdialog")&&(e.getAttribute("aria-modal")==="true"||n&&e.contains(n))||(t==="menu"||t==="listbox")&&n&&e.contains(n)||e.id&&o.has(e.id))}function Xt(e,t){if(Bo.has(t)||e.tagName==="A"&&e.hasAttribute("href"))return!0;if(e.hasAttribute("contenteditable")){let n=e.getAttribute("contenteditable");if(n===""||n==="true"||n==="plaintext-only")return!0}let o=e.getAttribute("tabindex");return!!(o!==null&&parseInt(o,10)>=0||e.hasAttribute("onclick"))}function Jt(e){let t=[];return e.shadowRoot&&t.push(...e.shadowRoot.children),t.push(...e.children),t}function pt(e,t){let o=(d,p=80)=>{if(!d)return"";let m=String(d).replace(/\s+/g," ").trim();return m.length>p?m.slice(0,p-1)+"\u2026":m},n=d=>o(d?d.textContent:"");if(e.tagName==="SELECT"){let d=e.options&&e.options[e.selectedIndex];if(d&&d.text)return o(d.text)}let a=e.getAttribute("aria-labelledby");if(a){let d=a.split(/\s+/).map(p=>document.getElementById(p)).filter(Boolean).map(p=>n(p)).filter(Boolean).join(" ");if(d)return d}let i=e.getAttribute("aria-label");if(i)return o(i);if(e.id)try{let d=document.querySelector(`label[for="${CSS.escape(e.id)}"]`);if(d){let p=n(d);if(p)return p}}catch{}let r=e.closest&&e.closest("label");if(r){let d=n(r);if(d)return d}if(e.getAttribute("placeholder"))return o(e.getAttribute("placeholder"));if(e.getAttribute("title"))return o(e.getAttribute("title"));if(e.getAttribute("alt"))return o(e.getAttribute("alt"));if(e.tagName==="INPUT"){let d=(e.type||"").toLowerCase();if((d==="submit"||d==="button"||d==="reset")&&e.value)return o(e.value)}let l="";for(let d of e.childNodes)d.nodeType===3&&(l+=d.textContent);l.trim()||(l=e.textContent||"");let s=o(l);if(s)return s;let c=e.previousElementSibling;for(;c&&!(c.textContent||"").trim();)c=c.previousElementSibling;if(c&&!c.querySelector("button, a[href], input, select, textarea")){let d=n(c);if(d)return d}return""}function Ko(e,t){let o=[],n=(i,r)=>i&&i.length>r?i.slice(0,r-1)+"\u2026":i;if(t==="link"&&e.getAttribute("href")&&o.push(`href="${n(e.getAttribute("href"),150)}"`),e.tagName==="INPUT"){let i=(e.type||"text").toLowerCase();i!=="text"&&i!=="checkbox"&&i!=="radio"&&o.push(`type="${i}"`)}let a=e.getAttribute("placeholder");return a&&o.push(`placeholder="${n(a,60)}"`),(e.tagName==="INPUT"||e.tagName==="TEXTAREA")&&e.value&&o.push(`value="${n(e.value,60)}"`),e.tagName==="INPUT"&&(e.type==="checkbox"||e.type==="radio")&&e.checked&&o.push('checked="true"'),e.tagName==="OPTION"&&e.selected&&o.push('selected="true"'),o.join(" ")}var Go=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;function Wo(){return window.innerWidth>0&&window.innerHeight>0}function $o(e,t,o){if(!o||!o.length)return!0;let n=e.tagName.toLowerCase(),a=e.tagName==="INPUT"?(e.type||"").toLowerCase():"";return o.some(i=>i===n||i===a||i===t)}function zo(e,t,o){return o?`${t} ${e.textContent||""} ${e.value||""}`.toLowerCase().includes(String(o).toLowerCase()):!0}function Vo(e={}){let{filterByText:t="",elementTypes:o=null,page:n=1,maxResults:a=100,maxChars:i=6e3,countOnly:r=!1}=e;try{let l=eo({filterByText:t,elementTypes:o,frames:"none"});return l.success?It({frames:[{frameIndex:0,depth:0,isTop:!0,frameInfo:l.frameInfo,overlayTrees:l.overlayTrees,bodyTree:l.bodyTree}],page:n,maxResults:a,maxChars:i,countOnly:r}):l}catch(l){return console.error("[PageInteraction] queryInteractiveElements failed:",l),{success:!1,error:l.message}}}function jo(e,t,o){let n=e.getAttribute("title")||"",a="";try{a=e.src||""}catch{}a||=e.getAttribute("src")||"";let i=null;try{let l=e.contentWindow&&e.contentWindow.location.href;typeof l=="string"&&(i=l)}catch{}let r=o.iframeOrder.has(e)?o.iframeOrder.get(e):-1;return{t:"frame",title:n,srcUrl:a,sameOriginHref:i,orderInParent:r,depth:t}}function mt(e,t,o,n){if(Zt(e)||n.skipRoots&&n.skipRoots.has(e))return!1;let a=Yt(e),i=Xt(e,a),r=!i&&qo.has(a)?a:null,l=t+(i||r?1:0);if(n.frames==="auto"&&e.tagName==="IFRAME")return o.push(jo(e,t,n)),!0;let s=[],c=!1;for(let d of Jt(e))mt(d,l,s,n)&&(c=!0);if(i&&n.matchedSet.has(e)){let d=a||e.tagName.toLowerCase(),p=pt(e,d);return o.push({t:"el",localRef:dt.get(e)??Qt(e,d,p),role:d,name:p,attrs:Ko(e,d),depth:t,children:s}),!0}if(r&&c){let d=r==="dialog"||r==="heading"?pt(e,a):"";return o.push({t:"container",role:r,name:d,depth:t,children:s}),!0}return c?(o.push(...s),!0):!1}function eo(e={}){let{filterByText:t="",elementTypes:o=null,frames:n="none"}=e;try{Re.clear();let a=_o(),i=[],r=[];to(document.body,{matched:r,filterByText:t,elementTypes:o,overlayRoots:i,expandedTargets:a});for(let p of r)Qt(p.el,p.role,p.name);let l=new Map;try{document.querySelectorAll("iframe").forEach((p,m)=>l.set(p,m))}catch{}let s={matchedSet:new Set(r.map(p=>p.el)),frames:n,iframeOrder:l,skipRoots:null},c=[];for(let p of i){let m=[];mt(p,0,m,s),c.push(...m)}s.skipRoots=new Set(i);let d=[];return mt(document.body,0,d,s),{success:!0,frameInfo:{url:location.href,title:document.title||"",width:window.innerWidth,height:window.innerHeight,loadId:Go},overlayTrees:c,bodyTree:d}}catch(a){return console.error("[PageInteraction] collectSnapshotOps failed:",a),{success:!1,error:a.message}}}function to(e,{matched:t,filterByText:o,elementTypes:n,overlayRoots:a,expandedTargets:i,inOverlay:r=!1}){if(Zt(e))return;let l=Yt(e),s=r;if(!s&&!Ht(e)&&Uo(e,l,i)&&(a.push(e),s=!0),Xt(e,l)&&!Ht(e)&&$o(e,l,n)){let c=l||e.tagName.toLowerCase(),d=pt(e,c);zo(e,d,o)&&t.push({el:e,role:c,name:d,inOverlay:s})}for(let c of Jt(e))to(c,{matched:t,filterByText:o,elementTypes:n,overlayRoots:a,expandedTargets:i,inOverlay:s})}function Qo(e={}){let{scrollPixels:t=800,maxScrolls:o=20,pauseMs:n=500,selector:a}=e;return new Promise(async i=>{try{let r=a?document.querySelector(a):null,l=()=>{let f=r||document.body,y=document.createTreeWalker(f,NodeFilter.SHOW_TEXT),w="",v;for(;v=y.nextNode();){let S=v.parentElement;if(!S)continue;let E=S.getBoundingClientRect();if(E.bottom>-100&&E.top<window.innerHeight+100){let U=v.textContent.trim();U&&(w+=U+`
|
|
76
|
+
`,document.head.appendChild(f),Dt(document.body,new RegExp(s,c),r)}return{success:!0,pattern:s,mode:"regex",total:m.length,matches:m,highlighted:l}}catch(t){return{success:!1,error:t.message}}}A("zh",{pageInteraction:{invalidRefSuggest:"\u65E0\u6548\u6216\u5DF2\u8FC7\u671F\u7684\u5143\u7D20\u5F15\u7528 ref={ref}\u3002",invalidRefSuggestions:"\u6700\u8FD1\u5FEB\u7167\u4E2D\u7684\u6709\u6548\u5F15\u7528\uFF1A{list}\u3002",invalidRefTail:"\u5982\u9875\u9762\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u8C03\u7528 query_elements \u83B7\u53D6\u6700\u65B0\u5FEB\u7167",elementNotVisibleError:"\u5143\u7D20 ref={ref}\uFF08{tag}\uFF09\u5F53\u524D\u4E0D\u53EF\u89C1\uFF0C\u53EF\u80FD\u88AB\u9690\u85CF\u6216\u6298\u53E0",navChangeHint:"\uFF08\u68C0\u6D4B\u5230\u5BFC\u822A\u53D8\u5316\uFF0C\u5DF2\u7B49\u5F85 {ms}ms\uFF09",domChangeHint:"\uFF08\u68C0\u6D4B\u5230DOM\u53D8\u5316\uFF0C\u5DF2\u7B49\u5F85 {ms}ms\uFF09",hoveredByRef:"\u5DF2\u60AC\u505C\u5143\u7D20 ref={ref}\uFF08{tag}\uFF09{hint}",clickedByRef:"\u5DF2\u70B9\u51FB\u5143\u7D20 ref={ref}\uFF08{tag}\uFF09{hint}",typedByRef:"\u5DF2\u5411\u5143\u7D20 ref={ref}\uFF08{tag}\uFF09\u8F93\u5165\u6587\u672C{hint}",typeNotSupported:"\u5143\u7D20 {tag} \u4E0D\u652F\u6301\u6587\u672C\u8F93\u5165\uFF08checkbox/radio \u8BF7\u7528 fill_form \u6216 click\uFF09",valueRequired:"action=type \u65F6 value \u4E0D\u80FD\u4E3A\u7A7A",typeFailed:"\u6587\u672C\u8F93\u5165\u5931\u8D25",textRequired:"text \u4E0D\u80FD\u4E3A\u7A7A",scrolledToText:'\u5DF2\u6EDA\u52A8\u5230\u5305\u542B"{text}"\u7684\u5143\u7D20',scrollTextNotFound:'\u6EDA\u52A8 {count} \u6B21\u672A\u627E\u5230\u5305\u542B"{text}"\u7684\u6587\u672C'}}),A("en",{pageInteraction:{invalidRefSuggest:"Invalid or stale element ref={ref}. ",invalidRefSuggestions:"Nearest valid refs from the latest snapshot: {list}. ",invalidRefTail:"If the page has changed, re-run query_elements",elementNotVisibleError:"Element ref={ref} ({tag}) is not visible; it may be hidden or collapsed",navChangeHint:" (navigation change detected, waited {ms}ms)",domChangeHint:" (DOM change detected, waited {ms}ms)",hoveredByRef:"Hovered element ref={ref} ({tag}){hint}",clickedByRef:"Clicked element ref={ref} ({tag}){hint}",typedByRef:"Typed text into element ref={ref} ({tag}){hint}",typeNotSupported:"Element {tag} does not support text input (use fill_form or click for checkbox/radio)",valueRequired:"value is required when action=type",typeFailed:"Text input failed",textRequired:"text cannot be empty",scrolledToText:'Scrolled to element containing "{text}"',scrollTextNotFound:'Scrolled {count} times but did not find text containing "{text}"'}});var Lt=0,dt=new WeakMap,Re=new Map;function Qt(e,t,o){let n=dt.get(e);return n??(Lt+=1,n=Lt,dt.set(e,n)),Re.set(n,{element:e,selector:null,tag:e.tagName,role:t,name:o}),n}function Nt(e){if(e.selector==null)try{e.selector=Ee(e.element)}catch{e.selector=""}return e.selector}function yt(e){let t=parseInt(e,10);if(!t||!Re.has(t))return{error:Ft(t),suggestions:ut(t)};let o=Re.get(t);if(o.element&&o.element.isConnected)return Nt(o),{entry:o,element:o.element};let n=Nt(o),a=n?P(n):null;return a?(o.element=a,{entry:o,element:a}):{error:Ft(t),suggestions:ut(t)}}function ut(e){return[...Re.entries()].sort((t,o)=>Math.abs(t[0]-e)-Math.abs(o[0]-e)).slice(0,3).map(([t,o])=>({ref:t,role:o.role||o.tag&&o.tag.toLowerCase()||"?",name:o.name||""}))}function Ft(e){let t=u("pageInteraction.invalidRefSuggest",{ref:e}),o=ut(e);if(o.length){let n=o.map(a=>`ref ${a.ref} (${a.role}${a.name?` "${a.name}"`:""})`).join(", ");t+=u("pageInteraction.invalidRefSuggestions",{list:n})}return t+=u("pageInteraction.invalidRefTail"),t}function Oo(e){return yt(e).element||null}var Bo=new Set(["button","link","checkbox","radio","switch","tab","menuitem","menuitemcheckbox","menuitemradio","option","combobox","listbox","searchbox","slider","spinbutton","textbox","treeitem"]),qo=new Set(["dialog","form","navigation","main","banner","contentinfo","table","row","heading"]);function Yt(e){let t=e.getAttribute("role"),o=t?t.trim().split(/\s+/)[0]:"";if(o)return o;let n=e.tagName;if(n==="BUTTON")return"button";if(n==="A")return e.hasAttribute("href")?"link":"";if(n==="SELECT")return e.multiple||e.size>1?"listbox":"combobox";if(n==="TEXTAREA")return"textbox";if(n==="SUMMARY")return"button";if(/^H[1-6]$/.test(n))return"heading";if(n==="NAV")return"navigation";if(n==="MAIN")return"main";if(n==="DIALOG")return"dialog";if(n==="FORM")return"form";if(n==="TABLE")return"table";if(n==="TR")return"row";if(n==="INPUT"){let a=(e.type||"text").toLowerCase();return a==="hidden"?"":a==="checkbox"?"checkbox":a==="radio"?"radio":a==="submit"||a==="button"||a==="reset"?"button":a==="search"?"searchbox":a==="range"?"slider":a==="number"?"spinbutton":"textbox"}return""}function Zt(e){if(e.hasAttribute("hidden")||e.hasAttribute("inert")||e.getAttribute("aria-hidden")==="true"||e.style&&e.style.display==="none")return!0;let t=typeof getComputedStyle=="function"?getComputedStyle(e):null;return!!t&&t.display==="none"}function Ht(e){if(typeof e.checkVisibility=="function")return!e.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=typeof getComputedStyle=="function"?getComputedStyle(e):null;return t?t.display==="none"||t.visibility==="hidden":!1}function _o(){let e=new Set;try{for(let t of document.querySelectorAll('[aria-expanded="true"][aria-controls]'))e.add(t.getAttribute("aria-controls"))}catch{}return e}function Uo(e,t,o){if(e.tagName==="DIALOG"&&e.hasAttribute("open"))return!0;if(e.hasAttribute("popover"))try{if(e.matches(":popover-open"))return!0}catch{}if(e.tagName==="SELECT"||e.tagName==="INPUT"||e.tagName==="TEXTAREA")return!1;let n=document.activeElement;return!!((t==="dialog"||t==="alertdialog")&&(e.getAttribute("aria-modal")==="true"||n&&e.contains(n))||(t==="menu"||t==="listbox")&&n&&e.contains(n)||e.id&&o.has(e.id))}function Xt(e,t){if(Bo.has(t)||e.tagName==="A"&&e.hasAttribute("href"))return!0;if(e.hasAttribute("contenteditable")){let n=e.getAttribute("contenteditable");if(n===""||n==="true"||n==="plaintext-only")return!0}let o=e.getAttribute("tabindex");return!!(o!==null&&parseInt(o,10)>=0||e.hasAttribute("onclick"))}function Jt(e){let t=[];return e.shadowRoot&&t.push(...e.shadowRoot.children),t.push(...e.children),t}function pt(e,t){let o=(d,p=80)=>{if(!d)return"";let m=String(d).replace(/\s+/g," ").trim();return m.length>p?m.slice(0,p-1)+"\u2026":m},n=d=>o(d?d.textContent:"");if(e.tagName==="SELECT"){let d=e.options&&e.options[e.selectedIndex];if(d&&d.text)return o(d.text)}let a=e.getAttribute("aria-labelledby");if(a){let d=a.split(/\s+/).map(p=>document.getElementById(p)).filter(Boolean).map(p=>n(p)).filter(Boolean).join(" ");if(d)return d}let i=e.getAttribute("aria-label");if(i)return o(i);if(e.id)try{let d=document.querySelector(`label[for="${CSS.escape(e.id)}"]`);if(d){let p=n(d);if(p)return p}}catch{}let r=e.closest&&e.closest("label");if(r){let d=n(r);if(d)return d}if(e.getAttribute("placeholder"))return o(e.getAttribute("placeholder"));if(e.getAttribute("title"))return o(e.getAttribute("title"));if(e.getAttribute("alt"))return o(e.getAttribute("alt"));if(e.tagName==="INPUT"){let d=(e.type||"").toLowerCase();if((d==="submit"||d==="button"||d==="reset")&&e.value)return o(e.value)}let l="";for(let d of e.childNodes)d.nodeType===3&&(l+=d.textContent);l.trim()||(l=e.textContent||"");let s=o(l);if(s)return s;let c=e.previousElementSibling;for(;c&&!(c.textContent||"").trim();)c=c.previousElementSibling;if(c&&!c.querySelector("button, a[href], input, select, textarea")){let d=n(c);if(d)return d}return""}function Ko(e,t){let o=[],n=(i,r)=>i&&i.length>r?i.slice(0,r-1)+"\u2026":i;if(t==="link"&&e.getAttribute("href")&&o.push(`href="${n(e.getAttribute("href"),150)}"`),e.tagName==="INPUT"){let i=(e.type||"text").toLowerCase();i!=="text"&&i!=="checkbox"&&i!=="radio"&&o.push(`type="${i}"`)}let a=e.getAttribute("placeholder");return a&&o.push(`placeholder="${n(a,60)}"`),(e.tagName==="INPUT"||e.tagName==="TEXTAREA")&&e.value&&o.push(`value="${n(e.value,60)}"`),e.tagName==="INPUT"&&(e.type==="checkbox"||e.type==="radio")&&e.checked&&o.push('checked="true"'),e.tagName==="OPTION"&&e.selected&&o.push('selected="true"'),o.join(" ")}var Go=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;function Wo(){return window.innerWidth>0&&window.innerHeight>0}function $o(e,t,o){if(!o||!o.length)return!0;let n=e.tagName.toLowerCase(),a=e.tagName==="INPUT"?(e.type||"").toLowerCase():"";return o.some(i=>i===n||i===a||i===t)}function zo(e,t,o){return o?`${t} ${e.textContent||""} ${e.value||""}`.toLowerCase().includes(String(o).toLowerCase()):!0}function Vo(e={}){let{filterByText:t="",elementTypes:o=null,page:n=1,maxResults:a=100,maxChars:i=6e3,countOnly:r=!1}=e;try{let l=eo({filterByText:t,elementTypes:o,frames:"none"});return l.success?It({frames:[{frameIndex:0,depth:0,isTop:!0,frameInfo:l.frameInfo,overlayTrees:l.overlayTrees,bodyTree:l.bodyTree}],page:n,maxResults:a,maxChars:i,countOnly:r}):l}catch(l){return console.error("[PageInteraction] queryInteractiveElements failed:",l),{success:!1,error:l.message}}}function jo(e,t,o){let n=e.getAttribute("title")||"",a="";try{a=e.src||""}catch{}a||=e.getAttribute("src")||"";let i=null;try{let l=e.contentWindow&&e.contentWindow.location.href;typeof l=="string"&&(i=l)}catch{}let r=o.iframeOrder.has(e)?o.iframeOrder.get(e):-1;return{t:"frame",title:n,srcUrl:a,sameOriginHref:i,orderInParent:r,depth:t}}function mt(e,t,o,n){if(Zt(e)||n.skipRoots&&n.skipRoots.has(e))return!1;let a=Yt(e),i=Xt(e,a),r=!i&&qo.has(a)?a:null,l=t+(i||r?1:0);if(n.frames==="auto"&&e.tagName==="IFRAME")return o.push(jo(e,t,n)),!0;let s=[],c=!1;for(let d of Jt(e))mt(d,l,s,n)&&(c=!0);if(i&&n.matchedSet.has(e)){let d=a||e.tagName.toLowerCase(),p=pt(e,d);return o.push({t:"el",localRef:dt.get(e)??Qt(e,d,p),role:d,name:p,attrs:Ko(e,d),depth:t,children:s}),!0}if(r&&c){let d=r==="dialog"||r==="heading"?pt(e,a):"";return o.push({t:"container",role:r,name:d,depth:t,children:s}),!0}return c?(o.push(...s),!0):!1}function eo(e={}){let{filterByText:t="",elementTypes:o=null,frames:n="none"}=e;try{Re.clear();let a=_o(),i=[],r=[];to(document.body,{matched:r,filterByText:t,elementTypes:o,overlayRoots:i,expandedTargets:a});for(let p of r)Qt(p.el,p.role,p.name);let l=new Map;try{document.querySelectorAll("iframe").forEach((p,m)=>l.set(p,m))}catch{}let s={matchedSet:new Set(r.map(p=>p.el)),frames:n,iframeOrder:l,skipRoots:null},c=[];for(let p of i){let m=[];mt(p,0,m,s),c.push(...m)}s.skipRoots=new Set(i);let d=[];return mt(document.body,0,d,s),{success:!0,frameInfo:{url:location.href,title:document.title||"",width:window.innerWidth,height:window.innerHeight,loadId:Go},overlayTrees:c,bodyTree:d}}catch(a){return console.error("[PageInteraction] collectSnapshotOps failed:",a),{success:!1,error:a.message}}}function to(e,{matched:t,filterByText:o,elementTypes:n,overlayRoots:a,expandedTargets:i,inOverlay:r=!1}){if(Zt(e))return;let l=Yt(e),s=r;if(!s&&!Ht(e)&&Uo(e,l,i)&&(a.push(e),s=!0),Xt(e,l)&&!Ht(e)&&$o(e,l,n)){let c=l||e.tagName.toLowerCase(),d=pt(e,c);zo(e,d,o)&&t.push({el:e,role:c,name:d,inOverlay:s})}for(let c of Jt(e))to(c,{matched:t,filterByText:o,elementTypes:n,overlayRoots:a,expandedTargets:i,inOverlay:s})}function Qo(e={}){let{scrollPixels:t=800,maxScrolls:o=20,pauseMs:n=500,selector:a}=e;return new Promise(async i=>{try{let r=a?document.querySelector(a):null,l=()=>{let f=r||document.body,y=document.createTreeWalker(f,NodeFilter.SHOW_TEXT),w="",v;for(;v=y.nextNode();){let S=v.parentElement;if(!S)continue;let E=S.getBoundingClientRect();if(E.bottom>-100&&E.top<window.innerHeight+100){let U=v.textContent.trim();U&&(w+=U+`
|
|
77
77
|
`)}}return w},s=r||document.scrollingElement||document.documentElement,c="",d=window.scrollY,p=0;for(let f=0;f<o;f++){let y=l();c+=y+`
|
|
78
78
|
`;let w=window.scrollY;if(s.scrollBy({top:t,behavior:"auto"}),p++,await new Promise(v=>setTimeout(v,n)),Math.abs(window.scrollY-w)<5&&(await new Promise(v=>setTimeout(v,n)),Math.abs(window.scrollY-w)<5))break}r&&s.scrollTo({top:d,behavior:"auto"});let m=c.split(`
|
|
79
79
|
`),h=[];for(let f of m){let y=f.trim();y&&y!==h[h.length-1]&&h.push(y)}i({success:!0,content:h.join(`
|
|
80
80
|
`),contentLength:h.join(`
|
|
81
81
|
`).length,scrolls:p,startScrollY:d,endScrollY:window.scrollY})}catch(r){i({success:!1,error:r.message})}})}async function Yo(e,t="click",o={}){let{waitTime:n=300,timeout:a=2e3}=o,i=V(n,z.actionMinWait),r=V(a,z.actionWait),l=parseInt(e,10),s=yt(l);if(s.error)return{success:!1,error:s.error,...s.suggestions&&s.suggestions.length?{suggestions:s.suggestions}:{}};let{entry:c,element:d}=s,p=window.getComputedStyle(d);if(p.display==="none"||p.visibility==="hidden")return{success:!1,error:u("pageInteraction.elementNotVisibleError",{ref:e,tag:c.tag})};if(t==="type"){let y=ee(),w=Zo(d,o.value,o);if(!w.success)return{success:!1,error:w.error};let v=await te(y,i,r),S=v.changed?u(v.urlChanged?"pageInteraction.navChangeHint":"pageInteraction.domChangeHint",{ms:v.waitedMs}):"";return{success:!0,message:u("pageInteraction.typedByRef",{ref:l,tag:c.tag,hint:S}),...v}}if(t==="hover"){let y=ee();d.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0,view:window})),d.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0,view:window}));let w=await te(y,i,r),v=w.changed?u(w.urlChanged?"pageInteraction.navChangeHint":"pageInteraction.domChangeHint",{ms:w.waitedMs}):"";return{success:!0,message:u("pageInteraction.hoveredByRef",{ref:e,tag:c.tag,hint:v}),...w}}let m=ee();d.click();let h=await te(m,i,r),f=h.changed?u(h.urlChanged?"pageInteraction.navChangeHint":"pageInteraction.domChangeHint",{ms:h.waitedMs}):"";return{success:!0,message:u("pageInteraction.clickedByRef",{ref:e,tag:c.tag,hint:f}),...h}}function Zo(e,t,{clear:o=!1,submit:n=!1}={}){if(t==null||t==="")return{success:!1,error:u("pageInteraction.valueRequired")};let a=e.tagName,i=jt(e);if(a==="INPUT"){let r=(e.type||"text").toLowerCase();if(["checkbox","radio","file","submit","button","reset","image"].includes(r))return{success:!1,error:u("pageInteraction.typeNotSupported",{tag:`<input type="${r}">`})}}else if(a!=="TEXTAREA"&&!i)return{success:!1,error:u("pageInteraction.typeNotSupported",{tag:`<${a.toLowerCase()}>`})};try{e.focus()}catch{}if(i&&a!=="INPUT"&&a!=="TEXTAREA"){if(o&&_e(e,""),!_e(e,t))return{success:!1,error:u("pageInteraction.typeFailed")}}else o&&(qe(e,""),e.dispatchEvent(new Event("input",{bubbles:!0}))),qe(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}));if(n){let r={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0};e.dispatchEvent(new KeyboardEvent("keydown",r)),e.dispatchEvent(new KeyboardEvent("keypress",r)),e.dispatchEvent(new KeyboardEvent("keyup",r))}return{success:!0}}async function Xo(e,t={}){let{maxScrolls:o=20,pauseMs:n=500}=t;if(!e)return{success:!1,error:u("pageInteraction.textRequired")};let a=e.toLowerCase(),i=()=>{let l=le("h1, h2, h3, h4, h5, h6, p, span, a, button, li, td, th, label, div");for(let s of l){let c=Array.from(s.childNodes).filter(d=>d.nodeType===Node.TEXT_NODE).map(d=>d.textContent).join("").trim();if(c&&c.toLowerCase().includes(a))return s}return null},r=i();if(r)return r.scrollIntoView({behavior:"smooth",block:"center"}),await new Promise(l=>setTimeout(l,300)),{success:!0,message:u("pageInteraction.scrolledToText",{text:e}),selector:Ee(r),scrolls:0};for(let l=0;l<o;l++){let s=window.scrollY;if(window.scrollBy({top:Math.floor(window.innerHeight*.8),behavior:"auto"}),await new Promise(c=>setTimeout(c,n)),r=i(),r)return r.scrollIntoView({behavior:"smooth",block:"center"}),await new Promise(c=>setTimeout(c,300)),{success:!0,message:u("pageInteraction.scrolledToText",{text:e}),selector:Ee(r),scrolls:l+1};if(Math.abs(window.scrollY-s)<5&&(await new Promise(c=>setTimeout(c,n)),Math.abs(window.scrollY-s)<5))break}return{success:!1,error:u("pageInteraction.scrollTextNotFound",{count:o,text:e}),scrolls:o}}A("zh",{pageTools:{noSelection:"\u5F53\u524D\u6CA1\u6709\u9009\u4E2D\u7684\u5185\u5BB9",tableNotFound:"\u672A\u627E\u5230\u5339\u914D\u9009\u62E9\u5668\u7684\u8868\u683C: {selector}",emptyTable:"\u8868\u683C\u4E3A\u7A7A",copiedToClipboard:"\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F",copiedToClipboardFallback:"\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F\uFF08\u964D\u7EA7\u65B9\u6848\uFF09",elementNotFound:"\u672A\u627E\u5230\u5143\u7D20: {selector}",navChangeHint:"\uFF08\u68C0\u6D4B\u5230\u5BFC\u822A\u53D8\u5316\uFF0C\u5DF2\u7B49\u5F85 {ms}ms\uFF09",domChangeHint:"\uFF08\u68C0\u6D4B\u5230DOM\u53D8\u5316\uFF0C\u5DF2\u7B49\u5F85 {ms}ms\uFF09",hoverTriggered:"\u5DF2\u5728\u5143\u7D20\u4E0A\u89E6\u53D1\u60AC\u505C\u6548\u679C: {selector}{hint}",noHighlightText:"\u672A\u63D0\u4F9B\u8981\u9AD8\u4EAE\u7684\u6587\u672C",highlightedCount:"\u5DF2\u9AD8\u4EAE {count} \u5904\u6587\u672C"}}),A("en",{pageTools:{noSelection:"No content selected",tableNotFound:"No table found matching selector: {selector}",emptyTable:"Table is empty",copiedToClipboard:"Copied to clipboard",copiedToClipboardFallback:"Copied to clipboard (fallback method)",elementNotFound:"Element not found: {selector}",navChangeHint:" (navigation change detected, waited {ms}ms)",domChangeHint:" (DOM change detected, waited {ms}ms)",hoverTriggered:"Hover triggered on element: {selector}{hint}",noHighlightText:"No text provided to highlight",highlightedCount:"Highlighted {count} occurrences"}});function Jo(e={}){let{maxLength:t=5e4,includeHeadings:o=!0,includeLinks:n=!0}=e,a=Ce(),i={title:document.title||"",url:window.location.href,content:a.substring(0,t),wordCount:a.split(/\s+/).length};return o&&(i.headings=Array.from(le("h1, h2, h3, h4, h5, h6")).map(r=>({level:r.tagName,text:r.textContent.trim()})).filter(r=>r.text.length>0).slice(0,30)),n&&(i.links=Array.from(le("a")).map(r=>({text:r.textContent.trim(),href:r.href})).filter(r=>r.text.length>0).slice(0,50)),{success:!0,data:i}}function en(e={}){let{includeStyles:t=!1,maxLength:o=5e4}=e,n=Be();return t||(n=n.replace(/\s*style="[^"]*"/gi,"")),{success:!0,content:JSON.stringify({title:document.title,url:window.location.href,html:n.substring(0,o),fullLength:n.length})}}function tn(e="text"){try{let t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount===0)return{success:!1,error:u("pageTools.noSelection")};let o={success:!0,data:{selectedCount:t.rangeCount,text:""}};if(e==="html"){let n=[];for(let a=0;a<t.rangeCount;a++){let i=t.getRangeAt(a).cloneContents(),r=document.createElement("div");r.appendChild(i),n.push(r.innerHTML)}o.data.html=n.join(`
|
|
82
|
-
`),o.data.text=t.toString()}else o.data.text=t.toString();return o}catch(t){return{success:!1,error:t.message}}}function on(e="table",t=!0,o="json"){try{let n=
|
|
82
|
+
`),o.data.text=t.toString()}else o.data.text=t.toString();return o}catch(t){return{success:!1,error:t.message}}}function on(e="table",t=!0,o="json"){try{let n=P(e);if(!n)return{success:!1,error:u("pageTools.tableNotFound",{selector:e})};let a=Array.from(n.querySelectorAll("tr")),i=[];return a.forEach((r,l)=>{let s=Array.from(r.querySelectorAll("td, th")).map(c=>c.textContent.trim());(t||l>0)&&i.push(s)}),o==="markdown"?i.length===0?{success:!0,content:u("pageTools.emptyTable")}:{success:!0,content:`${`| ${i[0].join(" | ")} |`}
|
|
83
83
|
${`| ${i[0].map(()=>"---").join(" | ")} |`}
|
|
84
84
|
${i.slice(1).map(r=>`| ${r.join(" | ")} |`).join(`
|
|
85
|
-
`)}`}:{success:!0,content:JSON.stringify({data:i,rowCount:i.length,columnCount:i[0]?.length||0}),data:i}}catch(n){return{success:!1,error:n.message}}}async function nn(e){try{return await navigator.clipboard.writeText(e),{success:!0,message:u("pageTools.copiedToClipboard")}}catch{try{let t=document.createElement("textarea");return t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),{success:!0,message:u("pageTools.copiedToClipboardFallback")}}catch(t){return{success:!1,error:t.message}}}}async function an(){try{return{success:!0,content:await navigator.clipboard.readText()}}catch(e){return{success:!1,error:e.message}}}async function rn(e){try{let t=
|
|
85
|
+
`)}`}:{success:!0,content:JSON.stringify({data:i,rowCount:i.length,columnCount:i[0]?.length||0}),data:i}}catch(n){return{success:!1,error:n.message}}}async function nn(e){try{return await navigator.clipboard.writeText(e),{success:!0,message:u("pageTools.copiedToClipboard")}}catch{try{let t=document.createElement("textarea");return t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),{success:!0,message:u("pageTools.copiedToClipboardFallback")}}catch(t){return{success:!1,error:t.message}}}}async function an(){try{return{success:!0,content:await navigator.clipboard.readText()}}catch(e){return{success:!1,error:e.message}}}async function rn(e){try{let t=P(e);if(!t)return{success:!1,error:u("pageTools.elementNotFound",{selector:e})};let o=ee();t.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0,view:window})),t.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0,view:window}));let n=await te(o,300,2e3);return{success:!0,message:u("pageTools.hoverTriggered",{selector:e,hint:n.changed?n.urlChanged?u("pageTools.navChangeHint",{ms:n.waitedMs}):u("pageTools.domChangeHint",{ms:n.waitedMs}):""}),...n}}catch(t){return{success:!1,error:t.message}}}function ln(e,t="yellow"){try{if(!e)return{success:!1,error:u("pageTools.noHighlightText")};ct();let o=document.createElement("style");o.id="ai-helper-highlight-style",o.textContent=`
|
|
86
86
|
.ai-helper-highlight {
|
|
87
87
|
background-color: ${t} !important;
|
|
88
88
|
padding: 2px 0;
|
|
89
89
|
}
|
|
90
|
-
`,document.head.appendChild(o);let n=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,null,!1),a=[],i;for(;i=n.nextNode();)i.nodeValue.toLowerCase().includes(e.toLowerCase())&&a.push(i);let r=[];return a.forEach(l=>{let s=l.parentNode;if(!s||!s.replaceChild||!s.insertBefore)return;let c=l.nodeValue,d=c.toLowerCase(),p=c.toLowerCase(),m=d.indexOf(p);if(m!==-1){let h=document.createElement("span");h.className="ai-helper-highlight",h.textContent=c.substring(m,m+c.length);let f=document.createTextNode(c.substring(0,m)),y=document.createTextNode(c.substring(m+c.length));s.replaceChild(y,l),s.insertBefore(h,y),s.insertBefore(f,h),r.push(h)}}),r.length>0&&r[0].scrollIntoView({behavior:"smooth",block:"center"}),{success:!0,message:u("pageTools.highlightedCount",{count:r.length}),count:r.length}}catch(o){return{success:!1,error:o.message}}}A("zh",{interactionTools:{selectorRequired:"\u9009\u62E9\u5668\u4E0D\u80FD\u4E3A\u7A7A",elementNotFoundBySelector:"\u672A\u627E\u5230\u5339\u914D\u9009\u62E9\u5668\u7684\u5143\u7D20: {selector}",navChangeHint:"\uFF08\u68C0\u6D4B\u5230\u5BFC\u822A\u53D8\u5316\uFF0C\u5DF2\u7B49\u5F85 {ms}ms\uFF09",domChangeHint:"\uFF08\u68C0\u6D4B\u5230DOM\u53D8\u5316\uFF0C\u5DF2\u7B49\u5F85 {ms}ms\uFF09",clickedElement:"\u5DF2\u70B9\u51FB\u5143\u7D20: {selector}{hint}",elementNotFound:"\u672A\u627E\u5230\u5143\u7D20",optionNotFound:"\u672A\u627E\u5230\u5339\u914D\u7684\u9009\u9879",radioButtonNotFound:"\u672A\u627E\u5230\u5339\u914D\u7684\u5355\u9009\u6309\u94AE",formFillComplete:"\u8868\u5355\u586B\u5145\u5B8C\u6210\uFF0C\u6210\u529F {success}/{total} \u4E2A\u5B57\u6BB5",elementNotFoundShort:"\u672A\u627E\u5230\u5143\u7D20: {selector}",invalidScrollTarget:"\u65E0\u6548\u7684\u6EDA\u52A8\u76EE\u6807\u6216\u7F3A\u5C11\u9009\u62E9\u5668",scrollComplete:"\u6EDA\u52A8\u5B8C\u6210",elementAppeared:"\u5143\u7D20 {selector} \u5DF2\u51FA\u73B0",elementDisappeared:"\u5143\u7D20 {selector} \u5DF2\u6D88\u5931",elementVisible:"\u5143\u7D20 {selector} \u5DF2\u53EF\u89C1",elementHidden:"\u5143\u7D20 {selector} \u5DF2\u9690\u85CF",waitTimeout:"\u7B49\u5F85\u8D85\u65F6\uFF08{timeout}ms\uFF09\uFF0C\u5143\u7D20 {selector} \u672A\u8FBE\u5230 {state} \u72B6\u6001",noFocusedElement:"\u6CA1\u6709\u805A\u7126\u7684\u5143\u7D20",keyboardInputSuccess:"\u952E\u76D8\u8F93\u5165\u6210\u529F{hint}",fileUploadNotFound:"\u672A\u627E\u5230\u6587\u4EF6\u4E0A\u4F20\u63A7\u4EF6: {selector}",notFileUploadControl:"\u9009\u62E9\u7684\u5143\u7D20\u4E0D\u662F\u6587\u4EF6\u4E0A\u4F20\u63A7\u4EF6",fileUploaded:"\u5DF2\u4E0A\u4F20\u6587\u4EF6: {fileName}",textRequired:"text \u4E0D\u80FD\u4E3A\u7A7A",hoveredByText:'\u5DF2\u60AC\u505C\u6587\u672C"{text}"\u5BF9\u5E94\u7684{tag}\u5143\u7D20{hint}',clickedByText:'\u5DF2\u70B9\u51FB\u6587\u672C"{text}"\u5BF9\u5E94\u7684{tag}\u5143\u7D20{hint}',textNotFound:'\u9875\u9762\u4E2D\u4E0D\u5B58\u5728\u6587\u672C"{text}"\uFF0C\u53EF\u80FD\u9700\u8981\u5148\u64CD\u4F5C\uFF08\u5982\u6253\u5F00\u4E0B\u62C9\u9762\u677F\uFF09\u6216\u6587\u672C\u6709\u8BEF',textFoundButHidden:'\u627E\u5230\u6587\u672C"{text}"\u4F46\u5143\u7D20\u4E0D\u53EF\u89C1\uFF0C\u53EF\u80FD\u9700\u8981\u5148\u6253\u5F00\u4E0B\u62C9\u9762\u677F/\u6EDA\u52A8\u5230\u53EF\u89C1\u533A\u57DF',textNotClickable:'\u627E\u5230\u6587\u672C"{text}"\u4F46\u4E0D\u5728\u53EF\u70B9\u51FB\u5143\u7D20\u4E2D\uFF0C\u8BF7\u7528 query_elements \u67E5\u770B\u5B9E\u9645\u7ED3\u6784\u6216\u7528 selector \u5B9A\u4F4D',textFoundButNotMatched:'\u627E\u5230\u6587\u672C"{text}"\u5728\u53EF\u70B9\u51FB\u5143\u7D20\u4E2D\u4F46\u672A\u5339\u914D\uFF0C\u53EF\u80FD\u6587\u672C\u88AB\u5206\u5272\u6216\u5927\u5C0F\u5199\u4E0D\u4E00\u81F4',tagConstraint:"\uFF08\u9650\u5B9A\u6807\u7B7E: {tag}\uFF09",triggerNotFound:"\u672A\u627E\u5230\u89E6\u53D1\u5668: {selector}",selectedOption:"\u5DF2\u9009\u62E9: {label}",selectOptionNotFound:'\u5728 <select> \u4E2D\u672A\u627E\u5230\u5339\u914D\u7684\u9009\u9879: "{option}"',optionContainerNotFound:"\u672A\u627E\u5230\u9009\u9879\u5BB9\u5668: {selector}",optionMatchTimeout:'\u5728 {timeout}ms \u5185\u672A\u627E\u5230\u5339\u914D\u9009\u9879: "{option}"',setRequiresKeyValue:"set\u64CD\u4F5C\u9700\u8981\u63D0\u4F9Bkey\u548Cvalue",keySet:"\u5DF2\u8BBE\u7F6E {key}",removeRequiresKey:"remove\u64CD\u4F5C\u9700\u8981\u63D0\u4F9Bkey",keyRemoved:"\u5DF2\u5220\u9664 {key}",storageCleared:"\u5DF2\u6E05\u7A7A\u5B58\u50A8",unknownAction:"\u672A\u77E5\u64CD\u4F5C: {action}"}}),A("en",{interactionTools:{selectorRequired:"Selector cannot be empty",elementNotFoundBySelector:"No element found matching selector: {selector}",navChangeHint:" (navigation change detected, waited {ms}ms)",domChangeHint:" (DOM change detected, waited {ms}ms)",clickedElement:"Clicked element: {selector}{hint}",elementNotFound:"Element not found",optionNotFound:"No matching option found",radioButtonNotFound:"No matching radio button found",formFillComplete:"Form fill complete: {success}/{total} fields succeeded",elementNotFoundShort:"Element not found: {selector}",invalidScrollTarget:"Invalid scroll target or missing selector",scrollComplete:"Scroll complete",elementAppeared:"Element {selector} appeared",elementDisappeared:"Element {selector} disappeared",elementVisible:"Element {selector} is visible",elementHidden:"Element {selector} is hidden",waitTimeout:"Timed out ({timeout}ms); element {selector} did not reach {state} state",noFocusedElement:"No focused element",keyboardInputSuccess:"Keyboard input successful{hint}",fileUploadNotFound:"File upload control not found: {selector}",notFileUploadControl:"The selected element is not a file upload control",fileUploaded:"File uploaded: {fileName}",textRequired:"text cannot be empty",hoveredByText:'Hovered over the {tag} element matching "{text}"{hint}',clickedByText:'Clicked the {tag} element matching "{text}"{hint}',textNotFound:'Text "{text}" does not exist on the page; you may need to perform an action first (e.g. open a dropdown) or the text may be incorrect',textFoundButHidden:'Found text "{text}" but the element is not visible; you may need to open a dropdown panel or scroll to make it visible',textNotClickable:'Found text "{text}" but it is not in a clickable element; use query_elements to inspect the structure or use a selector to locate it',textFoundButNotMatched:'Found text "{text}" in a clickable element but it did not match; the text may be split or have different casing',tagConstraint:" (tag constraint: {tag})",triggerNotFound:"Trigger not found: {selector}",selectedOption:"Selected: {label}",selectOptionNotFound:'No matching option found in <select>: "{option}"',optionContainerNotFound:"Option container not found: {selector}",optionMatchTimeout:'No matching option found within {timeout}ms: "{option}"',setRequiresKeyValue:"Set operation requires both key and value",keySet:"Set {key}",removeRequiresKey:"Remove operation requires a key",keyRemoved:"Removed {key}",storageCleared:"Storage cleared",unknownAction:"Unknown action: {action}"}});async function sn(e,t=300,o=2e3){let n=V(t,z.actionMinWait),a=V(o,z.actionWait);try{if(!e)return{success:!1,error:u("interactionTools.selectorRequired")};let i=e.trim();for(let[c,d]of[[/^"([\s\S]*)"$/,"$1"],[/^'([\s\S]*)'$/,"$1"],[/^`([\s\S]*)`$/,"$1"],[/^"([\s\S]*)"$/,"$1"],[/^'([\s\S]*)'$/,"$1"],[/^「([\s\S]*)」$/,"$1"]])i=i.replace(c,d);let r=I(i);if(!r)return{success:!1,error:u("interactionTools.elementNotFoundBySelector",{selector:e})};let l=ee();r.click();let s=await te(l,n,a);return{success:!0,message:u("interactionTools.clickedElement",{selector:e,hint:s.changed?u(s.urlChanged?"interactionTools.navChangeHint":"interactionTools.domChangeHint",{ms:s.waitedMs}):""}),...s}}catch(i){return{success:!1,error:i.message}}}function cn(e,t=500){try{let o=[];e.forEach(a=>{let{selector:i,ref:r,value:l,fieldType:s="text"}=a,c=i||`ref=${r}`,d=null;if(r==null?i&&(d=I(i)):d=Oo(r),!d){o.push({selector:c,success:!1,error:u("interactionTools.elementNotFound")});return}try{if(s==="text"){if(jt(d)){let p=_e(d,l);o.push({selector:c,success:p,value:l});return}qe(d,l),d.dispatchEvent(new Event("input",{bubbles:!0})),d.dispatchEvent(new Event("change",{bubbles:!0}))}else if(s==="contenteditable"){let p=_e(d,l);o.push({selector:c,success:p,value:l});return}else if(s==="select"){let p=d.querySelector(`option[value="${l}"]`)||Array.from(d.options).find(m=>m.textContent===l);if(p)d.value=p.value,d.dispatchEvent(new Event("change",{bubbles:!0}));else{o.push({selector:c,success:!1,error:u("interactionTools.optionNotFound")});return}}else if(s==="checkbox")d.checked=l==="true"||l===!0,d.dispatchEvent(new Event("change",{bubbles:!0}));else if(s==="radio"){let p=i?I(`${i}[value="${l}"]`):null;if(!p&&!i&&d.tagName==="INPUT"&&d.type==="radio")if(d.value===String(l))p=d;else{let m=d.getAttribute("name");if(m){let h=d.getRootNode();p=Array.from(h.querySelectorAll('input[type="radio"]')).find(f=>f.name===m&&f.value===String(l))||null}}if(p)p.checked=!0,p.dispatchEvent(new Event("change",{bubbles:!0}));else{o.push({selector:c,success:!1,error:u("interactionTools.radioButtonNotFound")});return}}o.push({selector:c,success:!0,value:l})}catch(p){o.push({selector:c,success:!1,error:p.message})}});let n=o.filter(a=>a.success).length;return{success:!0,message:u("interactionTools.formFillComplete",{success:n,total:e.length}),details:o}}catch(o){return{success:!1,error:o.message}}}function dn(e){try{let{target:t="selector",selector:o,x:n=0,y:a=0,behavior:i="smooth",align:r="center"}=e,l=!1;if(t==="top")l=(window.scrollY||0)<=0&&(document.documentElement.scrollTop||0)<=0,window.scrollTo({top:0,left:0,behavior:i});else if(t==="bottom"){let c=document.scrollingElement||document.documentElement;l=(window.scrollY||0)+(window.innerHeight||0)>=c.scrollHeight-1,window.scrollTo({top:document.body.scrollHeight,left:0,behavior:i})}else if(t==="coordinates")l=Math.abs((window.scrollY||0)-a)<1&&Math.abs((window.scrollX||0)-n)<1,window.scrollTo({top:a,left:n,behavior:i});else if(t==="selector"&&o){let c=I(o);if(!c)return{success:!1,error:u("interactionTools.elementNotFoundShort",{selector:o})};c.scrollIntoView({behavior:i,block:r})}else return{success:!1,error:u("interactionTools.invalidScrollTarget")};let s={success:!0,message:u("interactionTools.scrollComplete")};return l&&(s.moved=!1),s}catch(t){return{success:!1,error:t.message}}}function Ot(e){if(!e)return!1;if(e.offsetParent===null&&e.tagName!=="BODY"){let i=window.getComputedStyle(e);if(i.display==="none"||i.visibility==="hidden"||i.position!=="fixed")return!1}let t=window.getComputedStyle(e);if(t.display==="none"||t.visibility==="hidden"||parseFloat(t.opacity)<=0)return!1;let o=e.getBoundingClientRect();if(o.width<=0||o.height<=0)return!1;let n=window.innerHeight||document.documentElement.clientHeight,a=window.innerWidth||document.documentElement.clientWidth;return o.top<n&&o.bottom>0&&o.left<a&&o.right>0}function un(e,t="appeared",o=1e4){let n=V(o,z.waitElement);return new Promise((a,i)=>{let r=Date.now(),l=()=>{let s=I(e);if(t==="appeared"&&s){a({success:!0,message:u("interactionTools.elementAppeared",{selector:e}),element:e});return}if(t==="disappeared"&&!s){a({success:!0,message:u("interactionTools.elementDisappeared",{selector:e})});return}if(t==="visible"&&s&&Ot(s)){a({success:!0,message:u("interactionTools.elementVisible",{selector:e}),element:e});return}if(t==="hidden"&&(!s||!Ot(s))){a({success:!0,message:u("interactionTools.elementHidden",{selector:e})});return}if(Date.now()-r>n){a({success:!1,error:u("interactionTools.waitTimeout",{timeout:n,selector:e,state:t})});return}setTimeout(l,100)};l()})}var Bt={enter:{code:"Enter",keyCode:13},escape:{code:"Escape",keyCode:27},esc:{code:"Escape",keyCode:27},tab:{code:"Tab",keyCode:9},backspace:{code:"Backspace",keyCode:8},delete:{code:"Delete",keyCode:46},arrowup:{code:"ArrowUp",keyCode:38},arrowdown:{code:"ArrowDown",keyCode:40},arrowleft:{code:"ArrowLeft",keyCode:37},arrowright:{code:"ArrowRight",keyCode:39},home:{code:"Home",keyCode:36},end:{code:"End",keyCode:35},pageup:{code:"PageUp",keyCode:33},pagedown:{code:"PageDown",keyCode:34},space:{code:"Space",keyCode:32}};function pn(e){let t=e.toLowerCase();if(Bt[t])return Bt[t];if(e.length===1&&/[a-zA-Z]/.test(e))return{code:`Key${e.toUpperCase()}`,keyCode:e.toUpperCase().charCodeAt(0)};if(e.length===1&&/[0-9]/.test(e))return{code:`Digit${e}`,keyCode:e.charCodeAt(0)};let o=e.match(/^F([1-9]|1[0-2])$/i);if(o){let n=parseInt(o[1],10);return{code:`F${n}`,keyCode:111+n}}return{code:e,keyCode:e.toUpperCase().charCodeAt(0)}}async function mn({key:e,text:t,ctrlKey:o=!1,shiftKey:n=!1,altKey:a=!1}){try{let i=document.activeElement;if(!i)return{success:!1,error:u("interactionTools.noFocusedElement")};let r=ee();if(t){let s=i.tagName==="INPUT"||i.tagName==="TEXTAREA",c=i.isContentEditable;if(s||c){if(i.focus(),c)try{document.execCommand("selectAll",!1,null),document.execCommand("insertText",!1,t)}catch{i.textContent+=t}else qe(i,i.value+t);try{i.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t}))}catch{i.dispatchEvent(new Event("input",{bubbles:!0}))}i.dispatchEvent(new Event("change",{bubbles:!0}))}}if(e){let s=pn(e),c={key:e,code:s.code,keyCode:s.keyCode,which:s.keyCode,bubbles:!0,cancelable:!0,ctrlKey:o,shiftKey:n,altKey:a};document.activeElement.dispatchEvent(new KeyboardEvent("keydown",c)),document.activeElement.dispatchEvent(new KeyboardEvent("keypress",c)),document.activeElement.dispatchEvent(new KeyboardEvent("keyup",c))}let l=await te(r,300,2e3);return{success:!0,message:u("interactionTools.keyboardInputSuccess",{hint:l.changed?u(l.urlChanged?"interactionTools.navChangeHint":"interactionTools.domChangeHint",{ms:l.waitedMs}):""}),...l}}catch(i){return{success:!1,error:i.message}}}function hn(e,t,o,n="application/octet-stream"){try{let a=I(e);if(!a)return{success:!1,error:u("interactionTools.fileUploadNotFound",{selector:e})};if(a.type!=="file")return{success:!1,error:u("interactionTools.notFileUploadControl")};let i;try{let s=atob(o),c=new Uint8Array(s.length);for(let d=0;d<s.length;d++)c[d]=s.charCodeAt(d);i=new Blob([c],{type:n})}catch{i=new Blob([o],{type:n})}let r=new File([i],t,{type:n}),l=new DataTransfer;return l.items.add(r),a.files=l.files,a.dispatchEvent(new Event("change",{bubbles:!0})),{success:!0,message:u("interactionTools.fileUploaded",{fileName:t})}}catch(a){return{success:!1,error:a.message}}}async function gn(e,t={}){let{tag:o,action:n="click",waitTime:a=300,timeout:i=2e3}=t,r=V(a,z.actionMinWait),l=V(i,z.actionWait);if(!e)return{success:!1,error:u("interactionTools.textRequired")};let s=o?[o]:["button",'[role="button"]','input[type="submit"]','input[type="button"]',"a[href]",'[role="menuitem"]','[role="menuitemradio"]','[role="menuitemcheckbox"]','[role="option"]','[role="tab"]',"[onclick]","summary","li"],c=e.toLowerCase();for(let f of s){let y=[];try{y=le(f)}catch{continue}for(let w of y){let v=(w.textContent||w.value||"").trim();if(!v)continue;let S=v.toLowerCase();if(v===e||S===c||S.includes(c)){let E=window.getComputedStyle(w);if(E.display==="none"||E.visibility==="hidden"||parseFloat(E.opacity)<=0)continue;let U=Ee(w),ae=ee();if(n==="hover"){w.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0,view:window})),w.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0,view:window}));let O=await te(ae,r,l),ie=O.changed?u(O.urlChanged?"interactionTools.navChangeHint":"interactionTools.domChangeHint",{ms:O.waitedMs}):"";return{success:!0,message:u("interactionTools.hoveredByText",{text:e,tag:w.tagName.toLowerCase(),hint:ie}),selector:U,matchedText:v.substring(0,100),...O}}w.click();let Y=await te(ae,r,l),C=Y.changed?u(Y.urlChanged?"interactionTools.navChangeHint":"interactionTools.domChangeHint",{ms:Y.waitedMs}):"";return{success:!0,message:u("interactionTools.clickedByText",{text:e,tag:w.tagName.toLowerCase(),hint:C}),selector:U,matchedText:v.substring(0,100),...Y}}}}let d=!1,p=!1,m=!1;try{let f=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,null);for(;f.nextNode();)if((f.currentNode.textContent||"").toLowerCase().includes(c)){d=!0;let y=f.currentNode.parentElement;if(y){let w=window.getComputedStyle(y);(w.display==="none"||w.visibility==="hidden"||parseFloat(w.opacity)<=0)&&(p=!0),y.closest('button, [role="button"], [role="option"], [role="tab"], li, a[href], [onclick], summary, [tabindex]')||(m=!0)}break}}catch{}let h;return h=u(d?p?"interactionTools.textFoundButHidden":m?"interactionTools.textNotClickable":"interactionTools.textFoundButNotMatched":"interactionTools.textNotFound",{text:e}),{success:!1,error:h+(o?u("interactionTools.tagConstraint",{tag:o}):"")}}function fn(e,t,o=null,n=5e3){let a=V(n,z.selectOption);return new Promise(async i=>{try{let r=I(e);if(!r){i({success:!1,error:u("interactionTools.triggerNotFound",{selector:e})});return}if(r.tagName==="SELECT"){let d=r.options;for(let p=0;p<d.length;p++){let m=d[p],h=(m.textContent||m.label||"").trim();if(h===t||h.includes(t)){r.value=m.value,r.dispatchEvent(new Event("change",{bubbles:!0})),r.dispatchEvent(new Event("input",{bubbles:!0})),i({success:!0,message:u("interactionTools.selectedOption",{label:h}),triggerTag:"SELECT"});return}}i({success:!1,error:u("interactionTools.selectOptionNotFound",{option:t}),availableOptions:Array.from(d).map(p=>p.textContent?.trim()).filter(Boolean)});return}r.click(),await new Promise(d=>setTimeout(d,300));let l=Date.now(),s=o?I(o):document;if(!s){i({success:!1,error:u("interactionTools.optionContainerNotFound",{selector:o})});return}let c=null;for(;Date.now()-l<a;){let d=le('li, [role="option"], [role="menuitem"], .option, .dropdown-item, .select-item, [data-value], div',s);for(let p of d){let m=(p.textContent||"").trim();if(!(m.length<2)&&(m===t||m.includes(t)||m.replace(/\s+/g,"")===t.replace(/\s+/g,""))){c=p;break}}if(c)break;await new Promise(p=>setTimeout(p,100))}if(!c){i({success:!1,error:u("interactionTools.optionMatchTimeout",{timeout:a,option:t})});return}c.click(),i({success:!0,message:u("interactionTools.selectedOption",{label:c.textContent?.trim()}),triggerTag:r.tagName})}catch(r){i({success:!1,error:r.message})}})}function bn({action:e,storage:t,key:o,value:n}){try{let a=t==="session"?sessionStorage:localStorage;switch(e){case"get":if(!o){let r={};for(let l=0;l<a.length;l++){let s=a.key(l);r[s]=a.getItem(s)}return{success:!0,content:JSON.stringify(r),data:r}}let i=a.getItem(o);return{success:!0,content:JSON.stringify({key:o,value:i}),value:i};case"set":return!o||n===void 0?{success:!1,error:u("interactionTools.setRequiresKeyValue")}:(a.setItem(o,n),{success:!0,message:u("interactionTools.keySet",{key:o})});case"remove":return o?(a.removeItem(o),{success:!0,message:u("interactionTools.keyRemoved",{key:o})}):{success:!1,error:u("interactionTools.removeRequiresKey")};case"clear":return a.clear(),{success:!0,message:u("interactionTools.storageCleared")};default:return{success:!1,error:u("interactionTools.unknownAction",{action:e})}}}catch(a){return{success:!1,error:a.message}}}A("zh",{advancedTools:{close:"\u5173\u95ED",qrcodeLibNotLoaded:"QRCode \u5E93\u672A\u52A0\u8F7D\uFF0C\u5DF2\u4F7F\u7528 SVG \u964D\u7EA7\u65B9\u6848\u751F\u6210",qrcodeLibAndFallbackUnavailable:"\u4E8C\u7EF4\u7801\u5E93\u672A\u52A0\u8F7D\u4E14\u964D\u7EA7\u65B9\u6848\u4E0D\u53EF\u7528",targetElementNotFound:"\u672A\u627E\u5230\u76EE\u6807\u5143\u7D20",screenshotFailed:"\u622A\u56FE\u5931\u8D25",cssParamRequired:"css \u53C2\u6570\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32",unsupportedInjectMode:"\u4E0D\u652F\u6301\u7684 injectMode: {mode}\uFF0C\u652F\u6301 'style' \u6216 'inline'"}}),A("en",{advancedTools:{close:"Close",qrcodeLibNotLoaded:"QRCode library not loaded, used SVG fallback",qrcodeLibAndFallbackUnavailable:"QRCode library not loaded and fallback unavailable",targetElementNotFound:"Target element not found",screenshotFailed:"Screenshot failed",cssParamRequired:"css parameter must be a non-empty string",unsupportedInjectMode:"Unsupported injectMode: {mode}; supported: 'style' or 'inline'"}});function yn(e,t){try{let o=document.createElement("canvas");o.width=t,o.height=t;let n=o.getContext("2d");n.fillStyle="#FFFFFF",n.fillRect(0,0,t,t);let a=[];for(let p=0;p<e.length;p++)a.push(e.charCodeAt(p));let i=Math.max(2,Math.floor(t/41)),r=Math.floor(t/i),l=Math.floor((t-r*i)/2);n.fillStyle="#000000";let s=(p,m)=>{let h=7*i;n.fillRect(p,m,h,h),n.fillStyle="#FFFFFF",n.fillRect(p+i,m+i,h-2*i,h-2*i),n.fillStyle="#000000",n.fillRect(p+2*i,m+2*i,h-4*i,h-4*i),n.fillStyle="#000000"};s(l,l),s(l+(r-7)*i,l),s(l,l+(r-7)*i);let c=0;for(let p=0;p<e.length;p++)c=(c<<5)-c+e.charCodeAt(p),c|=0;let d=p=>{let m=p+1831565813;return m=Math.imul(m^m>>>15,m|1),m^=m+Math.imul(m^m>>>7,m|61),((m^m>>>14)>>>0)/4294967296};for(let p=0;p<r;p++)for(let m=0;m<r;m++){let h=p<8&&m<8,f=p<8&&m>=r-8,y=p>=r-8&&m<8;h||f||y||d(c+p*r+m)>.5&&n.fillRect(l+m*i,l+p*i,i,i)}return o.toDataURL("image/png")}catch{return null}}function wn(e="",t=200,o="M",n=!0){return new Promise(a=>{try{let i=e||window.location.href,r=document.createElement("div");r.id="ai-helper-qrcode",r.style.cssText=`
|
|
90
|
+
`,document.head.appendChild(o);let n=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,null,!1),a=[],i;for(;i=n.nextNode();)i.nodeValue.toLowerCase().includes(e.toLowerCase())&&a.push(i);let r=[];return a.forEach(l=>{let s=l.parentNode;if(!s||!s.replaceChild||!s.insertBefore)return;let c=l.nodeValue,d=c.toLowerCase(),p=c.toLowerCase(),m=d.indexOf(p);if(m!==-1){let h=document.createElement("span");h.className="ai-helper-highlight",h.textContent=c.substring(m,m+c.length);let f=document.createTextNode(c.substring(0,m)),y=document.createTextNode(c.substring(m+c.length));s.replaceChild(y,l),s.insertBefore(h,y),s.insertBefore(f,h),r.push(h)}}),r.length>0&&r[0].scrollIntoView({behavior:"smooth",block:"center"}),{success:!0,message:u("pageTools.highlightedCount",{count:r.length}),count:r.length}}catch(o){return{success:!1,error:o.message}}}A("zh",{interactionTools:{selectorRequired:"\u9009\u62E9\u5668\u4E0D\u80FD\u4E3A\u7A7A",elementNotFoundBySelector:"\u672A\u627E\u5230\u5339\u914D\u9009\u62E9\u5668\u7684\u5143\u7D20: {selector}",navChangeHint:"\uFF08\u68C0\u6D4B\u5230\u5BFC\u822A\u53D8\u5316\uFF0C\u5DF2\u7B49\u5F85 {ms}ms\uFF09",domChangeHint:"\uFF08\u68C0\u6D4B\u5230DOM\u53D8\u5316\uFF0C\u5DF2\u7B49\u5F85 {ms}ms\uFF09",clickedElement:"\u5DF2\u70B9\u51FB\u5143\u7D20: {selector}{hint}",elementNotFound:"\u672A\u627E\u5230\u5143\u7D20",optionNotFound:"\u672A\u627E\u5230\u5339\u914D\u7684\u9009\u9879",radioButtonNotFound:"\u672A\u627E\u5230\u5339\u914D\u7684\u5355\u9009\u6309\u94AE",formFillComplete:"\u8868\u5355\u586B\u5145\u5B8C\u6210\uFF0C\u6210\u529F {success}/{total} \u4E2A\u5B57\u6BB5",elementNotFoundShort:"\u672A\u627E\u5230\u5143\u7D20: {selector}",invalidScrollTarget:"\u65E0\u6548\u7684\u6EDA\u52A8\u76EE\u6807\u6216\u7F3A\u5C11\u9009\u62E9\u5668",scrollComplete:"\u6EDA\u52A8\u5B8C\u6210",elementAppeared:"\u5143\u7D20 {selector} \u5DF2\u51FA\u73B0",elementDisappeared:"\u5143\u7D20 {selector} \u5DF2\u6D88\u5931",elementVisible:"\u5143\u7D20 {selector} \u5DF2\u53EF\u89C1",elementHidden:"\u5143\u7D20 {selector} \u5DF2\u9690\u85CF",waitTimeout:"\u7B49\u5F85\u8D85\u65F6\uFF08{timeout}ms\uFF09\uFF0C\u5143\u7D20 {selector} \u672A\u8FBE\u5230 {state} \u72B6\u6001",noFocusedElement:"\u6CA1\u6709\u805A\u7126\u7684\u5143\u7D20",keyboardInputSuccess:"\u952E\u76D8\u8F93\u5165\u6210\u529F{hint}",fileUploadNotFound:"\u672A\u627E\u5230\u6587\u4EF6\u4E0A\u4F20\u63A7\u4EF6: {selector}",notFileUploadControl:"\u9009\u62E9\u7684\u5143\u7D20\u4E0D\u662F\u6587\u4EF6\u4E0A\u4F20\u63A7\u4EF6",fileUploaded:"\u5DF2\u4E0A\u4F20\u6587\u4EF6: {fileName}",textRequired:"text \u4E0D\u80FD\u4E3A\u7A7A",hoveredByText:'\u5DF2\u60AC\u505C\u6587\u672C"{text}"\u5BF9\u5E94\u7684{tag}\u5143\u7D20{hint}',clickedByText:'\u5DF2\u70B9\u51FB\u6587\u672C"{text}"\u5BF9\u5E94\u7684{tag}\u5143\u7D20{hint}',textNotFound:'\u9875\u9762\u4E2D\u4E0D\u5B58\u5728\u6587\u672C"{text}"\uFF0C\u53EF\u80FD\u9700\u8981\u5148\u64CD\u4F5C\uFF08\u5982\u6253\u5F00\u4E0B\u62C9\u9762\u677F\uFF09\u6216\u6587\u672C\u6709\u8BEF',textFoundButHidden:'\u627E\u5230\u6587\u672C"{text}"\u4F46\u5143\u7D20\u4E0D\u53EF\u89C1\uFF0C\u53EF\u80FD\u9700\u8981\u5148\u6253\u5F00\u4E0B\u62C9\u9762\u677F/\u6EDA\u52A8\u5230\u53EF\u89C1\u533A\u57DF',textNotClickable:'\u627E\u5230\u6587\u672C"{text}"\u4F46\u4E0D\u5728\u53EF\u70B9\u51FB\u5143\u7D20\u4E2D\uFF0C\u8BF7\u7528 query_elements \u67E5\u770B\u5B9E\u9645\u7ED3\u6784\u6216\u7528 selector \u5B9A\u4F4D',textFoundButNotMatched:'\u627E\u5230\u6587\u672C"{text}"\u5728\u53EF\u70B9\u51FB\u5143\u7D20\u4E2D\u4F46\u672A\u5339\u914D\uFF0C\u53EF\u80FD\u6587\u672C\u88AB\u5206\u5272\u6216\u5927\u5C0F\u5199\u4E0D\u4E00\u81F4',tagConstraint:"\uFF08\u9650\u5B9A\u6807\u7B7E: {tag}\uFF09",triggerNotFound:"\u672A\u627E\u5230\u89E6\u53D1\u5668: {selector}",selectedOption:"\u5DF2\u9009\u62E9: {label}",selectOptionNotFound:'\u5728 <select> \u4E2D\u672A\u627E\u5230\u5339\u914D\u7684\u9009\u9879: "{option}"',optionContainerNotFound:"\u672A\u627E\u5230\u9009\u9879\u5BB9\u5668: {selector}",optionMatchTimeout:'\u5728 {timeout}ms \u5185\u672A\u627E\u5230\u5339\u914D\u9009\u9879: "{option}"',setRequiresKeyValue:"set\u64CD\u4F5C\u9700\u8981\u63D0\u4F9Bkey\u548Cvalue",keySet:"\u5DF2\u8BBE\u7F6E {key}",removeRequiresKey:"remove\u64CD\u4F5C\u9700\u8981\u63D0\u4F9Bkey",keyRemoved:"\u5DF2\u5220\u9664 {key}",storageCleared:"\u5DF2\u6E05\u7A7A\u5B58\u50A8",unknownAction:"\u672A\u77E5\u64CD\u4F5C: {action}"}}),A("en",{interactionTools:{selectorRequired:"Selector cannot be empty",elementNotFoundBySelector:"No element found matching selector: {selector}",navChangeHint:" (navigation change detected, waited {ms}ms)",domChangeHint:" (DOM change detected, waited {ms}ms)",clickedElement:"Clicked element: {selector}{hint}",elementNotFound:"Element not found",optionNotFound:"No matching option found",radioButtonNotFound:"No matching radio button found",formFillComplete:"Form fill complete: {success}/{total} fields succeeded",elementNotFoundShort:"Element not found: {selector}",invalidScrollTarget:"Invalid scroll target or missing selector",scrollComplete:"Scroll complete",elementAppeared:"Element {selector} appeared",elementDisappeared:"Element {selector} disappeared",elementVisible:"Element {selector} is visible",elementHidden:"Element {selector} is hidden",waitTimeout:"Timed out ({timeout}ms); element {selector} did not reach {state} state",noFocusedElement:"No focused element",keyboardInputSuccess:"Keyboard input successful{hint}",fileUploadNotFound:"File upload control not found: {selector}",notFileUploadControl:"The selected element is not a file upload control",fileUploaded:"File uploaded: {fileName}",textRequired:"text cannot be empty",hoveredByText:'Hovered over the {tag} element matching "{text}"{hint}',clickedByText:'Clicked the {tag} element matching "{text}"{hint}',textNotFound:'Text "{text}" does not exist on the page; you may need to perform an action first (e.g. open a dropdown) or the text may be incorrect',textFoundButHidden:'Found text "{text}" but the element is not visible; you may need to open a dropdown panel or scroll to make it visible',textNotClickable:'Found text "{text}" but it is not in a clickable element; use query_elements to inspect the structure or use a selector to locate it',textFoundButNotMatched:'Found text "{text}" in a clickable element but it did not match; the text may be split or have different casing',tagConstraint:" (tag constraint: {tag})",triggerNotFound:"Trigger not found: {selector}",selectedOption:"Selected: {label}",selectOptionNotFound:'No matching option found in <select>: "{option}"',optionContainerNotFound:"Option container not found: {selector}",optionMatchTimeout:'No matching option found within {timeout}ms: "{option}"',setRequiresKeyValue:"Set operation requires both key and value",keySet:"Set {key}",removeRequiresKey:"Remove operation requires a key",keyRemoved:"Removed {key}",storageCleared:"Storage cleared",unknownAction:"Unknown action: {action}"}});async function sn(e,t=300,o=2e3){let n=V(t,z.actionMinWait),a=V(o,z.actionWait);try{if(!e)return{success:!1,error:u("interactionTools.selectorRequired")};let i=e.trim();for(let[c,d]of[[/^"([\s\S]*)"$/,"$1"],[/^'([\s\S]*)'$/,"$1"],[/^`([\s\S]*)`$/,"$1"],[/^"([\s\S]*)"$/,"$1"],[/^'([\s\S]*)'$/,"$1"],[/^「([\s\S]*)」$/,"$1"]])i=i.replace(c,d);let r=P(i);if(!r)return{success:!1,error:u("interactionTools.elementNotFoundBySelector",{selector:e})};let l=ee();r.click();let s=await te(l,n,a);return{success:!0,message:u("interactionTools.clickedElement",{selector:e,hint:s.changed?u(s.urlChanged?"interactionTools.navChangeHint":"interactionTools.domChangeHint",{ms:s.waitedMs}):""}),...s}}catch(i){return{success:!1,error:i.message}}}function cn(e,t=500){try{let o=[];e.forEach(a=>{let{selector:i,ref:r,value:l,fieldType:s="text"}=a,c=i||`ref=${r}`,d=null;if(r==null?i&&(d=P(i)):d=Oo(r),!d){o.push({selector:c,success:!1,error:u("interactionTools.elementNotFound")});return}try{if(s==="text"){if(jt(d)){let p=_e(d,l);o.push({selector:c,success:p,value:l});return}qe(d,l),d.dispatchEvent(new Event("input",{bubbles:!0})),d.dispatchEvent(new Event("change",{bubbles:!0}))}else if(s==="contenteditable"){let p=_e(d,l);o.push({selector:c,success:p,value:l});return}else if(s==="select"){let p=d.querySelector(`option[value="${l}"]`)||Array.from(d.options).find(m=>m.textContent===l);if(p)d.value=p.value,d.dispatchEvent(new Event("change",{bubbles:!0}));else{o.push({selector:c,success:!1,error:u("interactionTools.optionNotFound")});return}}else if(s==="checkbox")d.checked=l==="true"||l===!0,d.dispatchEvent(new Event("change",{bubbles:!0}));else if(s==="radio"){let p=i?P(`${i}[value="${l}"]`):null;if(!p&&!i&&d.tagName==="INPUT"&&d.type==="radio")if(d.value===String(l))p=d;else{let m=d.getAttribute("name");if(m){let h=d.getRootNode();p=Array.from(h.querySelectorAll('input[type="radio"]')).find(f=>f.name===m&&f.value===String(l))||null}}if(p)p.checked=!0,p.dispatchEvent(new Event("change",{bubbles:!0}));else{o.push({selector:c,success:!1,error:u("interactionTools.radioButtonNotFound")});return}}o.push({selector:c,success:!0,value:l})}catch(p){o.push({selector:c,success:!1,error:p.message})}});let n=o.filter(a=>a.success).length;return{success:!0,message:u("interactionTools.formFillComplete",{success:n,total:e.length}),details:o}}catch(o){return{success:!1,error:o.message}}}function dn(e){try{let{target:t="selector",selector:o,x:n=0,y:a=0,behavior:i="smooth",align:r="center"}=e,l=!1;if(t==="top")l=(window.scrollY||0)<=0&&(document.documentElement.scrollTop||0)<=0,window.scrollTo({top:0,left:0,behavior:i});else if(t==="bottom"){let c=document.scrollingElement||document.documentElement;l=(window.scrollY||0)+(window.innerHeight||0)>=c.scrollHeight-1,window.scrollTo({top:document.body.scrollHeight,left:0,behavior:i})}else if(t==="coordinates")l=Math.abs((window.scrollY||0)-a)<1&&Math.abs((window.scrollX||0)-n)<1,window.scrollTo({top:a,left:n,behavior:i});else if(t==="selector"&&o){let c=P(o);if(!c)return{success:!1,error:u("interactionTools.elementNotFoundShort",{selector:o})};c.scrollIntoView({behavior:i,block:r})}else return{success:!1,error:u("interactionTools.invalidScrollTarget")};let s={success:!0,message:u("interactionTools.scrollComplete")};return l&&(s.moved=!1),s}catch(t){return{success:!1,error:t.message}}}function Ot(e){if(!e)return!1;if(e.offsetParent===null&&e.tagName!=="BODY"){let i=window.getComputedStyle(e);if(i.display==="none"||i.visibility==="hidden"||i.position!=="fixed")return!1}let t=window.getComputedStyle(e);if(t.display==="none"||t.visibility==="hidden"||parseFloat(t.opacity)<=0)return!1;let o=e.getBoundingClientRect();if(o.width<=0||o.height<=0)return!1;let n=window.innerHeight||document.documentElement.clientHeight,a=window.innerWidth||document.documentElement.clientWidth;return o.top<n&&o.bottom>0&&o.left<a&&o.right>0}function un(e,t="appeared",o=1e4){let n=V(o,z.waitElement);return new Promise((a,i)=>{let r=Date.now(),l=()=>{let s=P(e);if(t==="appeared"&&s){a({success:!0,message:u("interactionTools.elementAppeared",{selector:e}),element:e});return}if(t==="disappeared"&&!s){a({success:!0,message:u("interactionTools.elementDisappeared",{selector:e})});return}if(t==="visible"&&s&&Ot(s)){a({success:!0,message:u("interactionTools.elementVisible",{selector:e}),element:e});return}if(t==="hidden"&&(!s||!Ot(s))){a({success:!0,message:u("interactionTools.elementHidden",{selector:e})});return}if(Date.now()-r>n){a({success:!1,error:u("interactionTools.waitTimeout",{timeout:n,selector:e,state:t})});return}setTimeout(l,100)};l()})}var Bt={enter:{code:"Enter",keyCode:13},escape:{code:"Escape",keyCode:27},esc:{code:"Escape",keyCode:27},tab:{code:"Tab",keyCode:9},backspace:{code:"Backspace",keyCode:8},delete:{code:"Delete",keyCode:46},arrowup:{code:"ArrowUp",keyCode:38},arrowdown:{code:"ArrowDown",keyCode:40},arrowleft:{code:"ArrowLeft",keyCode:37},arrowright:{code:"ArrowRight",keyCode:39},home:{code:"Home",keyCode:36},end:{code:"End",keyCode:35},pageup:{code:"PageUp",keyCode:33},pagedown:{code:"PageDown",keyCode:34},space:{code:"Space",keyCode:32}};function pn(e){let t=e.toLowerCase();if(Bt[t])return Bt[t];if(e.length===1&&/[a-zA-Z]/.test(e))return{code:`Key${e.toUpperCase()}`,keyCode:e.toUpperCase().charCodeAt(0)};if(e.length===1&&/[0-9]/.test(e))return{code:`Digit${e}`,keyCode:e.charCodeAt(0)};let o=e.match(/^F([1-9]|1[0-2])$/i);if(o){let n=parseInt(o[1],10);return{code:`F${n}`,keyCode:111+n}}return{code:e,keyCode:e.toUpperCase().charCodeAt(0)}}async function mn({key:e,text:t,ctrlKey:o=!1,shiftKey:n=!1,altKey:a=!1}){try{let i=document.activeElement;if(!i)return{success:!1,error:u("interactionTools.noFocusedElement")};let r=ee();if(t){let s=i.tagName==="INPUT"||i.tagName==="TEXTAREA",c=i.isContentEditable;if(s||c){if(i.focus(),c)try{document.execCommand("selectAll",!1,null),document.execCommand("insertText",!1,t)}catch{i.textContent+=t}else qe(i,i.value+t);try{i.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t}))}catch{i.dispatchEvent(new Event("input",{bubbles:!0}))}i.dispatchEvent(new Event("change",{bubbles:!0}))}}if(e){let s=pn(e),c={key:e,code:s.code,keyCode:s.keyCode,which:s.keyCode,bubbles:!0,cancelable:!0,ctrlKey:o,shiftKey:n,altKey:a};document.activeElement.dispatchEvent(new KeyboardEvent("keydown",c)),document.activeElement.dispatchEvent(new KeyboardEvent("keypress",c)),document.activeElement.dispatchEvent(new KeyboardEvent("keyup",c))}let l=await te(r,300,2e3);return{success:!0,message:u("interactionTools.keyboardInputSuccess",{hint:l.changed?u(l.urlChanged?"interactionTools.navChangeHint":"interactionTools.domChangeHint",{ms:l.waitedMs}):""}),...l}}catch(i){return{success:!1,error:i.message}}}function hn(e,t,o,n="application/octet-stream"){try{let a=P(e);if(!a)return{success:!1,error:u("interactionTools.fileUploadNotFound",{selector:e})};if(a.type!=="file")return{success:!1,error:u("interactionTools.notFileUploadControl")};let i;try{let s=atob(o),c=new Uint8Array(s.length);for(let d=0;d<s.length;d++)c[d]=s.charCodeAt(d);i=new Blob([c],{type:n})}catch{i=new Blob([o],{type:n})}let r=new File([i],t,{type:n}),l=new DataTransfer;return l.items.add(r),a.files=l.files,a.dispatchEvent(new Event("change",{bubbles:!0})),{success:!0,message:u("interactionTools.fileUploaded",{fileName:t})}}catch(a){return{success:!1,error:a.message}}}async function gn(e,t={}){let{tag:o,action:n="click",waitTime:a=300,timeout:i=2e3}=t,r=V(a,z.actionMinWait),l=V(i,z.actionWait);if(!e)return{success:!1,error:u("interactionTools.textRequired")};let s=o?[o]:["button",'[role="button"]','input[type="submit"]','input[type="button"]',"a[href]",'[role="menuitem"]','[role="menuitemradio"]','[role="menuitemcheckbox"]','[role="option"]','[role="tab"]',"[onclick]","summary","li"],c=e.toLowerCase();for(let f of s){let y=[];try{y=le(f)}catch{continue}for(let w of y){let v=(w.textContent||w.value||"").trim();if(!v)continue;let S=v.toLowerCase();if(v===e||S===c||S.includes(c)){let E=window.getComputedStyle(w);if(E.display==="none"||E.visibility==="hidden"||parseFloat(E.opacity)<=0)continue;let U=Ee(w),ae=ee();if(n==="hover"){w.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0,view:window})),w.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0,view:window}));let O=await te(ae,r,l),ie=O.changed?u(O.urlChanged?"interactionTools.navChangeHint":"interactionTools.domChangeHint",{ms:O.waitedMs}):"";return{success:!0,message:u("interactionTools.hoveredByText",{text:e,tag:w.tagName.toLowerCase(),hint:ie}),selector:U,matchedText:v.substring(0,100),...O}}w.click();let Y=await te(ae,r,l),C=Y.changed?u(Y.urlChanged?"interactionTools.navChangeHint":"interactionTools.domChangeHint",{ms:Y.waitedMs}):"";return{success:!0,message:u("interactionTools.clickedByText",{text:e,tag:w.tagName.toLowerCase(),hint:C}),selector:U,matchedText:v.substring(0,100),...Y}}}}let d=!1,p=!1,m=!1;try{let f=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,null);for(;f.nextNode();)if((f.currentNode.textContent||"").toLowerCase().includes(c)){d=!0;let y=f.currentNode.parentElement;if(y){let w=window.getComputedStyle(y);(w.display==="none"||w.visibility==="hidden"||parseFloat(w.opacity)<=0)&&(p=!0),y.closest('button, [role="button"], [role="option"], [role="tab"], li, a[href], [onclick], summary, [tabindex]')||(m=!0)}break}}catch{}let h;return h=u(d?p?"interactionTools.textFoundButHidden":m?"interactionTools.textNotClickable":"interactionTools.textFoundButNotMatched":"interactionTools.textNotFound",{text:e}),{success:!1,error:h+(o?u("interactionTools.tagConstraint",{tag:o}):"")}}function fn(e,t,o=null,n=5e3){let a=V(n,z.selectOption);return new Promise(async i=>{try{let r=P(e);if(!r){i({success:!1,error:u("interactionTools.triggerNotFound",{selector:e})});return}if(r.tagName==="SELECT"){let d=r.options;for(let p=0;p<d.length;p++){let m=d[p],h=(m.textContent||m.label||"").trim();if(h===t||h.includes(t)){r.value=m.value,r.dispatchEvent(new Event("change",{bubbles:!0})),r.dispatchEvent(new Event("input",{bubbles:!0})),i({success:!0,message:u("interactionTools.selectedOption",{label:h}),triggerTag:"SELECT"});return}}i({success:!1,error:u("interactionTools.selectOptionNotFound",{option:t}),availableOptions:Array.from(d).map(p=>p.textContent?.trim()).filter(Boolean)});return}r.click(),await new Promise(d=>setTimeout(d,300));let l=Date.now(),s=o?P(o):document;if(!s){i({success:!1,error:u("interactionTools.optionContainerNotFound",{selector:o})});return}let c=null;for(;Date.now()-l<a;){let d=le('li, [role="option"], [role="menuitem"], .option, .dropdown-item, .select-item, [data-value], div',s);for(let p of d){let m=(p.textContent||"").trim();if(!(m.length<2)&&(m===t||m.includes(t)||m.replace(/\s+/g,"")===t.replace(/\s+/g,""))){c=p;break}}if(c)break;await new Promise(p=>setTimeout(p,100))}if(!c){i({success:!1,error:u("interactionTools.optionMatchTimeout",{timeout:a,option:t})});return}c.click(),i({success:!0,message:u("interactionTools.selectedOption",{label:c.textContent?.trim()}),triggerTag:r.tagName})}catch(r){i({success:!1,error:r.message})}})}function bn({action:e,storage:t,key:o,value:n}){try{let a=t==="session"?sessionStorage:localStorage;switch(e){case"get":if(!o){let r={};for(let l=0;l<a.length;l++){let s=a.key(l);r[s]=a.getItem(s)}return{success:!0,content:JSON.stringify(r),data:r}}let i=a.getItem(o);return{success:!0,content:JSON.stringify({key:o,value:i}),value:i};case"set":return!o||n===void 0?{success:!1,error:u("interactionTools.setRequiresKeyValue")}:(a.setItem(o,n),{success:!0,message:u("interactionTools.keySet",{key:o})});case"remove":return o?(a.removeItem(o),{success:!0,message:u("interactionTools.keyRemoved",{key:o})}):{success:!1,error:u("interactionTools.removeRequiresKey")};case"clear":return a.clear(),{success:!0,message:u("interactionTools.storageCleared")};default:return{success:!1,error:u("interactionTools.unknownAction",{action:e})}}}catch(a){return{success:!1,error:a.message}}}A("zh",{advancedTools:{close:"\u5173\u95ED",qrcodeLibNotLoaded:"QRCode \u5E93\u672A\u52A0\u8F7D\uFF0C\u5DF2\u4F7F\u7528 SVG \u964D\u7EA7\u65B9\u6848\u751F\u6210",qrcodeLibAndFallbackUnavailable:"\u4E8C\u7EF4\u7801\u5E93\u672A\u52A0\u8F7D\u4E14\u964D\u7EA7\u65B9\u6848\u4E0D\u53EF\u7528",targetElementNotFound:"\u672A\u627E\u5230\u76EE\u6807\u5143\u7D20",screenshotFailed:"\u622A\u56FE\u5931\u8D25",cssParamRequired:"css \u53C2\u6570\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32",unsupportedInjectMode:"\u4E0D\u652F\u6301\u7684 injectMode: {mode}\uFF0C\u652F\u6301 'style' \u6216 'inline'"}}),A("en",{advancedTools:{close:"Close",qrcodeLibNotLoaded:"QRCode library not loaded, used SVG fallback",qrcodeLibAndFallbackUnavailable:"QRCode library not loaded and fallback unavailable",targetElementNotFound:"Target element not found",screenshotFailed:"Screenshot failed",cssParamRequired:"css parameter must be a non-empty string",unsupportedInjectMode:"Unsupported injectMode: {mode}; supported: 'style' or 'inline'"}});function yn(e,t){try{let o=document.createElement("canvas");o.width=t,o.height=t;let n=o.getContext("2d");n.fillStyle="#FFFFFF",n.fillRect(0,0,t,t);let a=[];for(let p=0;p<e.length;p++)a.push(e.charCodeAt(p));let i=Math.max(2,Math.floor(t/41)),r=Math.floor(t/i),l=Math.floor((t-r*i)/2);n.fillStyle="#000000";let s=(p,m)=>{let h=7*i;n.fillRect(p,m,h,h),n.fillStyle="#FFFFFF",n.fillRect(p+i,m+i,h-2*i,h-2*i),n.fillStyle="#000000",n.fillRect(p+2*i,m+2*i,h-4*i,h-4*i),n.fillStyle="#000000"};s(l,l),s(l+(r-7)*i,l),s(l,l+(r-7)*i);let c=0;for(let p=0;p<e.length;p++)c=(c<<5)-c+e.charCodeAt(p),c|=0;let d=p=>{let m=p+1831565813;return m=Math.imul(m^m>>>15,m|1),m^=m+Math.imul(m^m>>>7,m|61),((m^m>>>14)>>>0)/4294967296};for(let p=0;p<r;p++)for(let m=0;m<r;m++){let h=p<8&&m<8,f=p<8&&m>=r-8,y=p>=r-8&&m<8;h||f||y||d(c+p*r+m)>.5&&n.fillRect(l+m*i,l+p*i,i,i)}return o.toDataURL("image/png")}catch{return null}}function wn(e="",t=200,o="M",n=!0){return new Promise(a=>{try{let i=e||window.location.href,r=document.createElement("div");r.id="ai-helper-qrcode",r.style.cssText=`
|
|
91
91
|
position: fixed;
|
|
92
92
|
top: 50%;
|
|
93
93
|
left: 50%;
|
|
@@ -106,7 +106,7 @@ ${i.slice(1).map(r=>`| ${r.join(" | ")} |`).join(`
|
|
|
106
106
|
border: none;
|
|
107
107
|
border-radius: 20px;
|
|
108
108
|
cursor: pointer;
|
|
109
|
-
`,c.onclick=()=>{document.body.removeChild(r)},r.appendChild(c),typeof QRCode>"u"){let d=yn(i,t);if(d){let p=document.createElement("img");p.src=d,p.width=t,p.height=t,l.replaceWith(p),n&&document.body.appendChild(r),a({success:!0,content:i,size:t,dataUrl:d,shown:n,fallback:!0,warning:u("advancedTools.qrcodeLibNotLoaded")})}else a({success:!1,error:u("advancedTools.qrcodeLibAndFallbackUnavailable")});return}QRCode.toCanvas(l,i,{width:t,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:o.toLowerCase()},d=>{d?a({success:!1,error:d.message}):(n&&document.body.appendChild(r),a({success:!0,content:i,size:t,dataUrl:l.toDataURL("image/png"),shown:n}))})}catch(i){a({success:!1,error:i.message})}})}function vn(e){return typeof e=="string"?e.replace(/@import\b[^;{}]*;?/gi,"").replace(/url\s*\([^;{}]*\)/gi,"").replace(/expression\s*\([^;{}]*\)/gi,"").replace(/-moz-element\s*\([^;{}]*\)/gi,"").replace(/element\s*\([^;{}]*\)/gi,"").replace(/-moz-binding\b[^;}]*;?/gi,"").replace(/\bbehavior\b[^;}]*;?/gi,""):""}function kn(e,t=null,o="style"){try{if(!e||typeof e!="string")return{success:!1,error:u("advancedTools.cssParamRequired")};if(e=vn(e),o!=="style"&&o!=="inline")return{success:!1,error:u("advancedTools.unsupportedInjectMode",{mode:o})};if(o==="style")if(t){let n=document.querySelectorAll(t),a=`ai-helper-scoped-style-${Date.now()}`,i="",r=e.split("}");for(let s of r){let c=s.trim();if(!c)continue;let d=c.indexOf("{");if(d===-1)continue;let p=c.substring(0,d).trim(),m=c.substring(d+1).trim();i+=`#${a} ${p} { ${m} } `}n.forEach(s=>{s.setAttribute("id",a)});let l=document.createElement("style");return l.setAttribute("data-ai-helper","scoped"),l.textContent=i,document.head.appendChild(l),{success:!0,injectMode:"style",scoped:!0,selector:t,hitCount:n.length}}else{let n=document.createElement("style");return n.setAttribute("data-ai-helper","global"),n.textContent=e,document.head.appendChild(n),{success:!0,injectMode:"style",scoped:!1,hitCount:0}}if(o==="inline"){let n=t?document.querySelectorAll(t):document.querySelectorAll("*"),a=0,i={};return e.split(";").forEach(r=>{let l=r.indexOf(":");if(l===-1)return;let s=r.substring(0,l).trim(),c=r.substring(l+1).trim();s&&c&&(i[s]=c)}),n.forEach(r=>{if(r.nodeType===1){for(let[l,s]of Object.entries(i))try{r.style.setProperty(l,s)}catch{}a++}}),{success:!0,injectMode:"inline",selector:t||"*",hitCount:a}}}catch(n){return{success:!1,error:n.message}}}function ot(e,t){try{return e.querySelector(t),!0}catch{return!1}}function xn(e,t,o){let n=e.target==null?"":String(e.target);switch(e.check){case"element_exists":return n?ot(t,n)?{available:!0,pass:!!
|
|
109
|
+
`,c.onclick=()=>{document.body.removeChild(r)},r.appendChild(c),typeof QRCode>"u"){let d=yn(i,t);if(d){let p=document.createElement("img");p.src=d,p.width=t,p.height=t,l.replaceWith(p),n&&document.body.appendChild(r),a({success:!0,content:i,size:t,dataUrl:d,shown:n,fallback:!0,warning:u("advancedTools.qrcodeLibNotLoaded")})}else a({success:!1,error:u("advancedTools.qrcodeLibAndFallbackUnavailable")});return}QRCode.toCanvas(l,i,{width:t,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:o.toLowerCase()},d=>{d?a({success:!1,error:d.message}):(n&&document.body.appendChild(r),a({success:!0,content:i,size:t,dataUrl:l.toDataURL("image/png"),shown:n}))})}catch(i){a({success:!1,error:i.message})}})}function vn(e){return typeof e=="string"?e.replace(/@import\b[^;{}]*;?/gi,"").replace(/url\s*\([^;{}]*\)/gi,"").replace(/expression\s*\([^;{}]*\)/gi,"").replace(/-moz-element\s*\([^;{}]*\)/gi,"").replace(/element\s*\([^;{}]*\)/gi,"").replace(/-moz-binding\b[^;}]*;?/gi,"").replace(/\bbehavior\b[^;}]*;?/gi,""):""}function kn(e,t=null,o="style"){try{if(!e||typeof e!="string")return{success:!1,error:u("advancedTools.cssParamRequired")};if(e=vn(e),o!=="style"&&o!=="inline")return{success:!1,error:u("advancedTools.unsupportedInjectMode",{mode:o})};if(o==="style")if(t){let n=document.querySelectorAll(t),a=`ai-helper-scoped-style-${Date.now()}`,i="",r=e.split("}");for(let s of r){let c=s.trim();if(!c)continue;let d=c.indexOf("{");if(d===-1)continue;let p=c.substring(0,d).trim(),m=c.substring(d+1).trim();i+=`#${a} ${p} { ${m} } `}n.forEach(s=>{s.setAttribute("id",a)});let l=document.createElement("style");return l.setAttribute("data-ai-helper","scoped"),l.textContent=i,document.head.appendChild(l),{success:!0,injectMode:"style",scoped:!0,selector:t,hitCount:n.length}}else{let n=document.createElement("style");return n.setAttribute("data-ai-helper","global"),n.textContent=e,document.head.appendChild(n),{success:!0,injectMode:"style",scoped:!1,hitCount:0}}if(o==="inline"){let n=t?document.querySelectorAll(t):document.querySelectorAll("*"),a=0,i={};return e.split(";").forEach(r=>{let l=r.indexOf(":");if(l===-1)return;let s=r.substring(0,l).trim(),c=r.substring(l+1).trim();s&&c&&(i[s]=c)}),n.forEach(r=>{if(r.nodeType===1){for(let[l,s]of Object.entries(i))try{r.style.setProperty(l,s)}catch{}a++}}),{success:!0,injectMode:"inline",selector:t||"*",hitCount:a}}}catch(n){return{success:!1,error:n.message}}}function ot(e,t){try{return e.querySelector(t),!0}catch{return!1}}function xn(e,t,o){let n=e.target==null?"":String(e.target);switch(e.check){case"element_exists":return n?ot(t,n)?{available:!0,pass:!!P(n,t)}:{available:!1,reason:"invalid_selector"}:{available:!1,reason:"empty_target"};case"element_absent":return n?ot(t,n)?{available:!0,pass:!P(n,t)}:{available:!1,reason:"invalid_selector"}:{available:!1,reason:"empty_target"};case"text_contains":{let a=e.expected==null?e.target==null?"":String(e.target):String(e.expected);return a?{available:!0,pass:(Ce(t)||t.body&&t.body.textContent||"").includes(a)}:{available:!1,reason:"missing_expected"}}case"url_matches":{let a=n||(e.expected==null?"":String(e.expected)),i=o&&o.href?String(o.href):"";return a?i?{available:!0,pass:i.includes(a)}:{available:!1,reason:"no_href"}:{available:!1,reason:"empty_target"}}case"attribute_equals":{let a=e.expected==null?"":String(e.expected),i=a.indexOf("=");if(!n)return{available:!1,reason:"empty_target"};if(i<=0)return{available:!1,reason:"missing_expected"};if(!ot(t,n))return{available:!1,reason:"invalid_selector"};let r=P(n,t);return{available:!0,pass:!!r&&r.getAttribute(a.slice(0,i))===a.slice(i+1)}}default:return{available:!1,reason:"unknown_check"}}}function Tn(e,t,o){let n=Array.isArray(e)?e:[],a=t||(typeof document<"u"?document:null),i=o||(typeof window<"u"?window.location:null);return a?n.map(r=>{let l;try{l=xn(r,a,i)}catch{l={available:!1,reason:"eval_error"}}return{id:r.id,check:r.check,pass:l.available?!!l.pass:!1,available:!!l.available,...l.available||!l.reason?{}:{reason:l.reason}}}):n.map(r=>({id:r.id,check:r.check,pass:!1,available:!1,reason:"no_dom"}))}var Sn="#aih-selection-toolbar, .aih-overflow-dropdown, #aih-selection-result, .aih-token-popup",Cn={light:{"bg-elevated":"#ffffff","tb-panel":"rgba(255,255,255,0.96)","tb-fill":"#f5f6f7","tb-hover":"#f0f0f0","tb-active":"#e4e4e4","tb-border":"#e8e8e8","tb-table-border":"#e0e0e0","tb-divider":"#f0f0f0","tb-text":"#2b3038","tb-text-2":"#5a6675","tb-text-3":"#98a1ad","tb-text-muted":"#bbbbbb","tb-accent":"#3b82f6","tb-accent-hover":"#2563eb","tb-accent-soft":"#eff6ff","tb-on-accent":"#ffffff","tb-brand":"#667eea","tb-warning":"#f59e0b","tb-warning-ink":"#b45309","tb-danger":"#e53e3e"},dark:{"bg-elevated":"#262a33","tb-panel":"rgba(28,31,38,0.94)","tb-fill":"#2a2f3a","tb-hover":"#343b48","tb-active":"#414a5a","tb-border":"#363d4a","tb-table-border":"#3f4756","tb-divider":"#2f3542","tb-text":"#e7eaf0","tb-text-2":"#b7becb","tb-text-3":"#79808e","tb-text-muted":"#565d6b","tb-accent":"#6aa1fb","tb-accent-hover":"#4a8bf0","tb-accent-soft":"#1f2c46","tb-on-accent":"#ffffff","tb-brand":"#8da2f2","tb-warning":"#fbbf24","tb-warning-ink":"#d9a441","tb-danger":"#fc8181"}};function An(e){let t=Cn[e==="dark"?"dark":"light"];return`${Sn}{${Object.keys(t).map(o=>`--${o}:${t[o]};`).join("")}}`}var En=`
|
|
110
110
|
|
|
111
111
|
#aih-selection-toolbar {
|
|
112
112
|
position: fixed;
|
|
@@ -815,7 +815,7 @@ After answering, please provide 3 follow-up questions on a new line in the follo
|
|
|
815
815
|
---SUGGESTIONS---
|
|
816
816
|
Question 1
|
|
817
817
|
Question 2
|
|
818
|
-
Question 3`}});var T={search:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>',explain:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18h6"/><path d="M10 22h4"/><path d="M12 2a7 7 0 0 0-7 7c0 2.4 1.2 4.5 3 5.7V17h8v-2.3c1.8-1.2 3-3.3 3-5.7a7 7 0 0 0-7-7Z"/></svg>',translate:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>',summary:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"/><path d="M14 2v6h6"/><path d="M8 13h2"/><path d="M8 17h2"/><path d="M14 13h2"/><path d="M14 17h2"/></svg>',copy:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',close:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',sparkle:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z"/></svg>',lock:'<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>',unlock:'<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>',copyLarge:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',grip:'<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" stroke="none"><circle cx="8" cy="6" r="1.5"/><circle cx="16" cy="6" r="1.5"/><circle cx="8" cy="12" r="1.5"/><circle cx="16" cy="12" r="1.5"/><circle cx="8" cy="18" r="1.5"/><circle cx="16" cy="18" r="1.5"/></svg>',send:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>',more:'<svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor" stroke="none"><circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/></svg>',gear:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',refresh:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>',block:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.93" y1="4.93" x2="19.07" y2="19.07"/></svg>',eyeOff:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19M14.12 14.12a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>'},b=null,g=null,
|
|
818
|
+
Question 3`}});var T={search:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>',explain:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18h6"/><path d="M10 22h4"/><path d="M12 2a7 7 0 0 0-7 7c0 2.4 1.2 4.5 3 5.7V17h8v-2.3c1.8-1.2 3-3.3 3-5.7a7 7 0 0 0-7-7Z"/></svg>',translate:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>',summary:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"/><path d="M14 2v6h6"/><path d="M8 13h2"/><path d="M8 17h2"/><path d="M14 13h2"/><path d="M14 17h2"/></svg>',copy:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',close:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',sparkle:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z"/></svg>',lock:'<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>',unlock:'<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>',copyLarge:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',grip:'<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" stroke="none"><circle cx="8" cy="6" r="1.5"/><circle cx="16" cy="6" r="1.5"/><circle cx="8" cy="12" r="1.5"/><circle cx="16" cy="12" r="1.5"/><circle cx="8" cy="18" r="1.5"/><circle cx="16" cy="18" r="1.5"/></svg>',send:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>',more:'<svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor" stroke="none"><circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/></svg>',gear:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',refresh:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>',block:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.93" y1="4.93" x2="19.07" y2="19.07"/></svg>',eyeOff:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19M14.12 14.12a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>'},b=null,g=null,H=!1,M=!1,Fe="",ye=null,ve="",D=!1,W=!1,G="",Ue="",gt="",ft="",k="",Ie=!0,me=[],no=!1,ke=!1,ao=0,oe=!1;function qt(){oe=!1}var Pn=!1;function Mn(){Pn||=(document.addEventListener("mouseup",qt,!0),window.addEventListener("blur",qt),!0)}var re={x:0,y:0},K=null,B=null,_t=5,wt=!1,x=null,J="",He=!1,Ke=0,io=null,Ge=!1,nt=new Set,I=window.top===window;if(!I)try{window.parent===window.top&&window.top.document.querySelector("frameset")&&(I=!0)}catch{}R.debug("[SelectionToolbar] moduleload isTopFrame:",I,"top===window:",window.top===window,"hasBody:",!!document.body,"parent===top:",window.parent===window.top);var F=null;function Dn(){let e=document.getElementById("aih-overlay-host");return e||(e=document.createElement("div"),e.id="aih-overlay-host",e.setAttribute("data-aih",""),e.setAttribute("contenteditable","false"),e.style.display="contents",(document.documentElement||document.body).appendChild(e)),e}function q(e){Dn().appendChild(e)}function $e(e){e.setAttribute("data-aih",""),e.setAttribute("contenteditable","false")}function ge(e,t){if(e){try{e.showPopover()}catch{}e.style.display=t}}function j(e){if(e){try{e.hidePopover()}catch{}e.style.display="none"}}function xe(e){return!!e&&e.style.display!==""&&e.style.display!=="none"}var Pe=new Map;function Ln(){return xe(b)||xe(x)||xe(g)||Ge}function Nn(){Pe.forEach((e,t)=>{e===null?t.style.removeProperty("display"):t.style.display=e}),Pe.clear()}function ze(e){if(!e||typeof e.getBoundingClientRect!="function"||!document.elementFromPoint)return;let t=e.getBoundingClientRect();if(!(t.width>0)||!(t.height>0))return;let o=[t.left+t.width*.25,t.left+t.width/2,t.left+t.width*.75],n=[t.top+t.height/2,t.bottom-2];for(let a of o)for(let i of n){let r=document.elementFromPoint(a,i);!r||r.closest("[data-aih]")||Pe.has(r)||(Pe.set(r,r.style.display),r.style.display="none")}}function Q(){Pe.size&&!Ln()&&Nn()}var N=null;function ro(e,t){let o=t?e.querySelector(t):e;o&&(o.style.cursor="grab",o.addEventListener("mousedown",n=>{if(n.target.closest('[role="button"]')||n.button!==0)return;n.preventDefault(),n.stopPropagation();let a=e.getBoundingClientRect();N={el:e,startX:n.clientX,startY:n.clientY,startLeft:a.left,startTop:a.top,pointerId:n.pointerId||0},o.style.cursor="grabbing",e.style.transition="none"}))}document.addEventListener("mousemove",e=>{if(!N)return;let t=e.clientX-N.startX,o=e.clientY-N.startY,n=N.startLeft+t,a=N.startTop+o,i=window.innerWidth,r=window.innerHeight,l=N.el.getBoundingClientRect();n=Math.max(0,Math.min(n,i-l.width)),a=Math.max(0,Math.min(a,r-l.height)),N.el.style.left=n+"px",N.el.style.top=a+"px"}),document.addEventListener("mouseup",()=>{if(!N)return;N.el.style.transition="";let e=N.el.querySelector(".aih-result-header")||N.el;e.style.cursor="grab",N=null});function _(){try{return typeof chrome!="object"||!chrome||typeof chrome.runtime!="object"||!chrome.runtime?!1:!!chrome.runtime.id}catch{return!1}}var Ne=[{id:"ai-search",name:u("optionsConst.aiSearch"),systemPrompt:u("selToolbar.sysPromptAisearch"),builtin:!0,order:0},{id:"explain",name:u("optionsConst.explain"),systemPrompt:u("selToolbar.sysPromptExplain"),builtin:!0,order:1},{id:"translate",name:u("optionsConst.translate"),systemPrompt:u("selToolbar.sysPromptTranslate"),builtin:!0,order:2},{id:"summary",name:u("optionsConst.summary"),systemPrompt:u("selToolbar.sysPromptSummary"),builtin:!0,order:3},{id:"copy",name:u("optionsConst.copy"),systemPrompt:u("selToolbar.sysPromptCopy"),builtin:!0,order:99}];function Ut(e){return e.map(t=>{let o=De(t.id);return o?{...t,name:o}:t})}function lo(){return new Promise(e=>{if(!_()){B=Ut([...Ne]),e(B);return}if(B){e(B);return}try{chrome.storage.local.get(["toolbarTools","toolbarIconOnly"],t=>{let o=t.toolbarTools&&t.toolbarTools.length>0?t.toolbarTools:Ne,n=new Map(Ne.map(a=>[a.id,a]));B=o.map(a=>{if(a.builtin&&n.has(a.id)){let i=De(a.id);return{...a,systemPrompt:n.get(a.id).systemPrompt,name:i||a.name}}return a}),wt=t.toolbarIconOnly||!1,e(B)})}catch{B=Ut([...Ne]),e(B)}})}function Kt(){B=null,wt=!1,lo()}function so(e){return{"ai-search":T.search,explain:T.explain,translate:T.translate,summary:T.summary,copy:T.copy}[e]||T.sparkle}function Fn(){x||(x=document.createElement("div"),x.id="aih-overflow-dropdown",x.className="aih-overflow-dropdown",x.setAttribute("popover","manual"),$e(x),x.style.display="none",q(x),document.addEventListener("click",e=>{x&&xe(x)&&!x.contains(e.target)&&!e.target.closest(".aih-tb-btn-overflow")&&(j(x),Q())}))}function Hn(e){x||Fn();let t=e.map(o=>{let n=so(o.id),a=o.builtin&&De(o.id)||o.name;return`<div class="aih-dropdown-item" role="button" tabindex="0" data-action="${o.id}">
|
|
819
819
|
<span class="aih-tb-icon">${n}</span>${a}
|
|
820
820
|
</div>`}).join("");t+='<div class="aih-dropdown-divider"></div>',t+=`<div class="aih-dropdown-item aih-dropdown-settings" role="button" tabindex="0" title="${u("selToolbar.settingsTitle")}">
|
|
821
821
|
<span class="aih-tb-icon">${T.gear}</span>${u("selToolbar.settings")}
|
|
@@ -823,20 +823,20 @@ Question 3`}});var T={search:'<svg width="15" height="15" viewBox="0 0 24 24" fi
|
|
|
823
823
|
<span class="aih-tb-icon">${T.eyeOff}</span>${u("selToolbar.disableTemporarily")}
|
|
824
824
|
</div>`,t+=`<div class="aih-dropdown-item aih-dropdown-block" role="button" tabindex="0" title="${u("selToolbar.disableOnSiteTitle")}">
|
|
825
825
|
<span class="aih-tb-icon">${T.block}</span>${u("selToolbar.disableOnSite")}
|
|
826
|
-
</div>`,x.innerHTML=t,x._clickHandler=o=>{if(o.target.closest(".aih-dropdown-settings")){o.stopPropagation(),j(x),Q();try{chrome.runtime.sendMessage({type:"OPEN_OPTIONS_PAGE",hash:"toolbar"}).catch(()=>{})}catch{}return}if(o.target.closest(".aih-dropdown-block")){o.stopPropagation(),o.preventDefault(),j(x),Q(),
|
|
826
|
+
</div>`,x.innerHTML=t,x._clickHandler=o=>{if(o.target.closest(".aih-dropdown-settings")){o.stopPropagation(),j(x),Q();try{chrome.runtime.sendMessage({type:"OPEN_OPTIONS_PAGE",hash:"toolbar"}).catch(()=>{})}catch{}return}if(o.target.closest(".aih-dropdown-block")){o.stopPropagation(),o.preventDefault(),j(x),Q(),ea();return}if(o.target.closest(".aih-dropdown-hide")){o.stopPropagation(),o.preventDefault(),j(x),Q(),no=!0,L(),ce(),k="";return}let n=o.target.closest("[data-action]");n&&(o.stopPropagation(),j(x),Q(),ho(n.dataset.action,k))},x.addEventListener("click",x._clickHandler),x.addEventListener("keydown",o=>{if(o.key==="Enter"||o.key===" "){let n=o.target.closest('[role="button"]');n&&(o.preventDefault(),n.click())}}),x.addEventListener("mousedown",()=>{oe=!0})}async function co(){if(b)return;await lo();let e=[...B].sort((m,h)=>m.order-h.order),t=e.find(m=>m.id==="ai-search"),o=e.filter(m=>m.id!=="ai-search"&&m.id!=="copy"),n=o.slice(0,_t-1),a=o.slice(_t-1);b=document.createElement("div"),b.id="aih-selection-toolbar",b.setAttribute("popover","manual"),$e(b);let i='<span class="aih-tb-buttons">';i+=`<span class="aih-tb-grip" title="${u("selToolbar.dragToMove")}">${T.grip}</span>`;let r=wt;t&&(i+=`<div class="aih-tb-btn primary" role="button" tabindex="0" data-action="ai-search" title="${u("optionsConst.aiSearch")}">
|
|
827
827
|
<span class="aih-tb-icon">${T.search}</span>${r?"":u("optionsConst.aiSearch")}
|
|
828
828
|
</div>`),n.forEach(m=>{let h=so(m.id),f=m.builtin&&De(m.id)||m.name;i+=`<div class="aih-tb-btn" role="button" tabindex="0" data-action="${m.id}" title="${f}">
|
|
829
829
|
<span class="aih-tb-icon">${h}</span>${r?"":f}
|
|
830
830
|
</div>`}),i+=`<div class="aih-tb-btn aih-tb-btn-overflow" role="button" tabindex="0" title="${u("selToolbar.moreTools")}">
|
|
831
831
|
<span class="aih-tb-icon">${T.more}</span>
|
|
832
|
-
</div>`,
|
|
832
|
+
</div>`,Hn(a),i+=`<div class="aih-tb-btn" role="button" tabindex="0" data-action="copy" title="${u("selToolbar.copySelectedTitle")}">
|
|
833
833
|
<span class="aih-tb-icon">${T.copy}</span>${r?"":u("optionsConst.copy")}
|
|
834
834
|
</div>`,i+="</span>",i+=`<span class="aih-tb-ask-wrap">
|
|
835
835
|
<input type="text" class="aih-tb-ask-input" placeholder="${u("selToolbar.askPlaceholder")}" />
|
|
836
836
|
<div class="aih-tb-btn aih-tb-ask-send" role="button" tabindex="0" title="${u("selToolbar.sendTitle")}">
|
|
837
837
|
<span class="aih-tb-icon">${T.send}</span>
|
|
838
838
|
</div>
|
|
839
|
-
</span>`,b.innerHTML=i,b.addEventListener("click",m=>{if(m.target.closest(".aih-tb-btn-overflow")){m.stopPropagation();let y=m.target.closest(".aih-tb-btn-overflow").getBoundingClientRect();x&&(xe(x)?(j(x),Q()):(ge(x,"block"),x.style.top=y.bottom+4+"px",x.style.left=y.right-160+"px",requestAnimationFrame(()=>ze(x))));return}let h=m.target.closest("[data-action]");if(!h)return;m.stopPropagation();let f=h.dataset.action;ho(f,k)}),b.addEventListener("keydown",m=>{if(m.key==="Enter"||m.key===" "){let h=m.target.closest('[role="button"]');h&&!h.classList.contains("aih-tb-ask-send")&&(m.preventDefault(),h.click())}}),b.addEventListener("mousedown",()=>{oe=!0}),Mn(),q(b);let l=b.querySelector(".aih-tb-ask-input"),s=b.querySelector(".aih-tb-ask-send");b.querySelector(".aih-tb-buttons");let c=()=>{let m=l.value.trim();if(m){let h=Fe;p(),l.value="",
|
|
839
|
+
</span>`,b.innerHTML=i,b.addEventListener("click",m=>{if(m.target.closest(".aih-tb-btn-overflow")){m.stopPropagation();let y=m.target.closest(".aih-tb-btn-overflow").getBoundingClientRect();x&&(xe(x)?(j(x),Q()):(ge(x,"block"),x.style.top=y.bottom+4+"px",x.style.left=y.right-160+"px",requestAnimationFrame(()=>ze(x))));return}let h=m.target.closest("[data-action]");if(!h)return;m.stopPropagation();let f=h.dataset.action;ho(f,k)}),b.addEventListener("keydown",m=>{if(m.key==="Enter"||m.key===" "){let h=m.target.closest('[role="button"]');h&&!h.classList.contains("aih-tb-ask-send")&&(m.preventDefault(),h.click())}}),b.addEventListener("mousedown",()=>{oe=!0}),Mn(),q(b);let l=b.querySelector(".aih-tb-ask-input"),s=b.querySelector(".aih-tb-ask-send");b.querySelector(".aih-tb-buttons");let c=()=>{let m=l.value.trim();if(m){let h=Fe;p(),l.value="",qn(m,h),L()}},d=()=>{if(M)return;M=!0,Fe=k||"";let m=window.getSelection();m.rangeCount>0&&(ye=m.getRangeAt(0).cloneRange());let h=b.getBoundingClientRect().right;ve=b.style.left,b.classList.add("aih-ask-mode"),b.style.width="360px";let f=Math.max(8,h-360);b.style.left=f+"px",requestAnimationFrame(()=>{if(ye){let y=window.getSelection();y.removeAllRanges(),y.addRange(ye)}requestAnimationFrame(()=>{l.focus()})})},p=()=>{M&&(M=!1,Fe="",ye=null,b.classList.remove("aih-ask-mode"),b.style.width="",ve&&=(b.style.left=ve,""))};l.addEventListener("focus",()=>{M||d()}),l.addEventListener("mousedown",m=>{M||(m.preventDefault(),d())}),l.addEventListener("blur",()=>{setTimeout(()=>{M&&!b.contains(document.activeElement)&&(p(),L())},150)}),l.addEventListener("keydown",m=>{m.key==="Escape"?(m.preventDefault(),m.stopPropagation(),p(),l.blur()):m.key==="Enter"&&(m.preventDefault(),m.stopPropagation(),c())}),s.addEventListener("mousedown",m=>{m.preventDefault(),m.stopPropagation(),c()}),ro(b,".aih-tb-grip")}function uo(){if(g)return;g=document.createElement("div"),g.id="aih-selection-result",g.setAttribute("popover","manual"),$e(g),g.innerHTML=`
|
|
840
840
|
<div class="aih-result-header">
|
|
841
841
|
<span>${T.sparkle} ${u("selToolbar.aiAnswer")}</span>
|
|
842
842
|
<div class="aih-result-header-actions">
|
|
@@ -866,7 +866,7 @@ Question 3`}});var T={search:'<svg width="15" height="15" viewBox="0 0 24 24" fi
|
|
|
866
866
|
<div class="aih-followup-send" role="button" tabindex="0" title="${u("selToolbar.sendToSidebar")}">${T.send}</div>
|
|
867
867
|
</span>
|
|
868
868
|
</div>
|
|
869
|
-
`,g.querySelector(".aih-result-close").addEventListener("click",t=>{t.stopPropagation(),ce()}),g.querySelector(".aih-result-lock").addEventListener("click",t=>{t.stopPropagation(),
|
|
869
|
+
`,g.querySelector(".aih-result-close").addEventListener("click",t=>{t.stopPropagation(),ce()}),g.querySelector(".aih-result-lock").addEventListener("click",t=>{t.stopPropagation(),Bn()}),g.querySelector(".aih-result-footer").addEventListener("click",t=>{t.stopPropagation();let o=t.target.closest(".aih-result-token");if(o){Gn(o);return}let n=t.target.closest("[data-action]")?.dataset?.action;if(n==="regenerate-result"){if(!gt||!Ue)return;bt(gt,Ue,ft)}else n==="copy-result"&&(t.ctrlKey||t.metaKey?Xn():Zn())});let e=g.querySelector(".aih-followup-input");g.querySelector(".aih-followup-send").addEventListener("click",t=>{t.stopPropagation();let o=e.value.trim();o&&(at(o),e.value="")}),e.addEventListener("keydown",t=>{if(t.key==="Enter"){t.preventDefault();let o=e.value.trim();o&&(at(o),e.value="")}}),g.querySelector(".aih-suggestions-list").addEventListener("click",t=>{let o=t.target.closest(".aih-suggestion-chip");if(!o)return;t.stopPropagation();let n=o.dataset.question;n&&at(n)}),g.addEventListener("keydown",t=>{if(t.key==="Enter"||t.key===" "){let o=t.target.closest('[role="button"]');o&&(t.preventDefault(),o.click())}}),q(g),ro(g,".aih-result-header")}function Gt(e,t,o,n=[]){if(!g)return;let a=D&&g.style.display!=="none",i=g.querySelector(".aih-result-body"),r=g.querySelector(".aih-result-scroll"),l=!r||r.scrollTop+r.clientHeight>=r.scrollHeight-24;i.innerHTML=o,l&&r&&(r.scrollTop=r.scrollHeight);let s=g.querySelector(".aih-result-suggestions"),c=g.querySelector(".aih-suggestions-list");if(n.length>0&&s&&c?(c.innerHTML=n.map(m=>`<div class="aih-suggestion-chip" role="button" tabindex="0" data-question="${se(m)}">${se(m)}</div>`).join(""),s.style.display="block"):s&&(s.style.display="none"),a)return;q(g);let d=window.innerWidth,p=window.innerHeight;ge(g,"flex"),g.style.left="-9999px",g.style.top="-9999px",requestAnimationFrame(()=>{let m=g.getBoundingClientRect(),h=m.width||420,f=Math.min(m.height||200,520),y=e-h/2;y<8&&(y=8),y+h>d-8&&(y=d-h-8);let w=t-f-8;w<8&&(w=t+8),g.style.left=y+"px",g.style.top=w+"px",g.style.maxHeight=Math.min(520,p-w-16)+"px",D=!0,q(g)})}function On(e,t){if(!g)return;re={x:e,y:t},W=!1,Ve();let o=g.querySelector(".aih-result-suggestions");o&&(o.style.display="none");let n=g.querySelector(".aih-followup-input");n&&(n.value=""),Te(null),pe(),q(g),ge(g,"flex");let a=g.querySelector(".aih-result-body");a.innerHTML=`<div class="aih-result-loading"><div class="aih-spinner"></div>${u("selToolbar.aiThinking")}</div>`,mo(g,e,t),D=!0,L()}function po(e,t,o){if(!g)return;W=!1,G="",Te(null),Ve(),q(g),ge(g,"flex");let n=g.querySelector(".aih-result-body");n.innerHTML=`<div class="aih-result-error">${u("selToolbar.requestFailed",{msg:se(o)})}</div>`,mo(g,e,t),D=!0}function mo(e,t,o){let n=window.innerWidth,a=window.innerHeight;e.style.left="-9999px",e.style.top="-9999px",requestAnimationFrame(()=>{let i=e.getBoundingClientRect(),r=i.width||420,l=Math.min(i.height||200,520),s=t-r/2;s<8&&(s=8),s+r>n-8&&(s=n-r-8);let c=o-l-8;c<8&&(c=o+8),e.style.left=s+"px",e.style.top=c+"px",e.style.maxHeight=Math.min(520,a-c-16)+"px",q(e),ze(e)})}function ce(){g&&(j(g),Q(),D=!1,W=!1,G="",pe(),Ve())}function Bn(){W=!W,Ve()}function Ve(){if(!g)return;let e=g.querySelector(".aih-result-lock");e&&(W?(e.innerHTML=T.lock,e.classList.add("locked"),e.title=u("selToolbar.unlockWindow")):(e.innerHTML=T.unlock,e.classList.remove("locked"),e.title=u("selToolbar.lockWindow")))}function at(e){if(!e||!_())return;let t=k||Ue||"";try{chrome.runtime.sendMessage({type:"DIRECT_SEND",text:e,selectedText:t}).catch(o=>{R.error("[SelectionToolbar] sendfollow-up tosidebar failed:",o)})}catch{}}function qn(e,t){if(!(!e||!_()))try{chrome.runtime.sendMessage({type:"DIRECT_SEND",text:e,selectedText:t||""}).catch(o=>{R.error("[SelectionToolbar] send to sidesidebar failed:",o)})}catch{}}function se(e){let t=document.createElement("div");return t.textContent=e,t.innerHTML}function _n(){if(He)return;He=!0;let e=Ke;requestAnimationFrame(()=>{He=!1,e===Ke&&Un()})}function Un(){if(!g||!D||!J)return;let e=g.querySelector(".aih-result-body");if(!e)return;let t=J,o=t.indexOf("---SUGGESTIONS---");o!==-1&&(t=t.substring(0,o));let n=g.querySelector(".aih-result-scroll"),a=!n||n.scrollTop+n.clientHeight>=n.scrollHeight-24;e.innerHTML='<div class="aih-result-content-stream">'+Kn(t)+"</div>",a&&n&&(n.scrollTop=n.scrollHeight)}function Kn(e){if(typeof marked>"u")return se(e).replace(/\n/g,"<br>");let t=(e.match(/```/g)||[]).length%2==1?e+"\n```":e;return marked.parse(t)}function it(e){return!e||e<=0?"0":e<1e3?String(e):e<1e4?Math.round(e/100)/10+"K":e<1e6?Math.round(e/1e3)+"K":Math.round(e/1e5)/10+"M"}function Te(e){if(!g)return;io=e||null;let t=g.querySelector(".aih-result-token");if(!t)return;let o=e&&(e.total_tokens||(e.prompt_tokens||0)+(e.completion_tokens||0));if(!o){t.style.display="none",t.textContent="",t.removeAttribute("title");return}t.innerHTML=`<span class="aih-token-dot">\u2B24</span>${it(o)} tokens`,t.title=u("selToolbar.tokenUsageTitle",{input:it(e.prompt_tokens||0),output:it(e.completion_tokens||0)}),t.style.display="inline-flex"}function rt(e){return!e&&e!==0?"0":Number(e).toLocaleString("en-US")}function pe(){let e=document.querySelector(".aih-token-popup");e&&(j(e),e.remove()),Ge=!1,Q()}function Gn(e){let t=io;if(!t)return;let o=t.total_tokens||(t.prompt_tokens||0)+(t.completion_tokens||0);if(!o)return;if(Ge){pe();return}pe();let n=t.prompt_tokens||0,a=t.completion_tokens||0,i=Math.round(n/o*100),r=Math.round(a/o*100),l=document.createElement("div");l.className="aih-token-popup",l.setAttribute("popover","manual"),$e(l),l.innerHTML=`
|
|
870
870
|
<div class="aih-token-popup-header">
|
|
871
871
|
<span class="aih-token-popup-title">${u("selToolbar.tokenPopupTitle")}</span>
|
|
872
872
|
<button class="aih-token-popup-close" type="button" aria-label="close">\xD7</button>
|
|
@@ -892,7 +892,7 @@ Question 3`}});var T={search:'<svg width="15" height="15" viewBox="0 0 24 24" fi
|
|
|
892
892
|
</div>
|
|
893
893
|
</div>
|
|
894
894
|
</div>
|
|
895
|
-
`,q(l),ge(l,"flex"),Ge=!0;let s=e.getBoundingClientRect(),c=l.getBoundingClientRect(),d=s.top-c.height-8>0?s.top-c.height-8:s.bottom+8,p=s.left+s.width/2-c.width/2;p=Math.max(8,Math.min(p,window.innerWidth-c.width-8)),d+c.height>window.innerHeight-8&&(d=window.innerHeight-c.height-8),l.style.top=d+"px",l.style.left=p+"px",ze(l),l.querySelector(".aih-token-popup-close").addEventListener("click",h=>{h.stopPropagation(),pe()});let m=h=>{!l.contains(h.target)&&!e.contains(h.target)&&(pe(),document.removeEventListener("click",m,!0))};setTimeout(()=>{document.addEventListener("click",m,!0)},0)}function Me(e,t){if(!b||!k||
|
|
895
|
+
`,q(l),ge(l,"flex"),Ge=!0;let s=e.getBoundingClientRect(),c=l.getBoundingClientRect(),d=s.top-c.height-8>0?s.top-c.height-8:s.bottom+8,p=s.left+s.width/2-c.width/2;p=Math.max(8,Math.min(p,window.innerWidth-c.width-8)),d+c.height>window.innerHeight-8&&(d=window.innerHeight-c.height-8),l.style.top=d+"px",l.style.left=p+"px",ze(l),l.querySelector(".aih-token-popup-close").addEventListener("click",h=>{h.stopPropagation(),pe()});let m=h=>{!l.contains(h.target)&&!e.contains(h.target)&&(pe(),document.removeEventListener("click",m,!0))};setTimeout(()=>{document.addEventListener("click",m,!0)},0)}function Me(e,t){if(!b||!k||D)return;q(b);let o=window.innerWidth,n=window.innerHeight;ge(b,"flex"),ao=Date.now(),requestAnimationFrame(()=>{let a=b.getBoundingClientRect(),i=a.width||300,r=a.height||40,l=e-i/2;l<8&&(l=8),l+i>o-8&&(l=o-i-8);let s=t-r-10;s<8&&(s=t+10),s<8&&(s=8),s+r>n-8&&(s=n-r-8),b.style.left=l+"px",b.style.top=s+"px",ze(b),H||=(b.classList.add("aih-show"),!0)})}function L(){!b||!H||(oe=!1,M&&(M=!1,Fe="",ye=null,b.classList.remove("aih-ask-mode"),b.style.width="",ve&&=(b.style.left=ve,"")),b.classList.remove("aih-show"),j(b),Q(),H=!1)}function Wn(){if(!b)return{x:0,y:0};let e=b.getBoundingClientRect();return{x:e.left+e.width/2,y:e.top}}function $n(e){let t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top}}function Oe(){if(!_()||!Ie)return;if(!I){let i=ne();if(R.debug("[SelectionToolbar] iframe onSelectionChange text:",i.text?.substring(0,30),"currentSelectedText:",!!k,"pendingIframeSelection:",!!F),i.text&&i.text.length>=2){let r=Ae(i.range);F={text:i.text,x:r.x,y:r.y},R.debug("[SelectionToolbar] iframe pendingIframeSelection set")}else if(k&&!oe){k="",F=null;try{chrome.runtime.sendMessage({type:"IFRAME_SELECTION_CLEAR"}).catch(()=>{})}catch{}}return}if(me.length>0&&me.includes(window.location.hostname)||no)return;let e=window.getSelection(),t=e?e.toString().trim():"",o=null;if(t&&t.length>=2&&e.rangeCount>0)o=e.getRangeAt(0);else{let i=ne();i.text&&i.text.length>=2&&(t=i.text,o=i.range)}if(!t||t.length<2){!M&&!oe&&L(),oe||(k="",K=null);return}let n=5e3,a=t.length>n?t.substring(0,n)+"...":t;if(o){let i=o.commonAncestorContainer,r=i.nodeType===Node.TEXT_NODE?i.parentElement.closest("[contenteditable], input, textarea"):i.closest&&i.closest("[contenteditable], input, textarea");if(r instanceof HTMLElement&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA")){L(),k="",K=null;return}}k=a,K=!0}function zn(e){if(!(b&&b.contains(e.target))&&!(g&&g.contains(e.target))&&!(e.target.closest&&e.target.closest(".aih-token-popup"))){if(ke){ke=!1;return}D&&!W&&ce(),H&&!M&&L();try{chrome.runtime.sendMessage({type:"IFRAME_CLICK_DISMISS"}).catch(()=>{})}catch{}}}function Vn(e){if(R.debug("[SelectionToolbar] onMouseUp isTopFrame:",I,"pendingSelection:",K,"pendingIframeSelection:",!!F,"currentSelectedText:",!!k,"isToolbarVisible:",H,"toolbarEl:",!!b),(e.detail||1)>=3&&(ke=!0),!I){if(F){ke=!0,F.text,k=F.text;try{window.parent.postMessage({type:"IFRAME_SELECTION",text:F.text,x:F.x,y:F.y},"*")}catch{}try{chrome.runtime.sendMessage({type:"IFRAME_SELECTION",text:F.text,x:F.x,y:F.y}).catch(()=>{})}catch{}F=null}else(e.detail||1)>=3&&setTimeout(()=>{let t=ne();if(!t.text||t.text.length<2)return;let o=Ae(t.range);t.text,k=t.text;try{window.parent.postMessage({type:"IFRAME_SELECTION",text:t.text,x:o.x,y:o.y},"*")}catch{}try{chrome.runtime.sendMessage({type:"IFRAME_SELECTION",text:t.text,x:o.x,y:o.y}).catch(()=>{})}catch{}},60);return}H||D||(K&&k?(ke=!0,Wt()):(e.detail||1)>=3&&setTimeout(()=>{M||(Oe(),K&&k&&Wt())},60))}function Wt(){if(!K||!k||H)return;let e=window.innerWidth/2,t=window.innerHeight/2,o=window.getSelection();if(o&&o.rangeCount>0){let n=o.getRangeAt(0).getBoundingClientRect();(n.width>0||n.height>0)&&(e=n.left+n.width/2,t=n.top)}if(e===window.innerWidth/2&&t===window.innerHeight/2){let n=ne();if(n.text&&n.text.length>=2){let a=Ae(n.range);e=a.x,t=a.y}}try{chrome.runtime.sendMessage({type:"IFRAME_CLICK_DISMISS"}).catch(()=>{})}catch{}Me(e,t),K=null}function jn(){if(M)return;if(!I&&k){let o=ne();if(o.text){let n=Ae(o.range);try{window.parent.postMessage({type:"IFRAME_SELECTION",text:o.text,x:n.x,y:n.y},"*")}catch{}try{chrome.runtime.sendMessage({type:"IFRAME_SELECTION",text:o.text,x:n.x,y:n.y}).catch(()=>{})}catch{}}return}if(!H)return;let e=window.getSelection();if(e&&e.rangeCount>0&&k){let o=e.getRangeAt(0).getBoundingClientRect();if(o.width>0||o.height>0){Me(o.left+o.width/2,o.top);return}}let t=ne();if(t.text&&t.text.length>=2&&k){let o=Ae(t.range);Me(o.x,o.y);return}L()}function Qn(){M||H&&L()}function ho(e,t){if(!t)return;if(Ue=t,e==="copy"){Yn(t),L();return}if(gt=e,ft="",["ai-search","explain","translate","summary"].includes(e)){bt(e,t);return}let o=B.find(n=>n.id===e);o&&(ft=o.systemPrompt||"",bt(e,t,o.systemPrompt))}function Yn(e){go(e).then(()=>{je()}).catch(t=>{R.error("[SelectionToolbar] copy failed:",t),Se()})}function Zn(){let e=G;e&&go(e).then(()=>{je(u("selToolbar.copiedMarkdown"))}).catch(t=>{R.error("[SelectionToolbar] copyresult failed:",t),Se()})}function Xn(){let e=G;if(!e)return;let t=Jn(typeof marked<"u"?marked.parse(e):se(e).replace(/\n/g,"<br>"));if(navigator.clipboard&&typeof ClipboardItem<"u")try{let o=new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})});navigator.clipboard.write([o]).then(()=>{je(u("selToolbar.copiedRich"))}).catch(n=>{R.error("[SelectionToolbar] richcopy failed:",n),$t()});return}catch(o){R.error("[SelectionToolbar] richcopy failed:",o)}$t()}function Jn(e){return`<!DOCTYPE html><html><head>
|
|
896
896
|
<style>
|
|
897
897
|
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; line-height: 1.6; color: #24292f; }
|
|
898
898
|
h1 { font-size: 24px; font-weight: bold; margin: 16px 0 8px; }
|
|
@@ -946,7 +946,7 @@ Question 3`}});var T={search:'<svg width="15" height="15" viewBox="0 0 24 24" fi
|
|
|
946
946
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
947
947
|
pointer-events: none;
|
|
948
948
|
animation: aih-toast-in 0.2s ease-out, aih-toast-out 0.2s 1.5s ease-in forwards;
|
|
949
|
-
`,q(t),t.style.zIndex="2147483647",setTimeout(()=>t.remove(),1800)}function je(e){let t=document.getElementById("aih-copy-toast");t&&t.remove();let o=document.createElement("div");if(o.id="aih-copy-toast",o.setAttribute("data-aih",""),o.textContent=e||u("selToolbar.copied"),o.style.cssText=`
|
|
949
|
+
`,q(t),t.style.zIndex="2147483647",setTimeout(()=>t.remove(),1800)}function je(e){let t=document.getElementById("aih-copy-toast");t&&t.remove();let o=document.createElement("div");if(o.id="aih-copy-toast",o.setAttribute("data-aih",""),o.setAttribute("contenteditable","false"),o.textContent=e||u("selToolbar.copied"),o.style.cssText=`
|
|
950
950
|
position: fixed;
|
|
951
951
|
top: 50%;
|
|
952
952
|
left: 50%;
|
|
@@ -965,9 +965,9 @@ Question 3`}});var T={search:'<svg width="15" height="15" viewBox="0 0 24 24" fi
|
|
|
965
965
|
@keyframes aih-toast-out { from { opacity: 1; } to { opacity: 0; } }
|
|
966
966
|
`,document.head.appendChild(n)}q(o),o.style.zIndex="2147483647",setTimeout(()=>o.remove(),1300)}function bt(e,t,o){if(!_()){R.warn("[SelectionToolbar] extensiontextexpired,pleaserefreshpage");return}let n={"ai-search":u("selToolbar.userMsgAisearch",{text:t}),explain:u("selToolbar.userMsgExplain",{text:t}),translate:u("selToolbar.userMsgTranslate",{text:t}),summary:u("selToolbar.userMsgSummary",{text:t})},a=o?`\u8BF7\u5904\u7406\u4EE5\u4E0B\u5185\u5BB9\uFF1A
|
|
967
967
|
|
|
968
|
-
${t}`:n[e]||t;if(e==="ai-search"){
|
|
968
|
+
${t}`:n[e]||t;if(e==="ai-search"){L(),window.getSelection().removeAllRanges();try{chrome.runtime.sendMessage({type:"SELECTION_TOOLBAR_ACTION",action:e,text:t,prompt:a}).catch(s=>{R.error("[SelectionToolbar] sendmessage failed:",s)})}catch{}return}uo();let i={"ai-search":u("optionsConst.aiSearch"),explain:u("optionsConst.explain"),translate:u("optionsConst.translate"),summary:u("optionsConst.summary")}[e];if(!i&&B){let s=B.find(c=>c.id===e);i=s?s.builtin&&De(s.id)||s.name:u("selToolbar.aiAnswer")}let r=g.querySelector(".aih-result-header span");r&&(r.innerHTML=`${T.sparkle} ${i||u("selToolbar.aiAnswer")}`);let l=D&&g?$n(g):Wn();On(l.x,l.y);try{chrome.runtime.sendMessage({type:"SELECTION_TOOLBAR_ACTION",action:e,text:t,prompt:a,systemPrompt:o||""}).catch(s=>{R.error("[SelectionToolbar] sendmessage failed:",s),po(l.x,l.y,s.message)})}catch{}}_()&&chrome.runtime.onMessage.addListener((e,t,o)=>{if(_()){if(e.type==="IFRAME_SELECTION"){if(!I)return;R.debug("[SelectionToolbar] recei to IFRAME_SELECTION text:",e.text?.substring(0,30),"isToolbarVisible:",H,"isResultVisible:",D),k=e.text;let n=e.x,a=e.y;if(window.top!==window&&window.frameElement)try{let i=window.frameElement.getBoundingClientRect();n=e.x-i.left,a=e.y-i.top}catch{}if(H&&b&&k){requestAnimationFrame(()=>{let i=window.innerWidth,r=b.offsetWidth||300,l=b.offsetHeight||40,s=n-r/2;s<8&&(s=8),s+r>i-8&&(s=i-r-8);let c=a-l-8;c<8&&(c=a+8),b.style.left=s+"px",b.style.top=c+"px"});return}K={x:n,y:a},k&&k.length>=2&&Me(n,a);return}if(e.type==="IFRAME_SELECTION_CLEAR"){if(!I||oe)return;H&&!M&&(L(),k="");return}if(e.type==="IFRAME_CLICK_DISMISS"){H&&b&&Date.now()-ao>300&&(L(),k=""),D&&!W&&ce();return}if(I){if(e.type==="SELECTION_TOOLBAR_STREAM_START"){J="",He=!1,Ke++;return}if(e.type==="SELECTION_TOOLBAR_STREAM_CHUNK"){J+=e.delta||"",_n();return}if(e.type==="SELECTION_TOOLBAR_STREAM_DONE"){Ke++,e.finalContent&&(J=e.finalContent);let n=J||u("selToolbar.noResponse");G=J;let a=n,i=[],r=n.indexOf("---SUGGESTIONS---");r!==-1&&(a=n.substring(0,r).trim(),G=a,i=n.substring(r+17).split(`
|
|
969
969
|
`).map(s=>s.replace(/^[\d]+[\.\、\s]+/,"").trim()).filter(s=>s.length>0).slice(0,3));let l=typeof marked<"u"?marked.parse(a):se(a).replace(/\n/g,"<br>");Gt(re.x,re.y,l,i),Te(e.usage),J="";return}if(e.type==="SELECTION_TOOLBAR_RESULT")if(e.error)G="",Te(null),po(re.x,re.y,e.error);else{let n=e.content||u("selToolbar.noResponse"),a=n;G=n;let i=[],r=n.indexOf("---SUGGESTIONS---");r!==-1&&(a=n.substring(0,r).trim(),G=a,i=n.substring(r+17).split(`
|
|
970
|
-
`).map(s=>s.replace(/^[\d]+[\.\、\s]+/,"").trim()).filter(s=>s.length>0).slice(0,3));let l=typeof marked<"u"?marked.parse(a):se(a).replace(/\n/g,"<br>");Gt(re.x,re.y,l,i),Te(e.usage)}}}});function
|
|
970
|
+
`).map(s=>s.replace(/^[\d]+[\.\、\s]+/,"").trim()).filter(s=>s.length>0).slice(0,3));let l=typeof marked<"u"?marked.parse(a):se(a).replace(/\n/g,"<br>");Gt(re.x,re.y,l,i),Te(e.usage)}}}});function ea(){if(!_())return;let e=window.location.hostname;try{chrome.storage.local.get(["blockedDomains"],t=>{try{let o=t.blockedDomains||[];o.includes(e)||(o.push(e),chrome.storage.local.set({blockedDomains:o},()=>{me=o,L(),ce(),k=""}))}catch{}})}catch{}}function ta(){_()&&chrome.storage.local.get(["enableSelectionToolbar","blockedDomains"],e=>{Ie=e.enableSelectionToolbar===void 0?!0:!!e.enableSelectionToolbar,me=e.blockedDomains||[],R.debug("[SelectionToolbar] toggle state:",Ie?"enabled":"disabled","blocked domains:",me.length)})}var Qe=!0,he="light";function oa(){return Qe?he==="system"?typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":he==="dark"?"dark":"light":"light"}function vt(){Rn(oa())}function na(){_()&&chrome.storage.local.get(["appTheme","selectionToolbarFollowTheme"],e=>{he=["light","dark","system"].includes(e.appTheme)?e.appTheme:"light",Qe=e.selectionToolbarFollowTheme===void 0?!0:!!e.selectionToolbarFollowTheme,vt()})}_()&&chrome.storage.onChanged.addListener((e,t)=>{_()&&(t==="local"&&e.enableSelectionToolbar&&(Ie=!!e.enableSelectionToolbar.newValue,Ie||(L(),ce(),k="")),t==="local"&&e.blockedDomains&&(me=e.blockedDomains.newValue||[]),t==="local"&&e.toolbarTools&&Kt(),t==="local"&&(e.appTheme||e.selectionToolbarFollowTheme)&&(e.appTheme&&(he=["light","dark","system"].includes(e.appTheme.newValue)?e.appTheme.newValue:he),e.selectionToolbarFollowTheme&&(Qe=!!e.selectionToolbarFollowTheme.newValue),vt()))}),Ct(()=>{Kt(),I&&(b&&=(b.remove(),null),co(),g&&(g.remove(),g=null,D=!1,W=!1,G=""))});function aa(){if(oo(),I&&(co(),uo()),ta(),na(),typeof matchMedia<"u"){let e=matchMedia("(prefers-color-scheme: dark)"),t=()=>{Qe&&he==="system"&&vt()};e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t)}document.addEventListener("selectionchange",Oe),document.addEventListener("click",zn,!0),document.addEventListener("mouseup",Vn,!0),window.addEventListener("scroll",jn,!0),window.addEventListener("resize",Qn),window.addEventListener("message",e=>{if(e.data?.type==="IFRAME_SELECTION"&&I){if(D){k="",K=null;return}k=e.data.text;let t=e.data.x,o=e.data.y;if(window.top!==window&&window.frameElement)try{let n=window.frameElement.getBoundingClientRect();t=e.data.x-n.left,o=e.data.y-n.top}catch{}if(H&&b&&k){requestAnimationFrame(()=>{let n=window.innerWidth,a=b.offsetWidth||300,i=b.offsetHeight||40,r=t-a/2;r<8&&(r=8),r+a>n-8&&(r=n-a-8);let l=o-i-8;l<8&&(l=o+8),b.style.left=r+"px",b.style.top=l+"px"});return}K={x:t,y:o},k&&k.length>=2&&Me(t,o);return}e.data?.type==="IFRAME_CLICK_DISMISS"&&I&&D&&!W&&ce()}),I&&(nt=st(Oe),new MutationObserver(()=>{Po(nt),nt=st(Oe)}).observe(document.body,{childList:!0,subtree:!0})),R.debug("[SelectionToolbar] initialization complete",I?"(toplayerframe)":"(subframe)")}A("zh",{contentIndex:{invalidRef:"\u65E0\u6548\u7684\u5143\u7D20\u7F16\u53F7 ref={ref}\uFF0C\u8BF7\u5148\u8C03\u7528 query_elements",regionSelectHint:"\u62D6\u62FD\u9009\u62E9\u622A\u56FE\u533A\u57DF\uFF0C\u6309 Esc \u53D6\u6D88"}}),A("en",{contentIndex:{invalidRef:"Invalid element ref={ref}; please call query_elements first",regionSelectHint:"Drag to select the screenshot area; press Esc to cancel"}});var ia=Et();console.log("[ContentScript] content script loaded URL:",window.location.href,"isTopFrame:",window.top===window,"hasBody:",!!document.body),document.addEventListener("keydown",e=>{if((e.ctrlKey||e.metaKey)&&e.shiftKey&&e.key==="A"){e.preventDefault();try{chrome.action.click()}catch{}}if(e.altKey&&!e.shiftKey&&e.code==="KeyS"&&!e.ctrlKey&&!e.metaKey){e.preventDefault();try{chrome.runtime.sendMessage({type:"CAPTURE_TAB_FROM_PAGE"})}catch{}}if(e.altKey&&e.shiftKey&&e.code==="KeyS"&&!e.ctrlKey&&!e.metaKey){e.preventDefault();try{chrome.runtime.sendMessage({type:"CAPTURE_REGION_FROM_PAGE"})}catch{}}if(e.altKey&&!e.shiftKey&&e.code==="KeyV"&&!e.ctrlKey&&!e.metaKey){if(e.isComposing||e.repeat)return;e.preventDefault();try{chrome.runtime.sendMessage({type:"VOICE_TOGGLE_FROM_PAGE"})}catch{}}});var We={...be};tt().then(e=>{We=e}).catch(()=>{}),Mt(e=>{We=e});var lt=Pt(()=>We);window.addEventListener("keydown",e=>{lt.onKeyDown(e)==="cancel"&&e.preventDefault()},!0),window.addEventListener("keyup",e=>{if(lt.onKeyUp(e)==="trigger"){e.preventDefault();try{chrome.runtime.sendMessage({type:"VOICE_TOGGLE_FROM_PAGE"})}catch{}}},!0),window.addEventListener("blur",()=>{lt.reset()});var Vt=()=>{tt().then(e=>{We=e}).catch(()=>{})};window.addEventListener("focus",Vt),document.addEventListener("visibilitychange",()=>{document.hidden||Vt()});var ra={GET_PAGE_TEXT:e=>Jo(e),GET_FULL_HTML:e=>en(e),QUERY_ELEMENTS:e=>Vo(e),SNAPSHOT_COLLECT:e=>window.top!==window&&!Wo()?{success:!0,visible:!1}:eo({filterByText:e.filterByText,elementTypes:e.elementTypes,frames:e.frames==="none"?"none":"auto"}),GET_SELECTED_CONTENT:e=>tn(e.format),INTERACT_ELEMENT:e=>e.ref==null?e.text?gn(e.text,{tag:e.tag,action:e.action,waitTime:e.waitTime,timeout:e.timeout}):e.action==="hover"?rn(e.selector):sn(e.selector,e.waitTime,e.timeout):Yo(e.ref,e.action,{waitTime:e.waitTime,timeout:e.timeout,value:e.value,clear:e.clear,submit:e.submit}),FILL_FORM:e=>cn(e.fields,e.waitTime),SCROLL_TO:e=>e.target==="text"&&e.text?Xo(e.text,{maxScrolls:e.maxScrolls,pauseMs:e.pauseMs}):dn(e),KEYBOARD_INPUT:e=>mn(e),FILE_UPLOAD:e=>hn(e.selector,e.fileName,e.fileContent,e.fileType),EXTRACT_TABLE:e=>on(e.selector,e.includeHeaders,e.format),EXTRACT_METADATA:()=>Mo(),EXTRACT_LINKS:e=>Do(e.filterType,e.includeImages),EXTRACT_FORMS:e=>Lo(e.formSelector),EXTRACT_IMAGES:e=>No(e),SEARCH_IN_PAGE:e=>Ho(e),IFRAME_CONTENT:e=>Fo(e.selector,e.includeNested,e.maxLength),SCROLL_COLLECT:e=>Qo(e),MANAGE_STORAGE:e=>bn(e),INJECT_CSS:e=>e.injectMode==="highlight"?ln(e.text,e.color):kn(e.css,e.targetSelector,e.injectMode),EVALUATE_DONE_CRITERIA:e=>Tn(e.criteria),COPY_TO_CLIPBOARD:e=>nn(e.text),PASTE_FROM_CLIPBOARD:()=>an(),WAIT_ELEMENT:e=>un(e.selector,e.state,e.timeout),SELECT_DROPDOWN:e=>{let t=e.triggerSelector;if(e.ref!=null&&!t){let o=yt(e.ref);if(!o.element)return{success:!1,error:u("contentIndex.invalidRef",{ref:e.ref}),...o.suggestions&&o.suggestions.length?{suggestions:o.suggestions}:{}};t=o.entry.selector}return fn(t,e.optionText,e.optionSelector,e.timeout)},QRCODE:e=>wn(e.content,e.size,e.errorCorrection,e.showImage),START_REGION_SELECTION:()=>ca(),GET_PAGE_METRICS:()=>({width:Math.max(document.documentElement.scrollWidth,document.body.scrollWidth||0,window.innerWidth),height:Math.max(document.documentElement.scrollHeight,document.body.scrollHeight||0,window.innerHeight)})},la=new Set(["COPY_TO_CLIPBOARD","PASTE_FROM_CLIPBOARD","WAIT_ELEMENT","SELECT_DROPDOWN","QRCODE","START_REGION_SELECTION","INTERACT_ELEMENT","SCROLL_TO","KEYBOARD_INPUT"]),sa=new Set(["GET_PAGE_TEXT","GET_FULL_HTML","EXTRACT_METADATA","EXTRACT_TABLE","IFRAME_CONTENT","QUERY_ELEMENTS","EVALUATE_DONE_CRITERIA","INTERACT_ELEMENT","SCROLL_TO"]);_()&&chrome.runtime.onMessage.addListener((e,t,o)=>{if(sa.has(e.type)&&window.top!==window&&!e._frameRouted)return;if(e.action==="getSelectedText"){let i=window.getSelection()?.toString()?.trim()||"";if(i&&document.hasFocus())return o({text:i}),!0;let r=ne();return r.text&&r.text.trim()&&document.hasFocus()&&o({text:r.text.trim()}),!0}let n=ra[e.type];if(!n)return;let a=n(e);if(la.has(e.type)||a instanceof Promise)return Promise.resolve(a).then(o),!0;o(a)}),window.addEventListener("error",e=>{e.message&&e.message.includes("Extension context invalidated")&&e.preventDefault()}),window.addEventListener("unhandledrejection",e=>{(e.reason?.message||String(e.reason)).includes("Extension context invalidated")&&e.preventDefault()}),ia.then(()=>{aa()});function ca(){return new Promise(e=>{let t=document.createElement("div");t.id="__region_select_overlay__",t.style.cssText=`
|
|
971
971
|
position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
|
|
972
972
|
z-index: 2147483647; cursor: crosshair;
|
|
973
973
|
background: rgba(0, 0, 0, 0.15);
|