@jaychang1989/dsh-webchat 0.5.1 → 0.5.2
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 +1 -0
- package/README.md +1 -0
- package/lib/client.js +32 -0
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -64,6 +64,7 @@ Click again to collapse the panel. The guest stays mounted while the panel is cl
|
|
|
64
64
|
| The center column says "载入失败:…" | The host refused the guest (the bridge threw). The text carries the host's reason |
|
|
65
65
|
| Clicking the entry opened a browser window instead | This renderer had no `dshDesktop.browser` (a plain web profile, for instance), so the fallback ran |
|
|
66
66
|
| It asks for a login again after a restart | See the limitations above — it is the host's partition behaviour |
|
|
67
|
+
| The page shows "Abnormal usage environment" | DeepSeek's front end checks `navigator.userAgent` for the string `electron` — which the desktop default carries — and then recommends its official product. Since 0.5.2 the guest presents a plain Chrome user agent and the dialog no longer appears |
|
|
67
68
|
|
|
68
69
|
## Development and tests
|
|
69
70
|
|
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ dsh plugin --profile desktop add github:jaychang1989/dsh-webchat
|
|
|
64
64
|
| 中栏提示「载入失败:…」 | 宿主拒绝了访客(桥接返回异常)。文本里带着宿主给的原因 |
|
|
65
65
|
| 点了入口却弹出一个浏览器窗口 | 说明当前渲染进程拿不到 `dshDesktop.browser`(例如在纯 web 环境),插件走了降级路径 |
|
|
66
66
|
| 重启后要求重新登录 | 见上面的「已知限制」,属于宿主分区机制 |
|
|
67
|
+
| 页面弹出「使用环境异常」 | DeepSeek 前端会检查 `navigator.userAgent` 里是否含 `electron`(桌面端默认 UA 就含),命中就提示"建议使用官方产品"。0.5.2 起访客改用普通 Chrome UA,不再触发 |
|
|
67
68
|
|
|
68
69
|
## 开发与测试
|
|
69
70
|
|
package/lib/client.js
CHANGED
|
@@ -107,6 +107,27 @@ window.__ModuleLoader__.load({
|
|
|
107
107
|
document.head.appendChild(tag)
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* A plain Chrome user agent for the guest, derived from this renderer's
|
|
112
|
+
* own so the Chrome major version stays truthful.
|
|
113
|
+
*
|
|
114
|
+
* chat.deepseek.com greets an `electron` token in the user agent with a
|
|
115
|
+
* "使用环境异常 / Abnormal usage environment" dialog, and its dismissal is
|
|
116
|
+
* stored per guest partition — which is process-lifetime here, so it
|
|
117
|
+
* would come back on every restart. Its check is literally
|
|
118
|
+
* `navigator.userAgent.toLowerCase().includes("electron")` (the other
|
|
119
|
+
* arm, `window.process.type`, cannot fire in a sandboxed, isolated
|
|
120
|
+
* guest), so not advertising Electron is what keeps the page clean.
|
|
121
|
+
* @returns a Chrome user agent, or '' when this renderer reports none.
|
|
122
|
+
*/
|
|
123
|
+
function cleanUserAgent() {
|
|
124
|
+
var ua = typeof navigator === 'object' && typeof navigator.userAgent === 'string' ? navigator.userAgent : ''
|
|
125
|
+
var platform = (ua.match(/^Mozilla\/5\.0 \([^)]*\)/) || [])[0]
|
|
126
|
+
var chrome = (ua.match(/Chrome\/([0-9]+)/) || [])[1]
|
|
127
|
+
if (platform === undefined || chrome === undefined) return ''
|
|
128
|
+
return platform + ' AppleWebKit/537.36 (KHTML, like Gecko) Chrome/' + chrome + '.0.0.0 Safari/537.36'
|
|
129
|
+
}
|
|
130
|
+
|
|
110
131
|
/** Show one transient message in the corner. */
|
|
111
132
|
function toast(text, state) {
|
|
112
133
|
var previous = document.querySelector('[' + TOAST_ATTR + ']')
|
|
@@ -302,7 +323,18 @@ window.__ModuleLoader__.load({
|
|
|
302
323
|
element.setAttribute('partition', reservation.partition)
|
|
303
324
|
element.setAttribute('allowpopups', '')
|
|
304
325
|
element.setAttribute('src', 'about:blank#' + reservation.lease)
|
|
326
|
+
const userAgent = cleanUserAgent()
|
|
327
|
+
if (userAgent !== '') element.setAttribute('useragent', userAgent)
|
|
305
328
|
element.addEventListener('dom-ready', function () {
|
|
329
|
+
// The guest exists by now, and nothing has been navigated
|
|
330
|
+
// yet, so this UA is the one the page actually loads with.
|
|
331
|
+
if (userAgent !== '') {
|
|
332
|
+
try {
|
|
333
|
+
element.setUserAgent(userAgent)
|
|
334
|
+
} catch (error) {
|
|
335
|
+
console.warn('[dsh-webchat] could not set the guest user agent:', error)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
306
338
|
element.loadURL(PAGE_URL).catch(function (error) {
|
|
307
339
|
toast(T.failed + ':' + (error instanceof Error ? error.message : String(error)), 'bad')
|
|
308
340
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaychang1989/dsh-webchat",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Opens the official DeepSeek web app (chat.deepseek.com) inside DeepSeek Harness: one sidebar entry renders the real page in the center column, through the same native browser guest the built-in side-card browser uses. No chat UI, no agent tools, no runtime dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|