dsh-chrome-bridge 1.17.0 → 1.19.0
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/README.en.md +32 -0
- package/README.md +23 -18
- package/client.js +65 -19
- package/i18n/en.js +11 -2
- package/i18n/ru.js +11 -2
- package/i18n/zh.js +11 -2
- package/index.js +63 -14
- package/locale/en.json +2 -1
- package/locale/zh.json +2 -1
- package/package.json +2 -1
- package/vendor/extension/_locales/en/messages.json +5 -0
- package/vendor/extension/_locales/ru/messages.json +5 -0
- package/vendor/extension/_locales/zh_CN/messages.json +5 -0
- package/vendor/extension/_locales/zh_TW/messages.json +5 -0
- package/vendor/extension/background.js +327 -25
- package/vendor/extension/manifest.json +3 -2
- package/vendor/extension/popup.css +10 -5
- package/vendor/extension/popup.html +20 -14
- package/vendor/extension/popup.js +374 -66
package/README.en.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Chrome Bridge
|
|
2
|
+
|
|
3
|
+
Lets DSH work in the Chrome you already use: real clicks and typing, a cursor you can see on the page, and your own logins.
|
|
4
|
+
|
|
5
|
+
- Pages it opens go into a separate window, so your own window gets no new tabs and keeps focus.
|
|
6
|
+
- It never touches the page you are looking at on its own.
|
|
7
|
+
- Pause it any time: click the DSH Bridge icon in Chrome's toolbar and turn off "Let DSH control the browser".
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
1. In DSH, open **Plugins**, click **Add plugin**, enter `dsh-chrome-bridge`, then restart DSH.
|
|
12
|
+
2. Add the DSH Bridge extension from the [Chrome Web Store](https://chromewebstore.google.com/detail/bippcbbbipppmhjkjomgdnjbooecbimo).
|
|
13
|
+
|
|
14
|
+
Once both are in, the plugin shows "Connected" on the Plugins page.
|
|
15
|
+
|
|
16
|
+
To let DSH upload files into web pages: open the extension's **Details** in Chrome and turn on **Allow access to file URLs** (Chrome keeps it off by default). The DSH Bridge popup also shows a "File uploads · Open" row.
|
|
17
|
+
|
|
18
|
+
## Update
|
|
19
|
+
|
|
20
|
+
Open it on the Plugins page and click "Update to …". A new version can be installed about a day after it is released.
|
|
21
|
+
|
|
22
|
+
## Languages
|
|
23
|
+
|
|
24
|
+
- The extension panel in Chrome follows Chrome's language: English, Chinese or Russian.
|
|
25
|
+
- The settings card on the Plugins page follows DSH's language.
|
|
26
|
+
- To give the model English or Russian tool descriptions too, see "Tool descriptions in English or Russian" in the [full guide](https://github.com/OrderG-X/dsh-chrome-bridge#-tool-descriptions-in-english-or-russian).
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
macOS, Windows or Linux, and Chrome 116 or newer.
|
|
31
|
+
|
|
32
|
+
Full guide: https://github.com/OrderG-X/dsh-chrome-bridge
|
package/README.md
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Chrome 浏览器控制
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
让 DSH 直接操作你正在用的 Chrome:真点击、真输入,页面里看得到它的光标,你的登录状态都在。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- 它新开的页放进一个单独的窗口,不往你正在用的窗口里塞,也不抢焦点。
|
|
6
|
+
- 它不会擅自去动你正在看的那一页。
|
|
7
|
+
- 随时能暂停:点 Chrome 工具栏上的 DSH Bridge 图标,关掉「允许 DSH 控制浏览器」。
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
agent 新开的页放进你 Chrome 里一个单独的后台窗口,你自己的窗口不多标签页、焦点不动。
|
|
9
|
+
## 怎么装
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
1. 在 DSH「插件」页点「添加插件」,填 `dsh-chrome-bridge`,然后重启 DSH。
|
|
12
|
+
2. 从 [Chrome 应用商店](https://chromewebstore.google.com/detail/bippcbbbipppmhjkjomgdnjbooecbimo) 装上 DSH Bridge 扩展。
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
在 DSH「插件」页点「添加插件」,填 `dsh-chrome-bridge`,重启 DSH。DSH 连不上 npm 时会自动换国内镜像。
|
|
14
|
-
2. Add the DSH Bridge extension to Chrome from the [Chrome Web Store](https://chromewebstore.google.com/detail/bippcbbbipppmhjkjomgdnjbooecbimo).
|
|
15
|
-
从 [Chrome 应用商店](https://chromewebstore.google.com/detail/bippcbbbipppmhjkjomgdnjbooecbimo) 装上 DSH Bridge 扩展。
|
|
14
|
+
装好后,插件页上它会显示「已连接」。
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
系统要求:macOS、Windows 或 Linux,Chrome 116+,Node.js 18+。
|
|
16
|
+
想让 DSH 帮你往网页里上传文件:在 Chrome 打开扩展的「详情」,打开「允许访问文件网址」(Chrome 默认关着)。点 DSH Bridge 图标,面板里也有一行「上传文件 · 去打开」。
|
|
19
17
|
|
|
20
|
-
##
|
|
18
|
+
## 怎么更新
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
在「插件」页点开它,点「更新到 …」。新版发布后大约一天才装得到。
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
## 语言
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
- Chrome 里的扩展面板跟着 Chrome 的语言走:中文、英文、俄文。
|
|
25
|
+
- 插件页上的这张设置卡片跟着 DSH 的语言走。
|
|
26
|
+
- 想让模型看到的工具说明也换成英文或俄文,看[完整说明](https://github.com/OrderG-X/dsh-chrome-bridge/blob/main/README.zh.md)里「工具描述支持英文 / 俄文」那一节。
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
## 系统要求
|
|
29
|
+
|
|
30
|
+
macOS、Windows 或 Linux,Chrome 116 或更新。
|
|
31
|
+
|
|
32
|
+
完整说明:https://github.com/OrderG-X/dsh-chrome-bridge
|
|
33
|
+
|
|
34
|
+
English: https://github.com/OrderG-X/dsh-chrome-bridge/blob/main/plugin/README.en.md
|
package/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-chrome-bridge 的网页端:DSH「插件」页里我们这张卡的设置页。
|
|
3
3
|
*
|
|
4
|
-
* 连接状态(扩展 /
|
|
4
|
+
* 连接状态(扩展 / 本机程序、版本、正在控制哪些标签页)+ 全部放开;文字有中 / 英 / 俄三份,跟着 DSH 的界面语言
|
|
5
5
|
* 三个开关:允许 DSH 控制浏览器(这里只能关)、页面里显示 DSH 光标、新页开在单独窗口
|
|
6
6
|
* 没连上时:差哪一步、一键帮你打开安装页
|
|
7
7
|
*
|
|
@@ -49,20 +49,20 @@ window.__ModuleLoader__.load({
|
|
|
49
49
|
localBuild: '本地版',
|
|
50
50
|
controlling: '正在控制 %n 个标签页',
|
|
51
51
|
controllingIdle: '没有在控制的标签页',
|
|
52
|
-
releaseAll: '
|
|
53
|
-
released: '
|
|
52
|
+
releaseAll: '全部放开',
|
|
53
|
+
released: '已全部放开',
|
|
54
54
|
allowControl: '允许 DSH 控制浏览器',
|
|
55
|
-
allowControlHint: '关掉后,DSH
|
|
56
|
-
resumeInChrome: '
|
|
55
|
+
allowControlHint: '关掉后,DSH 碰不了浏览器。要重新打开,得去 Chrome 工具栏点 DSH Bridge 图标——DSH 自己打不开。',
|
|
56
|
+
resumeInChrome: '要恢复:点 Chrome 工具栏上的 DSH Bridge 图标,在里面把控制重新打开。',
|
|
57
57
|
showCursor: '页面里显示 DSH 光标',
|
|
58
|
-
showCursorHint: '
|
|
58
|
+
showCursorHint: '关掉只是不显示光标,点击、输入照做。',
|
|
59
59
|
ownWindow: '新页开在单独窗口',
|
|
60
|
-
ownWindowHint: 'DSH 新开的页放进一个单独的 Chrome
|
|
61
|
-
ownWindowOld: 'Chrome
|
|
62
|
-
outdated: 'Chrome
|
|
60
|
+
ownWindowHint: 'DSH 新开的页放进一个单独的 Chrome 窗口,登录状态照样在,不往你正在用的窗口里塞,也不抢焦点。关掉就开在你当前窗口的后台。',
|
|
61
|
+
ownWindowOld: 'Chrome 里的扩展更新后才有这个开关,现在新页开在你当前窗口的后台。',
|
|
62
|
+
outdated: 'Chrome 里的扩展版本旧了,更新后才能在这里改开关。',
|
|
63
63
|
setupTitle: '还差一步:把扩展装进 Chrome',
|
|
64
|
-
setupStoreTitle: '
|
|
65
|
-
setupStep1: '打开 Chrome
|
|
64
|
+
setupStoreTitle: '扩展装好了,但还没连上',
|
|
65
|
+
setupStep1: '打开 Chrome,地址栏输入 chrome://extensions,打开右上角的「开发者模式」',
|
|
66
66
|
setupStep2: '点「加载已解压的扩展程序」,选这个文件夹:',
|
|
67
67
|
setupStep3: '装好后这里会自动变成「已连接」',
|
|
68
68
|
setupStoreAlt: '更省事:直接从 Chrome 应用商店装,不用开发者模式。',
|
|
@@ -76,7 +76,7 @@ window.__ModuleLoader__.load({
|
|
|
76
76
|
pathCopiedWin: ',文件夹路径也复制好了(粘进文件框顶上的地址栏、回车)',
|
|
77
77
|
plugin: '插件 v%v',
|
|
78
78
|
guide: '使用说明',
|
|
79
|
-
failed: '
|
|
79
|
+
failed: '没成功:%e',
|
|
80
80
|
unreachable: '读不到插件状态,重启 DSH 后再试',
|
|
81
81
|
}
|
|
82
82
|
const en = {
|
|
@@ -97,16 +97,16 @@ window.__ModuleLoader__.load({
|
|
|
97
97
|
releaseAll: 'Release all',
|
|
98
98
|
released: 'Released all tabs',
|
|
99
99
|
allowControl: 'Allow DSH to control the browser',
|
|
100
|
-
allowControlHint: 'When off, DSH
|
|
101
|
-
resumeInChrome: 'To resume, click the DSH Bridge icon in Chrome\'s toolbar and turn
|
|
100
|
+
allowControlHint: 'When off, DSH can\'t touch the browser. To turn it back on, click the DSH Bridge icon in Chrome\'s toolbar; DSH can\'t do that itself.',
|
|
101
|
+
resumeInChrome: 'To resume, click the DSH Bridge icon in Chrome\'s toolbar and turn control back on there.',
|
|
102
102
|
showCursor: 'Show the DSH cursor on pages',
|
|
103
103
|
showCursorHint: 'Off only hides the cursor; clicks and typing still happen.',
|
|
104
104
|
ownWindow: 'Open new pages in a separate window',
|
|
105
|
-
ownWindowHint: 'Pages DSH opens go into their own Chrome window
|
|
106
|
-
ownWindowOld: '
|
|
107
|
-
outdated: 'The extension in Chrome is
|
|
105
|
+
ownWindowHint: 'Pages DSH opens go into their own Chrome window, with your logins, instead of piling up in the window you are using, and never take focus. Off: background tabs in your current window.',
|
|
106
|
+
ownWindowOld: 'Update the extension in Chrome to get this switch; for now new pages open as background tabs in your current window.',
|
|
107
|
+
outdated: 'The extension in Chrome is out of date; update it to change these switches here.',
|
|
108
108
|
setupTitle: 'One step left: add the extension to Chrome',
|
|
109
|
-
setupStoreTitle: 'The extension is installed but not connected',
|
|
109
|
+
setupStoreTitle: 'The extension is installed but not connected yet',
|
|
110
110
|
setupStep1: 'Open chrome://extensions in Chrome and turn on Developer mode (top right)',
|
|
111
111
|
setupStep2: 'Click "Load unpacked" and choose this folder:',
|
|
112
112
|
setupStep3: 'This page turns to "Connected" once it is loaded',
|
|
@@ -125,6 +125,52 @@ window.__ModuleLoader__.load({
|
|
|
125
125
|
unreachable: 'Could not read the plugin status; restart DSH and try again',
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
const ru = {
|
|
129
|
+
title: 'Управление Chrome',
|
|
130
|
+
checking: 'Проверка…',
|
|
131
|
+
connected: 'Подключено',
|
|
132
|
+
paused: 'Пауза',
|
|
133
|
+
disconnected: 'Не подключено',
|
|
134
|
+
unsupported: 'Работает только на macOS, Windows и Linux',
|
|
135
|
+
summaryOn: 'Подключено · вкладок под управлением: %n',
|
|
136
|
+
summaryIdle: 'Подключено, вкладок под управлением нет',
|
|
137
|
+
summaryOff: 'Chrome ещё не подключён — откройте, чтобы увидеть шаги',
|
|
138
|
+
summaryPaused: 'Пауза: DSH не может работать с браузером',
|
|
139
|
+
storeBuild: 'Из магазина',
|
|
140
|
+
localBuild: 'Локальная',
|
|
141
|
+
controlling: 'Вкладок под управлением: %n',
|
|
142
|
+
controllingIdle: 'Вкладок под управлением нет',
|
|
143
|
+
releaseAll: 'Отпустить все',
|
|
144
|
+
released: 'Все вкладки отпущены',
|
|
145
|
+
allowControl: 'Разрешить DSH управлять браузером',
|
|
146
|
+
allowControlHint: 'Выкл.: DSH не может трогать браузер. Включить обратно можно только через значок DSH Bridge на панели инструментов Chrome — сам DSH этого сделать не может.',
|
|
147
|
+
resumeInChrome: 'Чтобы продолжить, нажмите значок DSH Bridge на панели инструментов Chrome и снова включите управление.',
|
|
148
|
+
showCursor: 'Показывать курсор DSH',
|
|
149
|
+
showCursorHint: 'Выкл. только скрывает курсор, клики и ввод продолжаются.',
|
|
150
|
+
ownWindow: 'Новые страницы в отдельном окне',
|
|
151
|
+
ownWindowHint: 'Страницы, которые открывает DSH, попадают в отдельное окно Chrome (ваши входы в аккаунты сохраняются), не засоряют ваше окно и не перехватывают фокус. Выкл.: фоновые вкладки в текущем окне.',
|
|
152
|
+
ownWindowOld: 'Обновите расширение в Chrome, чтобы появился этот переключатель; пока новые страницы открываются фоном в текущем окне.',
|
|
153
|
+
outdated: 'Расширение в Chrome устарело; обновите его, чтобы менять переключатели здесь.',
|
|
154
|
+
setupTitle: 'Остался один шаг: добавить расширение в Chrome',
|
|
155
|
+
setupStoreTitle: 'Расширение установлено, но ещё не подключено',
|
|
156
|
+
setupStep1: 'Откройте в Chrome chrome://extensions и включите «Режим разработчика» справа вверху',
|
|
157
|
+
setupStep2: 'Нажмите «Загрузить распакованное расширение» и выберите эту папку:',
|
|
158
|
+
setupStep3: 'Как только расширение загрузится, здесь появится «Подключено»',
|
|
159
|
+
setupStoreAlt: 'Проще: установить из Chrome Web Store, режим разработчика не нужен.',
|
|
160
|
+
openStore: 'Открыть магазин',
|
|
161
|
+
storeOpened: 'Страница магазина открыта в Chrome — нажмите «Установить»',
|
|
162
|
+
setupStore1: 'Проверьте, что Chrome запущен, а расширение DSH Bridge включено',
|
|
163
|
+
setupStore2: 'Если не помогло — перезапустите Chrome',
|
|
164
|
+
openInstall: 'Открыть страницу установки',
|
|
165
|
+
installOpened: 'Страница расширений открыта в Chrome',
|
|
166
|
+
pathCopied: '; путь к папке скопирован (в окне выбора файлов ⌘⇧G, затем ⌘V)',
|
|
167
|
+
pathCopiedWin: '; путь к папке скопирован (вставьте его в адресную строку окна выбора файлов)',
|
|
168
|
+
plugin: 'Плагин v%v',
|
|
169
|
+
guide: 'Инструкция',
|
|
170
|
+
failed: 'Не получилось: %e',
|
|
171
|
+
unreachable: 'Не удалось прочитать состояние плагина; перезапустите DSH и попробуйте снова',
|
|
172
|
+
}
|
|
173
|
+
|
|
128
174
|
const fmt = (s, vars) => String(s).replace(/%([a-z])/g, (m, k) => (vars && k in vars ? String(vars[k]) : m))
|
|
129
175
|
|
|
130
176
|
const CSS = `
|
|
@@ -335,7 +381,7 @@ window.__ModuleLoader__.load({
|
|
|
335
381
|
function apply(ctx) {
|
|
336
382
|
const t = ctx.locale && typeof ctx.locale.bind === 'function' ? ctx.locale.bind(NS) : (k) => zh[k] || k
|
|
337
383
|
if (ctx.locale && typeof ctx.locale.register === 'function') {
|
|
338
|
-
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-chrome-bridge: dictionaries')
|
|
384
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en, ru }), 'dsh-chrome-bridge: dictionaries')
|
|
339
385
|
}
|
|
340
386
|
const Card = makeCard(t)
|
|
341
387
|
const mount = (name, key) => {
|
package/i18n/en.js
CHANGED
|
@@ -38,10 +38,10 @@ export default {
|
|
|
38
38
|
'tool.input.action': 'Input action to perform',
|
|
39
39
|
'tool.input.text': 'Text to enter when action=type',
|
|
40
40
|
'tool.input.ref': '%ref; can replace selector',
|
|
41
|
-
'tool.input.selector': 'CSS selector (for type it is clicked first to focus; select/
|
|
41
|
+
'tool.input.selector': 'CSS selector (for type it is clicked first to focus; select/focus/hover need it or ref; upload needs it too, unless the reply to your last click explicitly said the page is asking for a file)',
|
|
42
42
|
'tool.input.key': 'Key for action=key, e.g. Enter / Escape / "meta+a" / "ctrl+shift+k"',
|
|
43
43
|
'tool.input.value': 'Value or option label to pick when action=select',
|
|
44
|
-
'tool.input.files': 'Absolute local file paths for action=upload (only regular, non-hidden files under the session working directory or the system temp directory)',
|
|
44
|
+
'tool.input.files': 'Absolute local file paths for action=upload (only regular, non-hidden files under the session working directory or the system temp directory). Only when the reply to your last click explicitly said the page is asking for a file may upload omit ref / selector',
|
|
45
45
|
'tool.input.dy': 'Vertical scroll amount for action=scroll; default 600 (positive scrolls down)',
|
|
46
46
|
'tool.input.dx': 'Horizontal scroll amount for action=scroll; default 0',
|
|
47
47
|
'tool.input.x': 'Viewport X for action=hover when no selector is given',
|
|
@@ -135,6 +135,15 @@ export default {
|
|
|
135
135
|
'err.selectNeedsValue': 'action=select needs value',
|
|
136
136
|
'err.uploadNeedsTarget': 'action=upload needs ref or selector',
|
|
137
137
|
'err.uploadNeedsFiles': 'action=upload needs files',
|
|
138
|
+
'err.uploadNoChooser': "The page is not waiting for a file: click the page's upload button first (the reply will say so), or point at the file input with ref / selector",
|
|
139
|
+
'err.uploadUserPicked': 'Someone used this file input after it was intercepted (most likely the user picked a file themselves), so nothing was replaced. If you really need to swap in your files, ask the user first, then click the upload button again.',
|
|
140
|
+
'err.uploadFolder': 'This is a folder picker, and DSH cannot pick folders yet: ask the user to click the matching button on the page and pick the folder themselves (their own clicks are not intercepted).',
|
|
141
|
+
'err.uploadSingle': 'This file input takes only one file; pass a single path in files',
|
|
142
|
+
'err.fileAccessOff': 'Cannot upload: by default Chrome does not let extensions read files on the computer. Ask the user to open %url (the DSH Bridge details page) in Chrome and turn on "Allow access to file URLs". The extension then reloads by itself; wait a few seconds and upload again (if the page had opened a file picker, click its upload button again).',
|
|
143
|
+
'note.fileChooser': '📎 The page is asking for a file%multi: the system file picker was intercepted (it will not open). Hand the files to it with browser_input action=upload files=[…]; no ref / selector needed. If the user wants to pick in the system dialog themselves, ask them to click this button (their own clicks are not intercepted).',
|
|
144
|
+
'note.fileChooserMulti': ' (multiple allowed)',
|
|
145
|
+
'note.fileChooserUnsupported': '⚠️ The page opened a different kind of system file dialog (not a file input in the page). DSH cannot fill it, and this one was cancelled. Clicking again shows the normal system dialog; the user has to pick the file there.',
|
|
146
|
+
'note.fileChooserFolder': '⚠️ This button asks for a whole folder, and DSH cannot pick folders yet, so this system dialog will not open. Ask the user to click this button and pick the folder themselves (their own clicks are not intercepted).',
|
|
138
147
|
'err.focusNeedsTarget': 'action=focus needs ref or selector',
|
|
139
148
|
'err.hoverNeedsTarget': 'action=hover needs ref or selector, or x/y coordinates',
|
|
140
149
|
'err.navNeedsUrl': 'action=go needs a url',
|
package/i18n/ru.js
CHANGED
|
@@ -39,10 +39,10 @@ export default {
|
|
|
39
39
|
'tool.input.action': 'Какое действие ввода выполнить',
|
|
40
40
|
'tool.input.text': 'Текст для ввода при action=type',
|
|
41
41
|
'tool.input.ref': '%ref; может заменить selector',
|
|
42
|
-
'tool.input.selector': 'CSS-селектор (для type по нему сначала кликают, чтобы сфокусировать; select/
|
|
42
|
+
'tool.input.selector': 'CSS-селектор (для type по нему сначала кликают, чтобы сфокусировать; select/focus/hover нужен он или ref; upload тоже, если только ответ на последний клик прямо не сообщил, что страница просит файл)',
|
|
43
43
|
'tool.input.key': 'Клавиша для action=key, например Enter / Escape / "meta+a" / "ctrl+shift+k"',
|
|
44
44
|
'tool.input.value': 'value или текст пункта для action=select',
|
|
45
|
-
'tool.input.files': 'Абсолютные пути к локальным файлам для action=upload (только обычные, не скрытые файлы внутри рабочей папки сеанса или системного временного каталога)',
|
|
45
|
+
'tool.input.files': 'Абсолютные пути к локальным файлам для action=upload (только обычные, не скрытые файлы внутри рабочей папки сеанса или системного временного каталога). Только если ответ на последний клик прямо сообщил, что страница просит файл, upload можно вызывать без ref / selector',
|
|
46
46
|
'tool.input.dy': 'Величина вертикальной прокрутки для action=scroll; по умолчанию 600 (положительная — вниз)',
|
|
47
47
|
'tool.input.dx': 'Величина горизонтальной прокрутки для action=scroll; по умолчанию 0',
|
|
48
48
|
'tool.input.x': 'Координата X во вьюпорте для action=hover, если selector не задан',
|
|
@@ -136,6 +136,15 @@ export default {
|
|
|
136
136
|
'err.selectNeedsValue': 'action=select требует value',
|
|
137
137
|
'err.uploadNeedsTarget': 'action=upload требует ref или selector',
|
|
138
138
|
'err.uploadNeedsFiles': 'action=upload требует files',
|
|
139
|
+
'err.uploadNoChooser': 'Страница сейчас не ждёт файл: сначала нажмите её кнопку загрузки (в ответе будет подсказка) или укажите поле файла через ref / selector',
|
|
140
|
+
'err.uploadUserPicked': 'После перехвата этим полем файла уже кто-то воспользовался (скорее всего, пользователь сам выбрал файл), поэтому ничего не заменено. Если действительно нужно подставить ваши файлы, сначала спросите пользователя, затем снова нажмите кнопку загрузки.',
|
|
141
|
+
'err.uploadFolder': 'Это поле выбора папки, а DSH пока не умеет выбирать папки: попросите пользователя самого нажать соответствующую кнопку на странице и выбрать папку (его нажатия не перехватываются).',
|
|
142
|
+
'err.uploadSingle': 'Это поле принимает только один файл; укажите в files один путь',
|
|
143
|
+
'err.fileAccessOff': 'Не удалось загрузить: по умолчанию Chrome не даёт расширениям читать файлы на компьютере. Попросите пользователя открыть в Chrome %url (страница сведений DSH Bridge) и включить «Разрешить открывать локальные файлы по ссылкам» (Allow access to file URLs). Расширение само перезагрузится; подождите несколько секунд и загрузите снова (если страница открывала окно выбора файла, нажмите её кнопку загрузки ещё раз).',
|
|
144
|
+
'note.fileChooser': '📎 Страница просит выбрать файл%multi: системное окно выбора файла перехвачено (оно не откроется). Передайте файлы через browser_input action=upload files=[…], ref / selector не нужны. Если пользователь хочет выбрать сам в системном окне, попросите его самого нажать эту кнопку (его нажатия не перехватываются).',
|
|
145
|
+
'note.fileChooserMulti': ' (можно несколько)',
|
|
146
|
+
'note.fileChooserUnsupported': '⚠️ Страница открыла системное окно другого типа (не поле файла на странице). DSH не может его заполнить, это окно отменено. Повторное нажатие откроет обычное системное окно — файл придётся выбрать пользователю.',
|
|
147
|
+
'note.fileChooserFolder': '⚠️ Эта кнопка просит выбрать целую папку, а DSH пока не умеет выбирать папки, поэтому это системное окно не откроется. Попросите пользователя самого нажать эту кнопку и выбрать папку (его нажатия не перехватываются).',
|
|
139
148
|
'err.focusNeedsTarget': 'action=focus требует ref или selector',
|
|
140
149
|
'err.hoverNeedsTarget': 'action=hover требует ref или selector, либо координаты x/y',
|
|
141
150
|
'err.navNeedsUrl': 'action=go требует url',
|
package/i18n/zh.js
CHANGED
|
@@ -39,10 +39,10 @@ export default {
|
|
|
39
39
|
'tool.input.action': '要做的输入动作',
|
|
40
40
|
'tool.input.text': 'action=type 时要输入的文字',
|
|
41
41
|
'tool.input.ref': '%ref;可代替 selector',
|
|
42
|
-
'tool.input.selector': 'CSS 选择器(type 时先点它聚焦;select/
|
|
42
|
+
'tool.input.selector': 'CSS 选择器(type 时先点它聚焦;select/focus/hover 要它或 ref;upload 也要,除非刚才的点击回话明确提示「页面要选文件」)',
|
|
43
43
|
'tool.input.key': 'action=key 的按键,例如 Enter / Escape / "meta+a" / "ctrl+shift+k"',
|
|
44
44
|
'tool.input.value': 'action=select 时要选的 value 或选项文字',
|
|
45
|
-
'tool.input.files': 'action=upload
|
|
45
|
+
'tool.input.files': 'action=upload 的本地文件绝对路径(只限会话工作目录或系统临时目录下、非隐藏的文件)。只有刚才的点击回话明确提示「页面要选文件」时,upload 才可以不给 ref / selector',
|
|
46
46
|
'tool.input.dy': 'action=scroll 的纵向滚动量,默认 600(向下为正)',
|
|
47
47
|
'tool.input.dx': 'action=scroll 的横向滚动量,默认 0',
|
|
48
48
|
'tool.input.x': 'action=hover 且不用 selector 时的视口 X 坐标',
|
|
@@ -136,6 +136,15 @@ export default {
|
|
|
136
136
|
'err.selectNeedsValue': 'action=select 需要 value',
|
|
137
137
|
'err.uploadNeedsTarget': 'action=upload 需要 ref 或 selector',
|
|
138
138
|
'err.uploadNeedsFiles': 'action=upload 需要 files',
|
|
139
|
+
'err.uploadNoChooser': '页面现在没在等选文件:先点页面上的上传按钮(点完回话里会提示),或者用 ref / selector 指定文件输入框',
|
|
140
|
+
'err.uploadUserPicked': '拦下以后有人自己动过这个文件框(多半是用户自己选了文件),没有替换。确实要换成你的文件,先问用户,再重新点一次上传按钮。',
|
|
141
|
+
'err.uploadFolder': '这是选文件夹的框,DSH 暂时没法替你选文件夹:请用户自己点页面上对应的按钮选(用户自己点不会被拦)。',
|
|
142
|
+
'err.uploadSingle': '这个文件框一次只收一个文件,files 只给一个',
|
|
143
|
+
'err.fileAccessOff': '上传不了:Chrome 默认不让扩展读电脑上的文件。请用户在 Chrome 里打开 %url(DSH Bridge 的详情页),打开「允许访问文件网址」。打开后扩展会自动重新加载,等几秒再上传;之前点出来的选文件窗口要重新点一次。',
|
|
144
|
+
'note.fileChooser': '📎 页面要选文件%multi:系统的选文件窗口已经拦下(不会弹出来)。用 browser_input action=upload files=[…] 把文件交给它,不用给 ref / selector。要是用户想自己在系统窗口里选,请用户自己点这个按钮(用户自己点不会被拦)。',
|
|
145
|
+
'note.fileChooserMulti': '(可以多选)',
|
|
146
|
+
'note.fileChooserUnsupported': '⚠️ 页面打开的是另一种系统文件窗口(不是网页里的文件框),DSH 没法替你选,这一下已经被取消。再点一次会照常弹出系统窗口,需要用户自己在里面选文件。',
|
|
147
|
+
'note.fileChooserFolder': '⚠️ 这个按钮要选的是整个文件夹,DSH 暂时没法替你选文件夹,这一下的系统窗口不会弹出来。请用户自己点这个按钮选文件夹(用户自己点不会被拦)。',
|
|
139
148
|
'err.focusNeedsTarget': 'action=focus 需要 ref 或 selector',
|
|
140
149
|
'err.hoverNeedsTarget': 'action=hover 需要 ref 或 selector,或者给 x/y 坐标',
|
|
141
150
|
'err.navNeedsUrl': 'action=go 需要 url',
|
package/index.js
CHANGED
|
@@ -415,6 +415,44 @@ function sessionCwd(exec) {
|
|
|
415
415
|
return typeof cwd === 'string' && path.isAbsolute(cwd) ? cwd : ''
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
+
/**
|
|
419
|
+
* 点击 / 按键让页面要选文件时,扩展已把系统的选文件窗口拦下、回一个 id。记在「会话 + 标签页」名下:
|
|
420
|
+
* 之后这个会话 upload 不给目标就带着它去,别的会话拿不到(不会把文件塞进人家刚点开的框)。
|
|
421
|
+
*/
|
|
422
|
+
const chooserIds = new Map()
|
|
423
|
+
const chooserKey = (tabId) => `${sessionKey()}:${Number(tabId)}`
|
|
424
|
+
|
|
425
|
+
/** 点击 / 按键回话后面补的那句。老扩展不回 fileChooser,就什么也不加 */
|
|
426
|
+
function chooserNote(r, tabId) {
|
|
427
|
+
const c = r && r.fileChooser
|
|
428
|
+
if (!c) return ''
|
|
429
|
+
if (c.unsupported) return '\n' + t('note.fileChooserUnsupported')
|
|
430
|
+
if (c.folder) return '\n' + t('note.fileChooserFolder')
|
|
431
|
+
chooserIds.set(chooserKey(tabId), c.id)
|
|
432
|
+
return '\n' + t('note.fileChooser', { multi: c.mode === 'selectMultiple' ? t('note.fileChooserMulti') : '' })
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* upload 的报错换成说得清的话:
|
|
437
|
+
* 没开「允许访问文件网址」:新扩展报 FILE_ACCESS_OFF(带详情页地址),老扩展只回 CDP 的一句 Not allowed(issue #7)
|
|
438
|
+
* 单选框给了多个文件 / 页面没在等选文件 / 用户自己已经选好 / 选文件夹的框(新扩展的记号)
|
|
439
|
+
* 不给目标时老扩展的参数错(它不认这种用法)→ 还是「要 ref 或 selector」
|
|
440
|
+
* 别的错原样抛。
|
|
441
|
+
*/
|
|
442
|
+
function uploadError(e, noTarget) {
|
|
443
|
+
const msg = String(e && e.message || e)
|
|
444
|
+
if (/FILE_ACCESS_OFF|Not allowed/.test(msg)) {
|
|
445
|
+
const url = (/chrome:\/\/extensions\/\?id=[a-p]{32}/.exec(msg) || [])[0] || 'chrome://extensions'
|
|
446
|
+
return new Error(t('err.fileAccessOff', { url }))
|
|
447
|
+
}
|
|
448
|
+
if (msg.includes('MULTI_NOT_ALLOWED')) return new Error(t('err.uploadSingle'))
|
|
449
|
+
if (msg.includes('NO_FILE_CHOOSER')) return new Error(t('err.uploadNoChooser'))
|
|
450
|
+
if (msg.includes('USER_PICKED')) return new Error(t('err.uploadUserPicked'))
|
|
451
|
+
if (msg.includes('FOLDER_INPUT')) return new Error(t('err.uploadFolder'))
|
|
452
|
+
if (noTarget && /params\.selector|mandatory field|Invalid parameters|没找到文件输入框/.test(msg)) return new Error(t('err.uploadNeedsTarget'))
|
|
453
|
+
return e
|
|
454
|
+
}
|
|
455
|
+
|
|
418
456
|
/**
|
|
419
457
|
* upload 能塞进网页的文件:只限会话工作目录、系统临时目录下的普通文件,路径里任何一段以 . 开头
|
|
420
458
|
* (~/.ssh、.env 这类隐藏目录/文件)都不行。按 realpath 判断,软链接绕不过去;交给扩展的也是 realpath。
|
|
@@ -649,24 +687,24 @@ export function apply(ctx, config) {
|
|
|
649
687
|
if (args.ref !== undefined && args.ref !== null) {
|
|
650
688
|
const el = await locate(call, tabId, args.ref, { wantPoint: count > 1 })
|
|
651
689
|
if (el.selector && count === 1) {
|
|
652
|
-
const r = await call('clickEl', { tabId, selector: el.selector, ...withCursor() })
|
|
653
|
-
return { text: `已点击 [${args.ref}] ${r.target.tag}「${r.target.text}」@ (${r.x}, ${r.y})` }
|
|
690
|
+
const r = await call('clickEl', { tabId, selector: el.selector, ...withCursor(), chooser: true })
|
|
691
|
+
return { text: `已点击 [${args.ref}] ${r.target.tag}「${r.target.text}」@ (${r.x}, ${r.y})${chooserNote(r, tabId)}` }
|
|
654
692
|
}
|
|
655
693
|
// shadow DOM / iframe 里的元素(选择器够不着),或者要双击:按坐标点
|
|
656
|
-
const r = await call('click', { tabId, x: el.x, y: el.y, clickCount: count, ...withCursor() })
|
|
657
|
-
return { text: `已点击 [${args.ref}] ${el.tag}「${el.text}」@ (${r.x}, ${r.y})${count > 1 ? ` ×${count}` : ''}` }
|
|
694
|
+
const r = await call('click', { tabId, x: el.x, y: el.y, clickCount: count, ...withCursor(), chooser: true })
|
|
695
|
+
return { text: `已点击 [${args.ref}] ${el.tag}「${el.text}」@ (${r.x}, ${r.y})${count > 1 ? ` ×${count}` : ''}${chooserNote(r, tabId)}` }
|
|
658
696
|
}
|
|
659
697
|
if (args.selector) {
|
|
660
|
-
const r = await call('clickEl', { tabId, selector: args.selector, ...withCursor() })
|
|
661
|
-
return { text: `已点击 ${r.target.tag}「${r.target.text}」@ (${r.x}, ${r.y})` }
|
|
698
|
+
const r = await call('clickEl', { tabId, selector: args.selector, ...withCursor(), chooser: true })
|
|
699
|
+
return { text: `已点击 ${r.target.tag}「${r.target.text}」@ (${r.x}, ${r.y})${chooserNote(r, tabId)}` }
|
|
662
700
|
}
|
|
663
701
|
if (args.text) {
|
|
664
|
-
const r = await call('clickText', { tabId, text: args.text, exact: false, ...withCursor() })
|
|
665
|
-
return { text: `已点击 ${r.target.tag}「${r.target.text}」@ (${r.x}, ${r.y})` }
|
|
702
|
+
const r = await call('clickText', { tabId, text: args.text, exact: false, ...withCursor(), chooser: true })
|
|
703
|
+
return { text: `已点击 ${r.target.tag}「${r.target.text}」@ (${r.x}, ${r.y})${chooserNote(r, tabId)}` }
|
|
666
704
|
}
|
|
667
705
|
if (args.x !== undefined && args.y !== undefined) {
|
|
668
|
-
const r = await call('click', { tabId, x: Number(args.x), y: Number(args.y), clickCount: count, ...withCursor() })
|
|
669
|
-
return { text: `已点击坐标 (${r.x}, ${r.y})` }
|
|
706
|
+
const r = await call('click', { tabId, x: Number(args.x), y: Number(args.y), clickCount: count, ...withCursor(), chooser: true })
|
|
707
|
+
return { text: `已点击坐标 (${r.x}, ${r.y})${chooserNote(r, tabId)}` }
|
|
670
708
|
}
|
|
671
709
|
throw new Error(t('err.clickNeeds'))
|
|
672
710
|
},
|
|
@@ -720,8 +758,8 @@ export function apply(ctx, config) {
|
|
|
720
758
|
}
|
|
721
759
|
case 'key': {
|
|
722
760
|
if (!args.key) throw new Error(t('err.keyNeedsKey'))
|
|
723
|
-
await call('key', { tabId, key: args.key })
|
|
724
|
-
return { text: `已按键 ${args.key}` }
|
|
761
|
+
const r = await call('key', { tabId, key: args.key, chooser: true })
|
|
762
|
+
return { text: `已按键 ${args.key}${chooserNote(r, tabId)}` }
|
|
725
763
|
}
|
|
726
764
|
case 'select': {
|
|
727
765
|
if (!selector && !el) throw new Error(t('err.selectNeedsTarget'))
|
|
@@ -734,11 +772,22 @@ export function apply(ctx, config) {
|
|
|
734
772
|
return { text: `已选择「${r.label}」(${r.value})` }
|
|
735
773
|
}
|
|
736
774
|
case 'upload': {
|
|
737
|
-
if (!selector && !el) throw new Error(t('err.uploadNeedsTarget'))
|
|
738
775
|
if (!args.files?.length) throw new Error(t('err.uploadNeedsFiles'))
|
|
739
776
|
noShadow('upload')
|
|
740
777
|
const files = uploadable(args.files, sessionCwd(exec))
|
|
741
|
-
|
|
778
|
+
if (!selector && !el) {
|
|
779
|
+
// 没给目标:塞给本会话刚才点击时拦下的那个选文件框(带着点击回话里的 id 去,扩展核对)
|
|
780
|
+
const key = chooserKey(tabId)
|
|
781
|
+
const used = chooserIds.get(key)
|
|
782
|
+
let r
|
|
783
|
+
try { r = await call('upload', { tabId, files, chooserId: used }) } catch (e) { throw uploadError(e, true) }
|
|
784
|
+
if (!r || !r.chooser) throw new Error(t('err.uploadNeedsTarget'))
|
|
785
|
+
// 等回包时这个会话可能又点开了新框(存了新 id):只删这次用掉的
|
|
786
|
+
if (chooserIds.get(key) === used) chooserIds.delete(key)
|
|
787
|
+
return { text: `已把 ${r.files.length} 个文件交给页面刚才打开的选文件框` }
|
|
788
|
+
}
|
|
789
|
+
let r
|
|
790
|
+
try { r = await call('upload', { tabId, selector, files }) } catch (e) { throw uploadError(e) }
|
|
742
791
|
return { text: `已把 ${r.files.length} 个文件塞进 ${target}` }
|
|
743
792
|
}
|
|
744
793
|
case 'focus': {
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Chrome Bridge",
|
|
4
|
-
"description": "Lets DSH drive the Chrome you already use: real clicks and typing, a visible on-page cursor, your own logins."
|
|
4
|
+
"description": "Lets DSH drive the Chrome you already use: real clicks and typing, a visible on-page cursor, your own logins.",
|
|
5
|
+
"detail": "README.en.md"
|
|
5
6
|
}
|
|
6
7
|
}
|
package/locale/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-chrome-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "DSH plugin: native browser_* tools that drive the Chrome you are already using, over native messaging + CDP. No WebSocket, no port, no Connect button. The native host and the MV3 extension ship inside this package and are installed automatically on first load; the one step left is adding the DSH Bridge extension to Chrome, from the Chrome Web Store or as the bundled unpacked copy. Until then browser_* tools fail loudly with those exact steps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"client.js",
|
|
45
45
|
"locale",
|
|
46
46
|
"i18n",
|
|
47
|
+
"README.en.md",
|
|
47
48
|
"icon.svg",
|
|
48
49
|
"vendor",
|
|
49
50
|
"package.json"
|