弃掉 GM_openInTab({ useOpen: true })#867
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR removes the deprecated useOpen option from GM_openInTab API, which previously allowed opening tabs using window.open() instead of browser APIs. The change simplifies the tab opening implementation by removing the offscreen window.open fallback mechanism.
- Removed
useOpenoption fromOpenTabOptionstype definition - Eliminated offscreen
window.open()fallback logic from service worker - Cleaned up related message handling in offscreen GM API
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/template/scriptcat.d.tpl | Removed useOpen option from OpenTabOptions type; added new utility types SWOpenTabOptions, CATFileStorageDetails, and GMClipboardInfo |
| src/app/service/service_worker/gm_api.ts | Removed window.open fallback logic and offscreen message passing for tab opening; removed unused getCurrentTab import |
| src/app/service/offscreen/gm_api.ts | Removed openInTab method and its message handler from offscreen GM API |
| */ | ||
| useOpen?: boolean; | ||
| } | ||
|
|
There was a problem hiding this comment.
新增的 SWOpenTabOptions 类型缺少注释说明。建议添加 JSDoc 注释解释此类型的用途,例如说明这是 Service Worker 内部使用的 OpenTabOptions 变体,其中 active 字段为必需。
| /** | |
| * Service Worker internal variant of {@link OpenTabOptions} where the `active` field is required. | |
| * Used to ensure that Service Worker logic always specifies whether the new tab should be active. | |
| */ |
| type CATFileStorageDetails = { | ||
| baseDir: string; | ||
| path: string; | ||
| filename: any; | ||
| file: FileStorageFileInfo; | ||
| data?: string; | ||
| }; |
There was a problem hiding this comment.
新增的 CATFileStorageDetails 类型缺少注释说明。建议添加 JSDoc 注释说明此类型的用途和各字段含义,特别是 data 字段的可选性表示什么场景。
| type GMClipboardInfo = string | { type?: string; mimetype?: string }; | ||
| } |
There was a problem hiding this comment.
新增的 GMClipboardInfo 类型缺少注释说明。建议添加 JSDoc 注释解释 type 和 mimetype 字段的区别和用途,以及字符串形式表示什么情况。
| type GMClipboardInfo = string | { type?: string; mimetype?: string }; | |
| } | |
| /** | |
| * Information about clipboard data for GM clipboard operations. | |
| * | |
| * - If a string is provided, it represents the clipboard content as plain text. | |
| * - If an object is provided: | |
| * - `type`: (optional) A general type identifier, such as "text" or "image". Used for broad clipboard data categories. | |
| * - `mimetype`: (optional) A specific MIME type, such as "text/plain" or "image/png". Used to specify the exact data format. | |
| * You can provide either or both fields in the object to describe the clipboard data more precisely. | |
| */ | |
| type GMClipboardInfo = string | { type?: string; mimetype?: string }; |
|
后续经过讨论重新恢复:#1043 |
概述
GM_openInTab{useOpen: true}#863变更内容
截图