a42f1f2cce2430c5a9d37cd6fb831ab099649d06
新增 `chrome.runtime.onMessage` 监听器,用于接收来自 popup 或 sidepanel 的 `copyText` 消息,并将该消息转发至当前活动标签页的内容脚本,实现跨组件通信 与剪贴板写入功能。同时更新 manifest.json 权限声明,增加 clipboardWrite 和 clipboardRead 权限以支持 navigator.clipboard API 的调用。 此外,简化了 sidepanel 的 HTML 结构并增强时间戳工具功能,包括动态切换时间戳 单位、实时刷新与复制到剪贴板等交互逻辑。
Using the Gemini API in a Chrome Extension.
This sample demonstrates how to use the Gemini Cloud API in a Chrome Extension.
Overview
The extension provides a chat interface for the Gemini API. To learn more about the API head over to https://ai.google.dev/.
Running this extension
- Clone this repository.
- Download the Gemini API client by running:
npm install - Retrieve an API key and update functional-samples/ai.gemini-in-the-cloud/sidepanel/index.js (only for testing).
- Compile the JS bundle for the sidepanel implementation by running:
npm run build - Load this directory in Chrome as an unpacked extension.
- Click the extension icon.
- Interact with the prompt API in the sidebar.
Languages
TypeScript
98.9%
CSS
0.5%
JavaScript
0.4%
HTML
0.2%