dsh-chrome-bridge 1.17.0 → 1.18.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 ADDED
@@ -0,0 +1,30 @@
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
+ ## Update
17
+
18
+ Open it on the Plugins page and click "Update to …". A new version can be installed about a day after it is released.
19
+
20
+ ## Languages
21
+
22
+ - The extension panel in Chrome follows Chrome's language: English, Chinese or Russian.
23
+ - The settings card on the Plugins page follows DSH's language.
24
+ - 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).
25
+
26
+ ## Requirements
27
+
28
+ macOS, Windows or Linux, and Chrome 116 or newer.
29
+
30
+ Full guide: https://github.com/OrderG-X/dsh-chrome-bridge
package/README.md CHANGED
@@ -1,29 +1,32 @@
1
- # DSH Bridge · dsh-chrome-bridge
1
+ # Chrome 浏览器控制
2
2
 
3
- A DeepSeek Harness (DSH) plugin that drives the Chrome you already use: real clicks and typing, a visible on-page cursor, and your own logins. It provides 12 `browser_*` tools over native messaging and the Chrome debugger, with no listening port.
3
+ 让 DSH 直接操作你正在用的 Chrome:真点击、真输入,页面里看得到它的光标,你的登录状态都在。
4
4
 
5
- 让 DSH 直接操作你正在用的 Chrome:真点击、真输入,页面里看得到光标,登录状态都在。提供 12 个 `browser_*` 工具,走 native messaging 和 Chrome 调试接口,不开监听端口。
5
+ - 它新开的页放进一个单独的窗口,不往你正在用的窗口里塞,也不抢焦点。
6
+ - 它不会擅自去动你正在看的那一页。
7
+ - 随时能暂停:点 Chrome 工具栏上的 DSH Bridge 图标,关掉「允许 DSH 控制浏览器」。
6
8
 
7
- Pages the agent opens go into a separate background window of your Chrome, so your own window keeps its tabs and focus.
8
- agent 新开的页放进你 Chrome 里一个单独的后台窗口,你自己的窗口不多标签页、焦点不动。
9
+ ## 怎么装
9
10
 
10
- ## Install / 安装
11
+ 1. 在 DSH「插件」页点「添加插件」,填 `dsh-chrome-bridge`,然后重启 DSH。
12
+ 2. 从 [Chrome 应用商店](https://chromewebstore.google.com/detail/bippcbbbipppmhjkjomgdnjbooecbimo) 装上 DSH Bridge 扩展。
11
13
 
12
- 1. In DSH, open **Plugins**, click **Add plugin**, enter `dsh-chrome-bridge`, then restart DSH.
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
- Requirements: macOS, Windows or Linux, Chrome 116+, Node.js 18+.
18
- 系统要求:macOS、Windows 或 Linux,Chrome 116+,Node.js 18+。
16
+ ## 怎么更新
19
17
 
20
- ## Updating / 更新
18
+ 在「插件」页点开它,点「更新到 …」。新版发布后大约一天才装得到。
21
19
 
22
- On DSH 0.2.2 or later, open the plugin on the Plugins page and click "Update to …". On older DSH, uninstall it and add it again. A new version can be installed about a day after it is released, because the pnpm that DSH uses skips brand-new versions by default.
20
+ ## 语言
23
21
 
24
- DSH 0.2.2 起,在「插件」页点开它,点「更新到 …」;更老的 DSH 先卸载,再添加一次。DSH 用 pnpm 安装插件,而 pnpm 默认不装刚发布的版本,所以新版大约发布一天后才装得到。
22
+ - Chrome 里的扩展面板跟着 Chrome 的语言走:中文、英文、俄文。
23
+ - 插件页上的这张设置卡片跟着 DSH 的语言走。
24
+ - 想让模型看到的工具说明也换成英文或俄文,看[完整说明](https://github.com/OrderG-X/dsh-chrome-bridge/blob/main/README.zh.md)里「工具描述支持英文 / 俄文」那一节。
25
25
 
26
- Tool descriptions can be English or Russian: set `config.locale: en` (or `ru`) on the bundle in the profile's `cordis.patch.yml` and restart DSH.
27
- 工具描述可以是英文或俄文:在 profile 的 `cordis.patch.yml` 里给这个 bundle 加 `config.locale: en`(或 `ru`),然后重启 DSH。
26
+ ## 系统要求
28
27
 
29
- Full documentation / 完整说明:https://github.com/OrderG-X/dsh-chrome-bridge
28
+ macOS、Windows 或 Linux,Chrome 116 或更新。
29
+
30
+ 完整说明:https://github.com/OrderG-X/dsh-chrome-bridge
31
+
32
+ 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 的浏览器操作会被直接拒绝。重新打开要到 Chrome 工具栏的 DSH Bridge 面板里点 —— 这样模型自己没法把它打开。',
56
- resumeInChrome: '要恢复,请点 Chrome 工具栏上的 DSH Bridge 图标,打开「允许 DSH 控制浏览器」。',
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 里的扩展更新到 1.13 后才有这个开关;现在新页开在你当前窗口的后台。',
62
- outdated: 'Chrome 里的扩展版本较旧,更新后才能在这里切换开关。',
60
+ ownWindowHint: 'DSH 新开的页放进一个单独的 Chrome 窗口,登录状态照样在,不往你正在用的窗口里塞,也不抢焦点。关掉就开在你当前窗口的后台。',
61
+ ownWindowOld: 'Chrome 里的扩展更新后才有这个开关,现在新页开在你当前窗口的后台。',
62
+ outdated: 'Chrome 里的扩展版本旧了,更新后才能在这里改开关。',
63
63
  setupTitle: '还差一步:把扩展装进 Chrome',
64
- setupStoreTitle: '扩展装了,但没连上',
65
- setupStep1: '打开 Chrome,地址栏进入 chrome://extensions,右上角打开「开发者模式」',
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: '操作没成功:%e',
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 browser actions are refused. Turning it back on is done from the DSH Bridge panel in Chrome\'s toolbar, so the model cannot re-enable it itself.',
101
- resumeInChrome: 'To resume, click the DSH Bridge icon in Chrome\'s toolbar and turn on "Allow DSH to control the browser".',
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 (same profile, so your logins work) instead of piling tabs into the window you are using, and never take focus. Off: they open as background tabs in your current window.',
106
- ownWindowOld: 'This switch needs extension 1.13 or newer in Chrome; for now new pages open as background tabs in your current window.',
107
- outdated: 'The extension in Chrome is outdated; update it to change these switches here.',
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/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
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Chrome 浏览器控制",
4
- "description": "让 DSH 直接操作你正在用的 Chrome:真点击、真输入,页面里看得到光标,登录状态都在。"
4
+ "description": "让 DSH 直接操作你正在用的 Chrome:真点击、真输入,页面里看得到光标,登录状态都在。",
5
+ "detail": "README.md"
5
6
  }
6
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-chrome-bridge",
3
- "version": "1.17.0",
3
+ "version": "1.18.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"
@@ -0,0 +1,5 @@
1
+ {
2
+ "extDescription": {
3
+ "message": "Lets DSH work in the Chrome you already use: real clicks and typing, a cursor you can see, and your own logins."
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "extDescription": {
3
+ "message": "DSH работает в вашем Chrome: настоящие клики и ввод, видимый курсор и все ваши входы в аккаунты."
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "extDescription": {
3
+ "message": "让 DSH 直接操作你正在用的 Chrome:真点击、真输入,页面里看得到它的光标,你的登录状态都在。"
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "extDescription": {
3
+ "message": "讓 DSH 直接操作你正在用的 Chrome:真點擊、真輸入,頁面裡看得到它的游標,你的登入狀態都在。"
4
+ }
5
+ }
@@ -312,7 +312,21 @@ async function detachIdle() {
312
312
  // 用户在标签栏上一眼就能看出"agent 正在动哪几个页面",松手(空闲断开 / 显式 detach /
313
313
  // 关掉标签页 / 点掉 Chrome 那条调试提示)就自动还原,不留痕。
314
314
 
315
- const GROUP_TITLE = 'DSH agent 正在操作'
315
+ // 用户看得见的两处文字(标签组名、工具栏图标的悬停提示)跟 Chrome 的界面语言走:zh* 中文、ru* 俄文、其它英文。
316
+ // 认「我们的组」时几种语言的组名、以及老版本的「DSH agent 正在操作」都算,换了语言或升级后老组照样会被拆掉。
317
+ const UI_LANG = (() => {
318
+ let l = ''
319
+ try { l = String(chrome.i18n.getUILanguage() || '').toLowerCase() } catch {}
320
+ return l.startsWith('zh') ? 'zh' : l.startsWith('ru') ? 'ru' : 'en'
321
+ })()
322
+ const GROUP_TITLES = { zh: 'DSH 正在操作', en: 'DSH at work', ru: 'DSH работает' }
323
+ const GROUP_TITLE = GROUP_TITLES[UI_LANG]
324
+ const OUR_GROUP_TITLES = new Set([...Object.values(GROUP_TITLES), 'DSH agent 正在操作'])
325
+ const CURSOR_TAB_TITLE = {
326
+ zh: 'DSH 正在操作这个标签页(页面里有它的光标)',
327
+ en: 'DSH is working in this tab (its cursor is on the page)',
328
+ ru: 'DSH работает в этой вкладке (его курсор на странице)',
329
+ }[UI_LANG]
316
330
  const CURSOR_ICON = { 16: 'icons/cursor16.png', 32: 'icons/cursor32.png', 48: 'icons/cursor48.png' }
317
331
  // 标签页上的小鼠标:把页面 favicon 临时换成它(data URL,绕开页面 CSP 与 web_accessible_resources)
318
332
  const CURSOR_FAVICON = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAGUElEQVR4AbRWbWxUVRA9u9vutnQFFFNogZogIhFqqQnGEgiEEKIoJYoEP6pCTPhjoiJCGmKboBQqIWmAP5KYEKApWIRCoRSxlCpiUWIQGiiS8EMK/bBBoZZtl919z3Nudzfb7ZYQis297907M3fmzJl5t+vEwD8HRZK7wm/tNbl9+EOB4r26bt/unu/3+9dzllCZwikw/wuIeAAMlJ86fHha7bUOd6Hb7S60bdvX29srIG4CibenaGgj1qEyTO7urlhXexrYUmHjg1IbR38CPB7PGp/PJxAehtMZ2XI59CFnES90Os+TnJw8SwLL5tYGjvxoo+YUkJqauioQCJwA3kml3sVJAz6HOOIABJNJudNmYNuyYXHqXd1gYcXnFmpPu/Jse1d3uCQPhY1YAMzlrtOy4DAACAKcxADt9T500kJ1gx0pyXpg4ZAbNA4AMXDYisyoIQsICQSjkxloX1VvYVlREH+2p6yy7eo7YTYeuEETAlB8xgTjQ2tiMG+z1oaKDV+HUHXCirDxwA2aEACTZ7bkgSjUA+oFzcg6FJZ/ezyE/XXWkBo0IQBWgRk7wDhm2vwibHBPhW3zoTVl0gvE0k8DOFjvfKAGTQhAQZSloqv2eltsBjFg1owsRizWRG/ZVB4LovK7UKQk992ggwKgbw3AYubMWqBgsu7biwfpJAP1mpXHQijeFsTVG577btBBAPTV3woh2gvKNKjMiUTrCCNixQrLgmTpwpUQ1pbdxZ6jwQgbsQ1qcMc+EgKQgcUH/UKZMa6YpwTgPQHJojpKJZON5NBB9sieIyFU1ARjGtTcGQPiDRDQn7l4bDpSpkFGknNuYbLm3uhsEIxtZAYA2ZJ9hA29y6sDWLCiB3trkRcIHKijb92e/a7wxABoqWwUNPrmhrER3dMmAkxZU91fR71spSs/FMClq8681taOFylO4oyOxACYXWy9bdY2WmuiUKaqtxgxUzIzAQOK9uA0zNCXbJ592om0tGFzGFkAoiwkBGCQ01Lowc6HnHCCtbXCX4WRcW9kADZ+7MbGlW58yVm6ygPNTas92LTGg+M7hsHn6zk/YsSirfz/EQ3OY0gIQN+1UKvWkcyVmsmaKUpnkXPVWWxQJF/InuTEiJTWfY8Oa/tmlLd972Np7XtudZ4pPHPm10/S0uYtA3r/BQ4HjHH4kRAAmJkdyRz8M1kTOFnInqgjfWuxQC15B8oPB82ytbW1MStr+eZx45aWjh+/ZMPsWcVVeXnrDgDu68DPXTSSIT1xxSFvfPUfhgGbHc7UlK3pB9Z0ypMOfPFRMizJY/SyOd8cwoU/LOTm5hQAXe3AiGt9M/MGcLQDaLjFKH7OaHCuByuBVEyMpozFBTDlKSdKWGdpsrlWCQwDLIVkWu9it/Pn23PXr+9/AajpAWrvALt91Ctwv8wpMyMxA1SZeptvW/FtvPGyCy0tNypP/nCq+K1X2MiGAek4yY5YOXcphPOXLaSnp68G8pPphikImpncDhwJARhzHo0kp8xHpXVUZGUVlM2dU/z9hLG9TVPZcLIzDNEvsfIJ7KwKgL8rn29p+Wo+BUTK5z1GHACX7XTCnjLREa1zCWs+IbO3aezYxZsBfwvgbW1uvry9YGFfL+i/JgmAgKgXzl0K4nf2w+jRj68BlrgZOy4GJTEjTjks1Nx8ZftU1vjNBcnQt61svd7894EkNlbj30Do1vTpK+t1sWRPdsGwIIdhusTEjv19LACd+s3IT0YGiaczRkwX6f7c3A/r29v/2pk/x9/UdfPsaq/3tWWArxU4Fe7i2l4g0CWbdxclwVLqpCDEntBvRrDVfrvIh3EcUh/cNwBWfbcfSLuZkVFQ4vW+9PbMGYUHAR9pb7xJf9SZu5FJeu5kZCwuyyED0yYngQIYDVPIecaFbUWp6Ojo3AHcpYQn7zFiGZAZfdV0AyPbADe/40diMjchZEOnDfzERv4jFsrWejCN93zOZCe2FKUweAomPeFvGjPm9TLgEbIVPaezA2Y8ALIgEvfx263TtclA0NUpeeSw1uS4uysj49XNbW0d5Vs/S2XgVAbuvXi68ReWbd57QE8nUKfzso+cHfCOByADHWCWBrnWksVP6hsI0tWRmbm41OGYO9PhmD3b6120fOaMokNAEq/ds+qZAA8O5oMq4D8AAAD//zouHuEAAAAGSURBVAMAYX64YuQ3mpYAAAAASUVORK5CYII='
@@ -387,7 +401,7 @@ async function ensureGroup(tabId) {
387
401
  if (tab.groupId >= 0) {
388
402
  let g = null
389
403
  try { g = await chrome.tabGroups.get(tab.groupId) } catch {}
390
- if (!g || g.title !== GROUP_TITLE) return // 用户自己的组
404
+ if (!g || !OUR_GROUP_TITLES.has(g.title)) return // 用户自己的组
391
405
  groupedTabs.set(id, tab.groupId) // 本来就在我们的组里(worker 重启过之类)
392
406
  ourGroup.set(wid, tab.groupId)
393
407
  return
@@ -396,8 +410,8 @@ async function ensureGroup(tabId) {
396
410
  if (ourGroup.has(wid)) candidates.push(ourGroup.get(wid))
397
411
  try {
398
412
  // 只找本窗口的:按标题跨窗口复用,会把标签页拽到别的窗口去
399
- for (const g of await chrome.tabGroups.query({ title: GROUP_TITLE, windowId: wid })) {
400
- if (!candidates.includes(g.id)) candidates.push(g.id)
413
+ for (const g of await chrome.tabGroups.query({ windowId: wid })) {
414
+ if (OUR_GROUP_TITLES.has(g.title) && !candidates.includes(g.id)) candidates.push(g.id)
401
415
  }
402
416
  } catch {}
403
417
  for (const gid of candidates) {
@@ -443,11 +457,11 @@ async function unmarkTab(tabId) {
443
457
  * 自愈:service worker 会被 Chrome 随时挂起、扩展重载也会清掉内存里的分组表,
444
458
  * 但 Chrome 那边的组是持久的。所以启动时对一遍账:
445
459
  * · 还挂着调试会话的标签页 → 认领回分组表(继续归我们管)
446
- * · 已经没会话、却还留在「🖱 DSH agent」组里的 → 拆掉还原(别留孤儿组和残留角标)
460
+ * · 已经没会话、却还留在我们组里的(几种语言的组名、老版本的组名都算)→ 拆掉还原(别留孤儿组和残留角标)
447
461
  */
448
462
  async function reconcileGroups() {
449
463
  try {
450
- const groups = await chrome.tabGroups.query({ title: GROUP_TITLE })
464
+ const groups = (await chrome.tabGroups.query({})).filter((g) => OUR_GROUP_TITLES.has(g.title))
451
465
  if (!groups.length) return
452
466
  let attachedIds = new Set()
453
467
  try {
@@ -904,7 +918,7 @@ async function markCursor(tabId, on) {
904
918
  const id = Number(tabId)
905
919
  try {
906
920
  await chrome.action.setIcon({ tabId: id, path: on ? CURSOR_ICON : IDLE_ICON })
907
- await chrome.action.setTitle({ tabId: id, title: on ? 'DSH agent 正在操作这个标签页(页内有一只鼠标)' : '' })
921
+ await chrome.action.setTitle({ tabId: id, title: on ? CURSOR_TAB_TITLE : '' })
908
922
  } catch {}
909
923
  await setTabFavicon(id, on)
910
924
  }
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "DSH Bridge",
4
- "version": "1.13.2",
5
- "description": "DSH 原生浏览器控制桥:装一次永久可用,不需要点 Connect",
4
+ "version": "1.14.0",
5
+ "description": "__MSG_extDescription__",
6
+ "default_locale": "en",
6
7
  "minimum_chrome_version": "116",
7
8
  "icons": {
8
9
  "16": "icons/icon16.png",
@@ -205,7 +205,6 @@ code { font: 500 12.5px var(--mono); letter-spacing: -0.2px; }
205
205
  }
206
206
  .link { border: 0; background: none; padding: 0; color: var(--blue); font-size: 13px; font-weight: 500; cursor: pointer; }
207
207
  .link:active { opacity: 0.5; }
208
- .note { margin: 8px 16px 0; font-size: 12px; line-height: 1.45; color: var(--label-2); }
209
208
 
210
209
  .list { list-style: none; margin: 0; padding: 0; }
211
210
  .row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 9px 14px; }
@@ -222,6 +221,9 @@ code { font: 500 12.5px var(--mono); letter-spacing: -0.2px; }
222
221
  display: block; margin-top: 1px; font-size: 12px; color: var(--label-2);
223
222
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
224
223
  }
224
+ /* 开关下面那行小字:一句话说清关掉会怎样,长了就换行(俄文比中文长一截) */
225
+ .row-hint { display: block; margin-top: 2px; font-size: 12px; line-height: 1.35; color: var(--label-2); }
226
+ .toggle .row-title { white-space: normal; }
225
227
 
226
228
  /* 设置里那种彩色圆角方块图标 */
227
229
  .tile {
@@ -330,11 +332,12 @@ code { font: 500 12.5px var(--mono); letter-spacing: -0.2px; }
330
332
  /* ── 底部浮动按钮 ── */
331
333
 
332
334
  .dock { position: sticky; bottom: 0; z-index: 2; display: flex; gap: 10px; margin: 0 -14px; padding: 12px 14px 14px; }
333
- /* 内容滚到按钮后面时,后面那截先糊掉、再淡出 —— 按钮像浮在内容上 */
335
+ /* 内容滚到按钮后面时:底下垫一层背景色、上沿淡出 —— 按钮后面不再透出半张卡片,看着乱 */
334
336
  .dock::before {
335
- content: ""; position: absolute; inset: 0; z-index: -1;
337
+ content: ""; position: absolute; inset: -18px 0 0; z-index: -1;
338
+ background: linear-gradient(to top, var(--bg) 62%, color-mix(in srgb, var(--bg) 0%, transparent));
336
339
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
337
- -webkit-mask: linear-gradient(to top, #000 55%, transparent); mask: linear-gradient(to top, #000 55%, transparent);
340
+ -webkit-mask: linear-gradient(to top, #000 70%, transparent); mask: linear-gradient(to top, #000 70%, transparent);
338
341
  }
339
342
  .pill-btn {
340
343
  flex: 1; height: 42px; border-radius: 21px; border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
@@ -351,7 +354,7 @@ code { font: 500 12.5px var(--mono); letter-spacing: -0.2px; }
351
354
 
352
355
  .toast {
353
356
  position: fixed; left: 50%; bottom: 72px; z-index: 3; max-width: 330px; padding: 10px 16px; border-radius: 20px;
354
- font-size: 12.5px; font-weight: 500; color: var(--label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
357
+ font-size: 12.5px; font-weight: 500; color: var(--label); text-align: center; width: max-content;
355
358
  background: var(--toast); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
356
359
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22), inset 0 0 0 0.5px var(--sep);
357
360
  opacity: 0; transform: translate(-50%, 14px) scale(0.94); pointer-events: none;
@@ -15,17 +15,18 @@
15
15
  <div class="app-icon"><img src="icons/icon128.png" alt=""></div>
16
16
  <div class="brand">
17
17
  <div class="name">DSH Bridge</div>
18
- <div class="tagline">让 DSH 用你的 Chrome 干活</div>
18
+ <div class="tagline" data-i18n="tagline">让 DSH 用你的 Chrome 干活</div>
19
19
  </div>
20
20
  <span class="ver" id="ver"></span>
21
21
  </header>
22
22
 
23
- <!-- 状态卡:骨架固定,只改文字和 class —— 每秒整块重画会让呼吸灯、流动线的动画一直从头播 -->
23
+ <!-- 文字都在 popup.js 的 I18N 里按 Chrome 的界面语言换;这里的中文只是兜底。
24
+ 状态卡:骨架固定,只改文字和 class —— 每秒整块重画会让呼吸灯、流动线的动画一直从头播 -->
24
25
  <section id="status" class="card hero loading" aria-live="polite">
25
26
  <div class="hero-row">
26
27
  <span class="orb" id="orb"></span>
27
- <div class="hero-title"><span id="stTitle">正在检查…</span><small id="stSub"></small></div>
28
- <button class="icon-btn glassy" type="button" data-act="reconnect" title="重新连接本地宿主" aria-label="重新连接">
28
+ <div class="hero-title"><span id="stTitle" data-i18n="checking">正在检查…</span><small id="stSub"></small></div>
29
+ <button class="icon-btn glassy" type="button" data-act="reconnect" data-i18n-title="reconnect" title="重新连接" aria-label="重新连接">
29
30
  <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M13.2 8a5.2 5.2 0 1 1-1.5-3.7"/><path d="M13.2 2.6v3h-3"/></svg>
30
31
  </button>
31
32
  </div>
@@ -38,7 +39,7 @@
38
39
  <div class="wire" id="w1"></div>
39
40
  <div class="node" id="nHost">
40
41
  <div class="ring"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"><rect x="2.5" y="3" width="11" height="7.5" rx="1.6"/><path d="M6 13h4M8 10.5V13"/></svg></div>
41
- <b>本地宿主</b><small></small>
42
+ <b data-i18n="nodeHost">本机程序</b><small></small>
42
43
  </div>
43
44
  <div class="wire" id="w2"></div>
44
45
  <div class="node" id="nDsh">
@@ -52,29 +53,28 @@
52
53
  <div class="card list" id="settings">
53
54
  <label class="row toggle">
54
55
  <span class="tile green" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M8 2.2v5.2"/><path d="M4.6 4.4a5 5 0 1 0 6.8 0"/></svg></span>
55
- <span class="row-main"><span class="row-title">允许 DSH 控制浏览器</span></span>
56
+ <span class="row-main"><span class="row-title" data-i18n="pause">允许 DSH 控制浏览器</span><span class="row-hint" data-i18n="pauseHint">关掉后,DSH 碰不了浏览器</span></span>
56
57
  <input type="checkbox" role="switch" data-act="pause" checked>
57
58
  <span class="switch" aria-hidden="true"></span>
58
59
  </label>
59
60
  <label class="row toggle">
60
61
  <span class="tile blue" aria-hidden="true"><svg viewBox="0 0 24 24"><path fill="currentColor" d="M5 3.4v15.4c0 .75.9 1.12 1.42.58l3.6-3.76 2.9 5.94c.24.48.82.68 1.3.45l1.9-.92c.48-.23.68-.8.45-1.28l-2.88-5.9 5.2-.18c.77-.03 1.13-.97.56-1.5L6.64 2.7C6.08 2.18 5 2.6 5 3.4z"/></svg></span>
61
- <span class="row-main"><span class="row-title">页面里显示 DSH 光标</span></span>
62
+ <span class="row-main"><span class="row-title" data-i18n="cursor">页面里显示 DSH 光标</span><span class="row-hint" data-i18n="cursorHint">只管显示,关掉也照常操作</span></span>
62
63
  <input type="checkbox" role="switch" data-act="cursor" checked>
63
64
  <span class="switch" aria-hidden="true"></span>
64
65
  </label>
65
66
  <label class="row toggle">
66
67
  <span class="tile orange" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linejoin="round"><rect x="1.8" y="4.6" width="9.6" height="8.6" rx="1.6"/><path d="M4.6 4.6V3.4c0-.9.7-1.6 1.6-1.6h6.4c.9 0 1.6.7 1.6 1.6v5.6c0 .9-.7 1.6-1.6 1.6h-1.2"/></svg></span>
67
- <span class="row-main"><span class="row-title">新页开在单独窗口</span></span>
68
+ <span class="row-main"><span class="row-title" data-i18n="window">新页开在单独窗口</span><span class="row-hint" data-i18n="windowHint">关掉就开在你当前窗口的后台</span></span>
68
69
  <input type="checkbox" role="switch" data-act="window" checked>
69
70
  <span class="switch" aria-hidden="true"></span>
70
71
  </label>
71
72
  </div>
72
- <p class="note">关掉「控制」后,DSH 的浏览器调用会被直接拒绝。关掉「光标」只是不画,操作照做。关掉「单独窗口」,新页就开在你当前窗口的后台。</p>
73
73
  </section>
74
74
 
75
75
  <section class="block">
76
76
  <div class="block-head">
77
- <h2>活跃会话</h2>
77
+ <h2 data-i18n="sessions">正在用浏览器的对话</h2>
78
78
  <span class="count" id="sessCount">0</span>
79
79
  </div>
80
80
  <div id="sessions"></div>
@@ -82,8 +82,8 @@
82
82
 
83
83
  <section class="block">
84
84
  <div class="block-head">
85
- <h2>最近动作</h2>
86
- <button class="link" id="moreAct" type="button" hidden>全部</button>
85
+ <h2 data-i18n="activity">最近操作</h2>
86
+ <button class="link" id="moreAct" type="button" hidden></button>
87
87
  </div>
88
88
  <ol id="activity" class="card list activity"></ol>
89
89
  </section>
@@ -91,11 +91,11 @@
91
91
  <footer class="dock">
92
92
  <button id="releaseAll" class="pill-btn danger" type="button" data-act="releaseAll" disabled>
93
93
  <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"><circle cx="8" cy="8" r="6"/><path d="M5.9 5.9l4.2 4.2M10.1 5.9l-4.2 4.2"/></svg>
94
- 全部松手
94
+ <span data-i18n="releaseAll">全部放开</span>
95
95
  </button>
96
96
  <button id="copyDiag" class="pill-btn" type="button" data-act="diagnostics">
97
97
  <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"><rect x="5.5" y="5.5" width="8" height="8.5" rx="2"/><path d="M10.5 5.5V4a2 2 0 0 0-2-2H4.5a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h1"/></svg>
98
- 复制诊断信息
98
+ <span data-i18n="copyReport">复制问题报告</span>
99
99
  </button>
100
100
  </footer>
101
101
 
@@ -26,37 +26,327 @@ const ICON = {
26
26
  cursor: svg('<path fill="currentColor" d="M5 3.4v15.4c0 .75.9 1.12 1.42.58l3.6-3.76 2.9 5.94c.24.48.82.68 1.3.45l1.9-.92c.48-.23.68-.8.45-1.28l-2.88-5.9 5.2-.18c.77-.03 1.13-.97.56-1.5L6.64 2.7C6.08 2.18 5 2.6 5 3.4z"/>', '0 0 24 24', ''),
27
27
  }
28
28
 
29
- const TOOL = {
30
- browser_tabs: '标签页', browser_read: '读页面', browser_click: '点击', browser_input: '输入',
31
- browser_nav: '导航', browser_screenshot: '截图', browser_eval: '跑脚本', browser_wait: '等待',
32
- browser_dialog: '弹窗', browser_drag: '拖拽', browser_devtools: '调试',
29
+ // ── 文字:按 Chrome 的界面语言选 中 / 英 / 俄(zh* → 中文,ru* → 俄文,其它 → 英文)──────────
30
+ // 值是字符串(%n、%a 之类单个字母的占位符会被替换)或函数。三份的键要一致(scratch/test-ui-i18n.mjs 会查)。
31
+
32
+ const plural = {
33
+ zh: (n, w) => w,
34
+ en: (n, [one, many]) => (n === 1 ? one : many),
35
+ ru: (n, [one, few, many]) => {
36
+ const a = n % 10, b = n % 100
37
+ return a === 1 && b !== 11 ? one : a >= 2 && a <= 4 && (b < 12 || b > 14) ? few : many
38
+ },
33
39
  }
34
- const OP = {
35
- tabs: '列标签页', open: '开标签页', close: '关标签页', activate: '切标签页', text: '读文字', html: '读 HTML',
36
- attr: '读属性', info: '页面信息', eval: '跑脚本', click: '点击', clickEl: '点击', clickText: '点击',
37
- type: '打字', key: '按键', select: '选下拉', upload: '传文件', focus: '聚焦', hover: '悬停', scroll: '滚动',
38
- nav: '跳转', shot: '截图', waitFor: '等元素', dialog: '处理弹窗', console: '看控制台', network: '看网络',
39
- cursor: '光标', attach: '接管', detach: '松手', screencast: '录屏', userRelease: '你松手了',
40
- 'cdp:Input.dispatchMouseEvent': '鼠标', 'cdp:Page.captureScreenshot': '截图', 'cdp:Page.reload': '刷新',
41
- 'cdp:Page.navigateToHistoryEntry': '后退/前进', 'cdp:Network.getResponseBody': '看返回内容',
40
+
41
+ const I18N = {
42
+ zh: {
43
+ tagline: '让 DSH 用你的 Chrome 干活',
44
+ checking: '正在检查…',
45
+ reconnect: '重新连接',
46
+ nodeHost: '本机程序',
47
+ pause: '允许 DSH 控制浏览器',
48
+ pauseHint: '关掉后,DSH 碰不了浏览器',
49
+ cursor: '页面里显示 DSH 光标',
50
+ cursorHint: '只管显示,关掉也照常操作',
51
+ window: '新页开在单独窗口',
52
+ windowHint: '关掉就开在你当前窗口的后台',
53
+ sessions: '正在用浏览器的对话',
54
+ activity: '最近操作',
55
+ releaseAll: '全部放开',
56
+ copyReport: '复制问题报告',
57
+ extReady: '已就绪',
58
+ hostOk: '正常',
59
+ hostUp: '已运行 %t',
60
+ hostOff: '没连上',
61
+ hostNotReady: '没准备好',
62
+ hostLinked: '已连接',
63
+ dshUsed: '%a用过',
64
+ dshLinked: '已连上',
65
+ dshWait: '等它来用',
66
+ offTitle: '还没连上 DSH',
67
+ offSub: 'DSH 现在用不了浏览器',
68
+ offExplain: '先在 DSH 的「插件」页装上「Chrome 浏览器控制」,重启 DSH,再点右上角的 ↻(重新连接)。还不行,就在 DSH 里让它用一下浏览器,它会告诉你差哪一步。',
69
+ pausedTitle: '已暂停',
70
+ pausedSub: 'DSH 现在碰不了你的浏览器',
71
+ onTitle: '已连接',
72
+ onSub: '正在控制 %n 个标签页',
73
+ idleSub: '待命中,没在控制标签页',
74
+ noReply: '扩展没响应',
75
+ noReplySub: '到 chrome://extensions 里把 DSH Bridge 关掉再打开',
76
+ tabDialog: '被弹窗挡住了',
77
+ tabReleased: '已放开',
78
+ tabBusy: '操作中',
79
+ tabIdle: '空闲 · %t后自动放开',
80
+ tabIdleNow: '空闲 · 马上自动放开',
81
+ showTab: '切过去看看',
82
+ releaseTab: '放开:不再控制,标签页留着',
83
+ untitled: '(无标题)',
84
+ cli: '命令行工具',
85
+ unknown: '来源不明',
86
+ unknownMeta: '正被控制,但不知道是哪个对话',
87
+ conv: '对话 %i',
88
+ dshApp: 'DSH 桌面端',
89
+ ops: '%n 次操作',
90
+ fails: '%n 次失败',
91
+ tabsN: '%n 个标签页',
92
+ noTabs: '没在控制标签页',
93
+ emptyTitle: '还没有对话在用浏览器',
94
+ emptySub: '在 DSH 里让它操作浏览器,这里会实时显示它在动哪些标签页。',
95
+ showAll: '全部 %n',
96
+ collapse: '收起',
97
+ noActivity: '还没有操作',
98
+ failed: '失败',
99
+ reconnected: '已重新连接',
100
+ stillOff: '还是没连上',
101
+ released: '已放开,标签页还在',
102
+ releasedAll: '全部放开了',
103
+ copied: '问题报告已复制,可以直接发给开发者',
104
+ noReport: '拿不到问题报告',
105
+ copyFail: '复制失败,浏览器没给剪贴板权限',
106
+ pausedToast: '已暂停:DSH 碰不了浏览器了',
107
+ resumedToast: '已恢复:DSH 可以用浏览器了',
108
+ cursorOn: '页面里会显示 DSH 的光标',
109
+ cursorOff: '光标藏起来了,DSH 照常干活',
110
+ windowOn: 'DSH 新开的页会放进一个单独窗口',
111
+ windowOff: 'DSH 新开的页会开在你当前窗口的后台',
112
+ agoNow: '刚刚',
113
+ agoS: '%n 秒前', agoM: '%n 分钟前', agoH: '%n 小时前', agoD: '%n 天前',
114
+ spanS: '%n 秒', spanM: '%n 分钟', spanH: '%n 小时',
115
+ tool: {
116
+ browser_tabs: '标签页', browser_read: '读页面', browser_click: '点击', browser_input: '输入',
117
+ browser_nav: '跳转', browser_screenshot: '截图', browser_eval: '运行脚本', browser_wait: '等待',
118
+ browser_dialog: '弹窗', browser_drag: '拖拽', browser_devtools: '开发者工具', browser_download: '下载',
119
+ },
120
+ op: {
121
+ tabs: '列标签页', open: '开标签页', close: '关标签页', activate: '切标签页', text: '读文字', html: '读网页源码',
122
+ attr: '读属性', info: '页面信息', eval: '运行脚本', click: '点击', clickEl: '点击', clickText: '点击',
123
+ type: '打字', key: '按键', select: '选下拉', upload: '传文件', focus: '聚焦', hover: '悬停', scroll: '滚动',
124
+ nav: '跳转', shot: '截图', waitFor: '等元素', dialog: '处理弹窗', console: '看控制台', network: '看网络请求',
125
+ cursor: '光标', attach: '开始控制', detach: '放开', screencast: '录屏', userRelease: '你放开了',
126
+ 'cdp:Input.dispatchMouseEvent': '鼠标', 'cdp:Page.captureScreenshot': '截图', 'cdp:Page.reload': '刷新',
127
+ 'cdp:Page.navigateToHistoryEntry': '后退/前进', 'cdp:Network.getResponseBody': '看返回内容',
128
+ },
129
+ },
130
+ en: {
131
+ tagline: 'Lets DSH work in your Chrome',
132
+ checking: 'Checking…',
133
+ reconnect: 'Reconnect',
134
+ nodeHost: 'Local helper',
135
+ pause: 'Let DSH control the browser',
136
+ pauseHint: 'Off: DSH can\'t touch the browser',
137
+ cursor: 'Show the DSH cursor',
138
+ cursorHint: 'Off: just hidden; DSH keeps working',
139
+ window: 'New pages in a separate window',
140
+ windowHint: 'Off: background tabs in your current window',
141
+ sessions: 'Conversations using the browser',
142
+ activity: 'Recent actions',
143
+ releaseAll: 'Release all',
144
+ copyReport: 'Copy report',
145
+ extReady: 'Ready',
146
+ hostOk: 'Running',
147
+ hostUp: 'Up for %t',
148
+ hostOff: 'Not connected',
149
+ hostNotReady: 'Not ready',
150
+ hostLinked: 'Connected',
151
+ dshUsed: 'Used %a',
152
+ dshLinked: 'Linked',
153
+ dshWait: 'Waiting',
154
+ offTitle: 'Not connected to DSH',
155
+ offSub: 'DSH can\'t use the browser right now',
156
+ offExplain: 'Add "Chrome Bridge" on the Plugins page in DSH, restart DSH, then click ↻ (Reconnect) at the top right. Still stuck? Ask DSH to use the browser and it will tell you which step is missing.',
157
+ pausedTitle: 'Paused',
158
+ pausedSub: 'DSH can\'t touch your browser right now',
159
+ onTitle: 'Connected',
160
+ onSub: (v) => `Controlling ${v.n} ${plural.en(v.n, ['tab', 'tabs'])}`,
161
+ idleSub: 'Standing by, no tabs under control',
162
+ noReply: 'The extension isn\'t responding',
163
+ noReplySub: 'Turn DSH Bridge off and on again in chrome://extensions',
164
+ tabDialog: 'Blocked by a dialog',
165
+ tabReleased: 'Released',
166
+ tabBusy: 'Working',
167
+ tabIdle: 'Idle · auto-release in %t',
168
+ tabIdleNow: 'Idle · releasing now',
169
+ showTab: 'Show this tab',
170
+ releaseTab: 'Release: stop controlling it, keep the tab',
171
+ untitled: '(untitled)',
172
+ cli: 'Command-line tool',
173
+ unknown: 'Unknown source',
174
+ unknownMeta: 'Under control, but by which conversation is unknown',
175
+ conv: 'Conversation %i',
176
+ dshApp: 'DSH desktop',
177
+ ops: (v) => `${v.n} ${plural.en(v.n, ['action', 'actions'])}`,
178
+ fails: '%n failed',
179
+ tabsN: (v) => `${v.n} ${plural.en(v.n, ['tab', 'tabs'])}`,
180
+ noTabs: 'no tabs under control',
181
+ emptyTitle: 'No conversation is using the browser',
182
+ emptySub: 'Ask DSH to use the browser and you\'ll see here which tabs it is working in.',
183
+ showAll: 'All %n',
184
+ collapse: 'Less',
185
+ noActivity: 'Nothing yet',
186
+ failed: 'Failed',
187
+ reconnected: 'Reconnected',
188
+ stillOff: 'Still not connected',
189
+ released: 'Released; the tab stays open',
190
+ releasedAll: 'Released all tabs',
191
+ copied: 'Report copied; paste it into your bug report',
192
+ noReport: 'Couldn\'t build the report',
193
+ copyFail: 'Copy failed: no clipboard permission',
194
+ pausedToast: 'Paused: DSH can\'t touch the browser',
195
+ resumedToast: 'Resumed: DSH can use the browser',
196
+ cursorOn: 'The DSH cursor will show on pages',
197
+ cursorOff: 'Cursor hidden; DSH keeps working',
198
+ windowOn: 'New pages from DSH go into a separate window',
199
+ windowOff: 'New pages from DSH open as background tabs here',
200
+ agoNow: 'just now',
201
+ agoS: '%ns ago', agoM: '%n min ago', agoH: '%n h ago', agoD: '%n d ago',
202
+ spanS: '%ns', spanM: '%n min', spanH: '%n h',
203
+ tool: {
204
+ browser_tabs: 'Tabs', browser_read: 'Read page', browser_click: 'Click', browser_input: 'Type',
205
+ browser_nav: 'Navigate', browser_screenshot: 'Screenshot', browser_eval: 'Run script', browser_wait: 'Wait',
206
+ browser_dialog: 'Dialog', browser_drag: 'Drag', browser_devtools: 'DevTools', browser_download: 'Download',
207
+ },
208
+ op: {
209
+ tabs: 'List tabs', open: 'Open tab', close: 'Close tab', activate: 'Switch tab', text: 'Read text', html: 'Read HTML',
210
+ attr: 'Read attribute', info: 'Page info', eval: 'Run script', click: 'Click', clickEl: 'Click', clickText: 'Click',
211
+ type: 'Type', key: 'Key press', select: 'Select', upload: 'Upload', focus: 'Focus', hover: 'Hover', scroll: 'Scroll',
212
+ nav: 'Navigate', shot: 'Screenshot', waitFor: 'Wait for element', dialog: 'Handle dialog', console: 'Console', network: 'Network',
213
+ cursor: 'Cursor', attach: 'Take control', detach: 'Release', screencast: 'Record', userRelease: 'You released it',
214
+ 'cdp:Input.dispatchMouseEvent': 'Mouse', 'cdp:Page.captureScreenshot': 'Screenshot', 'cdp:Page.reload': 'Reload',
215
+ 'cdp:Page.navigateToHistoryEntry': 'Back/forward', 'cdp:Network.getResponseBody': 'Response body',
216
+ },
217
+ },
218
+ ru: {
219
+ tagline: 'DSH работает в вашем Chrome',
220
+ checking: 'Проверка…',
221
+ reconnect: 'Переподключить',
222
+ nodeHost: 'Помощник',
223
+ pause: 'Разрешить управлять браузером',
224
+ pauseHint: 'Выкл.: DSH не может трогать браузер',
225
+ cursor: 'Показывать курсор DSH',
226
+ cursorHint: 'Выкл.: курсор скрыт, работа идёт',
227
+ window: 'Новые страницы в отдельном окне',
228
+ windowHint: 'Выкл.: фоновые вкладки в текущем окне',
229
+ sessions: 'Диалоги, которые работают с браузером',
230
+ activity: 'Последние действия',
231
+ releaseAll: 'Отпустить все',
232
+ copyReport: 'Копировать отчёт',
233
+ extReady: 'Готово',
234
+ hostOk: 'Работает',
235
+ hostUp: 'Работает %t',
236
+ hostOff: 'Нет связи',
237
+ hostNotReady: 'Не готов',
238
+ hostLinked: 'Подключён',
239
+ dshUsed: '%a',
240
+ dshLinked: 'На связи',
241
+ dshWait: 'Ожидание',
242
+ offTitle: 'Нет связи с DSH',
243
+ offSub: 'Сейчас DSH не может работать с браузером',
244
+ offExplain: 'Добавьте «Chrome Bridge» на странице «Плагины» в DSH, перезапустите DSH и нажмите ↻ («Переподключить») справа вверху. Не помогло — попросите DSH открыть браузер, и он скажет, чего не хватает.',
245
+ pausedTitle: 'Пауза',
246
+ pausedSub: 'Сейчас DSH не может трогать ваш браузер',
247
+ onTitle: 'Подключено',
248
+ onSub: 'Вкладок под управлением: %n',
249
+ idleSub: 'Ожидание, вкладок под управлением нет',
250
+ noReply: 'Расширение не отвечает',
251
+ noReplySub: 'Выключите и снова включите DSH Bridge в chrome://extensions',
252
+ tabDialog: 'Мешает диалоговое окно',
253
+ tabReleased: 'Отпущена',
254
+ tabBusy: 'В работе',
255
+ tabIdle: 'Простой · отпустит через %t',
256
+ tabIdleNow: 'Простой · сейчас отпустит',
257
+ showTab: 'Показать вкладку',
258
+ releaseTab: 'Отпустить: перестать управлять, вкладка останется',
259
+ untitled: '(без названия)',
260
+ cli: 'Командная строка',
261
+ unknown: 'Источник неизвестен',
262
+ unknownMeta: 'Под управлением, но неизвестно, какого диалога',
263
+ conv: 'Диалог %i',
264
+ dshApp: 'DSH (приложение)',
265
+ ops: 'действий: %n',
266
+ fails: 'ошибок: %n',
267
+ tabsN: 'вкладок: %n',
268
+ noTabs: 'вкладок нет',
269
+ emptyTitle: 'Пока ни один диалог не работает с браузером',
270
+ emptySub: 'Попросите DSH поработать в браузере — здесь будет видно, какие вкладки он трогает.',
271
+ showAll: 'Все %n',
272
+ collapse: 'Свернуть',
273
+ noActivity: 'Пока ничего',
274
+ failed: 'Ошибка',
275
+ reconnected: 'Переподключено',
276
+ stillOff: 'Связи по-прежнему нет',
277
+ released: 'Отпущено, вкладка осталась',
278
+ releasedAll: 'Все вкладки отпущены',
279
+ copied: 'Отчёт скопирован — вставьте его в сообщение об ошибке',
280
+ noReport: 'Не удалось собрать отчёт',
281
+ copyFail: 'Не удалось скопировать: нет доступа к буферу обмена',
282
+ pausedToast: 'Пауза: DSH не может трогать браузер',
283
+ resumedToast: 'Возобновлено: DSH может работать с браузером',
284
+ cursorOn: 'Курсор DSH будет виден на страницах',
285
+ cursorOff: 'Курсор скрыт, DSH продолжает работу',
286
+ windowOn: 'Новые страницы DSH откроются в отдельном окне',
287
+ windowOff: 'Новые страницы DSH откроются фоном в текущем окне',
288
+ agoNow: 'только что',
289
+ agoS: '%n сек. назад', agoM: '%n мин. назад', agoH: '%n ч. назад', agoD: '%n дн. назад',
290
+ spanS: '%n сек.', spanM: '%n мин.', spanH: '%n ч.',
291
+ tool: {
292
+ browser_tabs: 'Вкладки', browser_read: 'Чтение', browser_click: 'Клик', browser_input: 'Ввод',
293
+ browser_nav: 'Переход', browser_screenshot: 'Скриншот', browser_eval: 'Скрипт', browser_wait: 'Ожидание',
294
+ browser_dialog: 'Диалог', browser_drag: 'Перетаскивание', browser_devtools: 'DevTools', browser_download: 'Загрузка',
295
+ },
296
+ op: {
297
+ tabs: 'Список вкладок', open: 'Открыть вкладку', close: 'Закрыть вкладку', activate: 'Переключить вкладку', text: 'Текст', html: 'HTML',
298
+ attr: 'Атрибут', info: 'Сведения', eval: 'Скрипт', click: 'Клик', clickEl: 'Клик', clickText: 'Клик',
299
+ type: 'Ввод', key: 'Клавиша', select: 'Выбор', upload: 'Файл', focus: 'Фокус', hover: 'Наведение', scroll: 'Прокрутка',
300
+ nav: 'Переход', shot: 'Скриншот', waitFor: 'Ожидание элемента', dialog: 'Диалог', console: 'Консоль', network: 'Сеть',
301
+ cursor: 'Курсор', attach: 'Начало управления', detach: 'Отпустить', screencast: 'Запись', userRelease: 'Вы отпустили',
302
+ 'cdp:Input.dispatchMouseEvent': 'Мышь', 'cdp:Page.captureScreenshot': 'Скриншот', 'cdp:Page.reload': 'Обновить',
303
+ 'cdp:Page.navigateToHistoryEntry': 'Назад/вперёд', 'cdp:Network.getResponseBody': 'Ответ сервера',
304
+ },
305
+ },
306
+ }
307
+
308
+ const LANG = (() => {
309
+ let l = ''
310
+ try { l = String(chrome.i18n.getUILanguage() || '') } catch {}
311
+ if (!l) l = navigator.language || ''
312
+ l = l.toLowerCase()
313
+ return l.startsWith('zh') ? 'zh' : l.startsWith('ru') ? 'ru' : 'en'
314
+ })()
315
+ const D = I18N[LANG]
316
+
317
+ /** 取文字:缺键回落中文;%x(单个字母)换成 vars.x —— 「%ns ago」里的 s 不算占位符 */
318
+ function T(key, vars = {}) {
319
+ const v = key in D ? D[key] : I18N.zh[key]
320
+ if (typeof v === 'function') return v(vars)
321
+ return String(v ?? key).replace(/%([a-z])/g, (m, k) => (k in vars ? String(vars[k]) : m))
322
+ }
323
+
324
+ /** 静态文字:popup.html 里带 data-i18n / data-i18n-title 的 */
325
+ function applyStatic() {
326
+ document.documentElement.lang = LANG === 'zh' ? 'zh-CN' : LANG
327
+ for (const el of document.querySelectorAll('[data-i18n]')) el.textContent = T(el.dataset.i18n)
328
+ for (const el of document.querySelectorAll('[data-i18n-title]')) {
329
+ el.title = T(el.dataset.i18nTitle)
330
+ el.setAttribute('aria-label', el.title)
331
+ }
42
332
  }
43
333
 
44
334
  const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c])
45
335
 
46
336
  function ago(ms, now) {
47
337
  const s = Math.max(0, Math.round((now - ms) / 1000))
48
- if (s < 5) return '刚刚'
49
- if (s < 60) return `${s} 秒前`
50
- if (s < 3600) return `${Math.floor(s / 60)} 分钟前`
51
- if (s < 86400) return `${Math.floor(s / 3600)} 小时前`
52
- return `${Math.floor(s / 86400)} 天前`
338
+ if (s < 5) return T('agoNow')
339
+ if (s < 60) return T('agoS', { n: s })
340
+ if (s < 3600) return T('agoM', { n: Math.floor(s / 60) })
341
+ if (s < 86400) return T('agoH', { n: Math.floor(s / 3600) })
342
+ return T('agoD', { n: Math.floor(s / 86400) })
53
343
  }
54
344
 
55
345
  function span(ms) {
56
346
  const s = Math.round(ms / 1000)
57
- if (s < 60) return `${s} 秒`
58
- if (s < 3600) return `${Math.floor(s / 60)} 分钟`
59
- return `${Math.floor(s / 3600)} 小时`
347
+ if (s < 60) return T('spanS', { n: s })
348
+ if (s < 3600) return T('spanM', { n: Math.floor(s / 60) })
349
+ return T('spanH', { n: Math.floor(s / 3600) })
60
350
  }
61
351
 
62
352
  const clock = (ms) => new Date(ms).toTimeString().slice(0, 8)
@@ -70,10 +360,8 @@ function host(url) {
70
360
  }
71
361
  }
72
362
 
73
- const shortId = (raw) => {
74
- const id = String(raw).replace(/^session-/, '')
75
- return id.length > 14 ? `${id.slice(0, 8)}…${id.slice(-4)}` : id
76
- }
363
+ /** 会话编号只留前 4 位(够分辨同时在跑的几个),全称放悬停提示里 */
364
+ const shortId = (raw) => String(raw).replace(/^session-/, '').slice(0, 4)
77
365
 
78
366
  /** 内容真变了才动 DOM:不打断悬停、按下、动画 */
79
367
  function setHTML(el, html) {
@@ -95,9 +383,10 @@ function renderStatus(st) {
95
383
  const dshRecent = h && h.lastClientAt && st.now - h.lastClientAt < 10 * 60e3
96
384
  const lastDsh = st.sessions.find((s) => s.kind === 'dsh')
97
385
 
98
- const hostSub = !st.connected ? '没连上' : h ? (h.socketOk ? `运行 ${span(st.now - h.startedAt)}` : 'socket 没开') : '已连接'
386
+ const hostSub = !st.connected ? T('hostOff') : h ? (h.socketOk ? T('hostOk') : T('hostNotReady')) : T('hostLinked')
387
+ const hostTip = h && h.socketOk && h.startedAt ? T('hostUp', { t: span(st.now - h.startedAt) }) : hostSub
99
388
  const hostCls = !st.connected || (h && !h.socketOk) ? 'off' : 'on'
100
- const dshSub = !st.connected ? '—' : lastDsh ? `${ago(lastDsh.last, st.now)}用过` : dshRecent ? '已连上' : '等它来调用'
389
+ const dshSub = !st.connected ? '—' : lastDsh ? T('dshUsed', { a: ago(lastDsh.last, st.now) }) : dshRecent ? T('dshLinked') : T('dshWait')
101
390
  const dshCls = !st.connected ? 'idle' : lastDsh || dshRecent ? 'on' : 'idle'
102
391
 
103
392
  const node = (id, cls, sub, tip = sub) => {
@@ -107,21 +396,21 @@ function renderStatus(st) {
107
396
  setText(small, sub)
108
397
  small.title = tip
109
398
  }
110
- node('nExt', 'on', `扩展 v${st.version}`)
111
- node('nHost', hostCls, hostSub, h ? `pid ${h.pid},已处理 ${h.served} 次请求\n${h.socket}` : hostSub)
399
+ node('nExt', 'on', T('extReady'), `DSH Bridge v${st.version}`)
400
+ node('nHost', hostCls, hostSub, hostTip)
112
401
  node('nDsh', dshCls, dshSub)
113
402
  setClass($('w1'), `wire ${st.connected ? 'on' : 'off'}`)
114
403
  setClass($('w2'), `wire ${hostCls === 'on' && dshCls === 'on' ? 'on' : ''}`)
115
404
 
116
405
  let mood, icon, title, sub, extra = ''
117
406
  if (!st.connected) {
118
- mood = 'bad'; icon = 'bang'; title = '没连上本地宿主'; sub = 'DSH 现在用不了浏览器'
119
- extra = `<p class="explain">多半是 DSH 里还没装浏览器桥插件,或者装好后还没重启 DSH。装好、重启 DSH 后点右上角重新连接;还连不上就在 DSH 里让它用一下浏览器,它会说卡在哪一步。</p>`
407
+ mood = 'bad'; icon = 'bang'; title = T('offTitle'); sub = T('offSub')
408
+ extra = `<p class="explain">${esc(T('offExplain'))}</p>`
120
409
  } else if (st.paused) {
121
- mood = 'warn'; icon = 'pause'; title = '已暂停'; sub = 'DSH 现在动不了你的浏览器'
410
+ mood = 'warn'; icon = 'pause'; title = T('pausedTitle'); sub = T('pausedSub')
122
411
  } else {
123
412
  const n = st.attachedCount
124
- mood = 'ok'; icon = 'check'; title = '已连接'; sub = n ? `正在控制 ${n} 个标签页` : '待命中,没有在控制标签页'
413
+ mood = 'ok'; icon = 'check'; title = T('onTitle'); sub = n ? T('onSub', { n }) : T('idleSub')
125
414
  }
126
415
  setClass($('status'), `card hero ${mood}`)
127
416
  setHTML($('orb'), ICON[icon])
@@ -144,11 +433,11 @@ function renderSettings(st) {
144
433
  // ── 会话 ────────────────────────────────────────────────────────────────────
145
434
 
146
435
  function tabState(t, st) {
147
- if (t.dialog) return `<span class="state warn">有 ${esc(t.dialog.type)} 弹窗挡着</span>`
148
- if (!t.attached) return '<span class="state gone">已松手</span>'
149
- if (t.busy || st.now - t.lastUsed < 2500) return '<span class="state busy">操作中</span>'
150
- const left = Math.max(0, Math.ceil((st.idleMs - (st.now - t.lastUsed)) / 1000))
151
- return `<span class="state idle">待命 · ${left > 0 ? `${left} 秒后自动松手` : '马上自动松手'}</span>`
436
+ if (t.dialog) return `<span class="state warn">${esc(T('tabDialog'))}</span>`
437
+ if (!t.attached) return `<span class="state gone">${esc(T('tabReleased'))}</span>`
438
+ if (t.busy || st.now - t.lastUsed < 2500) return `<span class="state busy">${esc(T('tabBusy'))}</span>`
439
+ const left = Math.max(0, st.idleMs - (st.now - t.lastUsed))
440
+ return `<span class="state idle">${esc(left >= 1000 ? T('tabIdle', { t: span(Math.ceil(left / 1000) * 1000) }) : T('tabIdleNow'))}</span>`
152
441
  }
153
442
 
154
443
  /** 加载失败过的 favicon:每秒重画时别再试一次(不然会一闪一闪) */
@@ -165,28 +454,27 @@ function tabRow(t, st) {
165
454
  return `<div class="row tab ${t.attached ? '' : 'released'}">
166
455
  ${favicon(t)}
167
456
  <span class="row-main">
168
- <span class="row-title" title="${esc(t.title)}">${esc(t.title || t.url || '(无标题)')}</span>
457
+ <span class="row-title" title="${esc(t.title)}">${esc(t.title || t.url || T('untitled'))}</span>
169
458
  <span class="row-sub">${esc(where)}${where ? ' · ' : ''}${tabState(t, st)}</span>
170
459
  </span>
171
460
  <span class="acts">
172
- <button class="icon-btn" type="button" data-act="focus" data-tab="${t.id}" title="切过去看看" aria-label="切到这个标签页">${ICON.open}</button>
173
- ${t.attached ? `<button class="icon-btn danger" type="button" data-act="release" data-tab="${t.id}" title="松手:断开调试,标签页留着" aria-label="松手">${ICON.release}</button>` : ''}
461
+ <button class="icon-btn" type="button" data-act="focus" data-tab="${t.id}" title="${esc(T('showTab'))}" aria-label="${esc(T('showTab'))}">${ICON.open}</button>
462
+ ${t.attached ? `<button class="icon-btn danger" type="button" data-act="release" data-tab="${t.id}" title="${esc(T('releaseTab'))}" aria-label="${esc(T('releaseTab'))}">${ICON.release}</button>` : ''}
174
463
  </span>
175
464
  </div>`
176
465
  }
177
466
 
178
467
  function who(s) {
179
- if (s.kind === 'cli') return { tile: '<span class="tile gray">' + ICON.term + '</span>', name: 'cb 命令行' }
180
- if (s.kind === 'other') return { tile: '<span class="tile orange">' + ICON.question + '</span>', name: '来源不明(旧版本宿主)' }
468
+ if (s.kind === 'cli') return { tile: '<span class="tile gray">' + ICON.term + '</span>', name: esc(T('cli')) }
469
+ if (s.kind === 'other') return { tile: '<span class="tile orange">' + ICON.question + '</span>', name: esc(T('unknown')) }
181
470
  return {
182
471
  tile: '<span class="tile blue">' + ICON.bubble + '</span>',
183
- name: s.session ? `会话 <code title="${esc(s.session)}">${esc(shortId(s.session))}</code>`
184
- : `DSH 桌面端${s.pid ? ` <code>pid ${s.pid}</code>` : ''}`,
472
+ name: s.session ? `<span title="${esc(s.session)}">${esc(T('conv', { i: shortId(s.session) }))}</span>` : esc(T('dshApp')),
185
473
  }
186
474
  }
187
475
 
188
- const meta = (s, st) => s.kind === 'other' ? '扩展知道它们在被控制,但不知道是谁'
189
- : `${ago(s.last, st.now)} · ${s.ops} 次操作${s.errors ? ` · <span class="err">${s.errors} 次失败</span>` : ''}`
476
+ const opsText = (s) => `${esc(T('ops', { n: s.ops }))}${s.errors ? ` · <span class="err">${esc(T('fails', { n: s.errors }))}</span>` : ''}`
477
+ const meta = (s, st) => s.kind === 'other' ? esc(T('unknownMeta')) : `${esc(ago(s.last, st.now))} · ${opsText(s)}`
190
478
 
191
479
  /** 半小时没动静、手上也没标签页的会话不占地方 */
192
480
  const STALE_MS = 30 * 60e3
@@ -200,8 +488,8 @@ function renderSessions(st) {
200
488
  if (!list.length) {
201
489
  setHTML($('sessions'), `<div class="card empty">
202
490
  <span class="tile blue">${ICON.cursor}</span>
203
- <b>还没有会话</b>
204
- <span>在 DSH 里让它操作浏览器,这里会实时显示它在动哪些标签页。</span>
491
+ <b>${esc(T('emptyTitle'))}</b>
492
+ <span>${esc(T('emptySub'))}</span>
205
493
  </div>`)
206
494
  return
207
495
  }
@@ -215,7 +503,7 @@ function renderSessions(st) {
215
503
  <div class="row sess-head">
216
504
  ${w.tile}
217
505
  <span class="row-main"><span class="row-title">${w.name}</span><span class="row-sub">${meta(s, st)}</span></span>
218
- <span class="cap ${live ? 'on' : ''}">${live} 个 Tab</span>
506
+ <span class="cap ${live ? 'on' : ''}">${esc(T('tabsN', { n: live }))}</span>
219
507
  </div>
220
508
  ${s.tabs.map((t) => tabRow(t, st)).join('')}
221
509
  </div>`
@@ -225,8 +513,8 @@ function renderSessions(st) {
225
513
  const w = who(s)
226
514
  return `<div class="row">
227
515
  ${w.tile}
228
- <span class="row-main"><span class="row-title">${w.name}</span><span class="row-sub">${s.ops} 次操作${s.errors ? ` · <span class="err">${s.errors} 次失败</span>` : ''} · 没在控制标签页</span></span>
229
- <span class="ago">${ago(s.last, st.now)}</span>
516
+ <span class="row-main"><span class="row-title">${w.name}</span><span class="row-sub">${opsText(s)} · ${esc(T('noTabs'))}</span></span>
517
+ <span class="ago">${esc(ago(s.last, st.now))}</span>
230
518
  </div>`
231
519
  }).join('')}</div>`)
232
520
  }
@@ -241,13 +529,13 @@ function renderActivity(st) {
241
529
  const all = st.activity
242
530
  const items = showAllActivity ? all : all.slice(0, 6)
243
531
  $('moreAct').hidden = all.length <= 6
244
- setText($('moreAct'), showAllActivity ? '收起' : `全部 ${all.length}`)
532
+ setText($('moreAct'), showAllActivity ? T('collapse') : T('showAll', { n: all.length }))
245
533
  if (!all.length) {
246
- setHTML($('activity'), '<li class="row act-empty">还没有动作</li>')
534
+ setHTML($('activity'), `<li class="row act-empty">${esc(T('noActivity'))}</li>`)
247
535
  return
248
536
  }
249
537
  setHTML($('activity'), items.map((a) => {
250
- const label = a.tool ? TOOL[a.tool] || a.tool : OP[a.op] || a.op
538
+ const label = a.tool ? D.tool[a.tool] || a.tool : D.op[a.op] || a.op
251
539
  const user = a.key === 'user'
252
540
  const ms = a.ms >= 1000 ? `${(a.ms / 1000).toFixed(1)}s` : `${a.ms}ms`
253
541
  const sub = [a.title, clock(a.at)].filter(Boolean).map(esc).join(' · ')
@@ -256,7 +544,7 @@ function renderActivity(st) {
256
544
  <span class="main"><b>${esc(label)}</b> <span class="hint">${esc(a.hint || '')}</span></span>
257
545
  <span class="ms">${user ? '' : ms}</span>
258
546
  <span class="sub">${sub}</span>
259
- ${a.ok ? '' : `<span class="why">${esc(a.error || '失败')}</span>`}
547
+ ${a.ok ? '' : `<span class="why">${esc(a.error || T('failed'))}</span>`}
260
548
  </li>`
261
549
  }).join(''))
262
550
  }
@@ -269,11 +557,13 @@ function render(st) {
269
557
  if (!st || st.error) {
270
558
  setClass($('status'), 'card hero bad')
271
559
  setHTML($('orb'), ICON.bang)
272
- setText($('stTitle'), '扩展后台没回话')
273
- setText($('stSub'), (st && st.error) || '去 chrome://extensions 重新加载一下 DSH Bridge')
560
+ setText($('stTitle'), T('noReply'))
561
+ setText($('stSub'), T('noReplySub'))
562
+ $('stSub').title = st && st.error ? String(st.error) : '' // 原始报错放悬停里,排查时有线索
274
563
  return
275
564
  }
276
565
  last = st
566
+ $('stSub').title = ''
277
567
  setText($('ver'), `v${st.version}`)
278
568
  renderStatus(st)
279
569
  renderSettings(st)
@@ -308,7 +598,7 @@ async function copy(text, done) {
308
598
  await navigator.clipboard.writeText(text)
309
599
  toast(done)
310
600
  } catch {
311
- toast('复制失败,浏览器没给剪贴板权限')
601
+ toast(T('copyFail'))
312
602
  }
313
603
  }
314
604
 
@@ -322,23 +612,23 @@ document.addEventListener('click', async (ev) => {
322
612
  btn.classList.add('spin')
323
613
  render(await ask('reconnect'))
324
614
  setTimeout(() => btn.classList.remove('spin'), 500)
325
- toast(last && last.connected ? '已重新连接' : '还是没连上')
615
+ toast(last && last.connected ? T('reconnected') : T('stillOff'))
326
616
  break
327
617
  case 'focus':
328
618
  render(await ask('focus', { tabId }))
329
619
  break
330
620
  case 'release':
331
621
  render(await ask('release', { tabId }))
332
- toast('已松手,标签页还在')
622
+ toast(T('released'))
333
623
  break
334
624
  case 'releaseAll':
335
625
  render(await ask('releaseAll'))
336
- toast('全部松手了')
626
+ toast(T('releasedAll'))
337
627
  break
338
628
  case 'diagnostics': {
339
629
  const r = await ask('diagnostics')
340
- if (r && r.text) copy(r.text, '诊断信息已复制,可以直接发给开发者')
341
- else toast('拿不到诊断信息')
630
+ if (r && r.text) copy(r.text, T('copied'))
631
+ else toast(T('noReport'))
342
632
  break
343
633
  }
344
634
  }
@@ -350,13 +640,13 @@ document.addEventListener('change', async (ev) => {
350
640
  if (input.dataset.act === 'pause') {
351
641
  const pause = !input.checked
352
642
  render(await ask('pause', { on: pause }))
353
- toast(pause ? '已暂停:DSH 动不了浏览器了' : '已恢复:DSH 可以用浏览器了')
643
+ toast(pause ? T('pausedToast') : T('resumedToast'))
354
644
  } else if (input.dataset.act === 'cursor') {
355
645
  render(await ask('cursor', { on: input.checked }))
356
- toast(input.checked ? '页面里会显示 DSH 的光标' : '光标藏起来了,DSH 照常干活')
646
+ toast(input.checked ? T('cursorOn') : T('cursorOff'))
357
647
  } else if (input.dataset.act === 'window') {
358
648
  render(await ask('window', { on: input.checked }))
359
- toast(input.checked ? 'DSH 新开的页会放进一个单独窗口' : 'DSH 新开的页会放在你当前窗口的后台')
649
+ toast(input.checked ? T('windowOn') : T('windowOff'))
360
650
  }
361
651
  })
362
652
 
@@ -375,6 +665,7 @@ $('moreAct').addEventListener('click', () => {
375
665
  if (last) renderActivity(last)
376
666
  })
377
667
 
668
+ applyStatic()
378
669
  tick()
379
670
  timer = setInterval(tick, 1000)
380
671
  addEventListener('unload', () => clearInterval(timer))