papersearch 0.7.0 → 0.7.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.
Files changed (96) hide show
  1. package/dist/capabilities/download/batch/batch.d.ts.map +1 -1
  2. package/dist/capabilities/download/batch/batch.js +12 -1
  3. package/dist/capabilities/download/batch/batch.js.map +1 -1
  4. package/dist/capabilities/download/batch/batchSummary.d.ts.map +1 -1
  5. package/dist/capabilities/download/batch/batchSummary.js +16 -7
  6. package/dist/capabilities/download/batch/batchSummary.js.map +1 -1
  7. package/dist/capabilities/download/batch/journalKey.d.ts +12 -0
  8. package/dist/capabilities/download/batch/journalKey.d.ts.map +1 -0
  9. package/dist/capabilities/download/batch/journalKey.js +30 -0
  10. package/dist/capabilities/download/batch/journalKey.js.map +1 -0
  11. package/dist/capabilities/download/content/pdf/DownloadTier.d.ts +4 -0
  12. package/dist/capabilities/download/content/pdf/DownloadTier.d.ts.map +1 -1
  13. package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.d.ts.map +1 -1
  14. package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.js +2 -0
  15. package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.js.map +1 -1
  16. package/dist/capabilities/download/content/pdf/school.js +2 -0
  17. package/dist/capabilities/download/content/pdf/school.js.map +1 -1
  18. package/dist/capabilities/download/types.d.ts +4 -0
  19. package/dist/capabilities/download/types.d.ts.map +1 -1
  20. package/dist/cli.js +32 -9
  21. package/dist/cli.js.map +1 -1
  22. package/dist/infrastructure/school/SchoolMcpClient.d.ts +4 -0
  23. package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -1
  24. package/dist/infrastructure/school/SchoolMcpClient.js +20 -1
  25. package/dist/infrastructure/school/SchoolMcpClient.js.map +1 -1
  26. package/dist/infrastructure/school/SchoolReadiness.d.ts +2 -0
  27. package/dist/infrastructure/school/SchoolReadiness.d.ts.map +1 -1
  28. package/dist/infrastructure/school/SchoolReadiness.js +3 -0
  29. package/dist/infrastructure/school/SchoolReadiness.js.map +1 -1
  30. package/dist/infrastructure/school/SchoolResultNormalizer.d.ts.map +1 -1
  31. package/dist/infrastructure/school/SchoolResultNormalizer.js +5 -0
  32. package/dist/infrastructure/school/SchoolResultNormalizer.js.map +1 -1
  33. package/dist/infrastructure/school/types.d.ts +12 -0
  34. package/dist/infrastructure/school/types.d.ts.map +1 -1
  35. package/dist/management/pro/activate.d.ts +36 -0
  36. package/dist/management/pro/activate.d.ts.map +1 -0
  37. package/dist/management/pro/activate.js +122 -0
  38. package/dist/management/pro/activate.js.map +1 -0
  39. package/dist/management/pro/install.d.ts +15 -0
  40. package/dist/management/pro/install.d.ts.map +1 -1
  41. package/dist/management/pro/install.js +39 -12
  42. package/dist/management/pro/install.js.map +1 -1
  43. package/dist/management/reports/index.d.ts +6 -0
  44. package/dist/management/reports/index.d.ts.map +1 -1
  45. package/dist/management/reports/index.js +6 -0
  46. package/dist/management/reports/index.js.map +1 -1
  47. package/dist/management/school/autoUpdate.d.ts.map +1 -1
  48. package/dist/management/school/autoUpdate.js +1 -0
  49. package/dist/management/school/autoUpdate.js.map +1 -1
  50. package/dist/management/school/cliProgress.d.ts.map +1 -1
  51. package/dist/management/school/cliProgress.js +1 -0
  52. package/dist/management/school/cliProgress.js.map +1 -1
  53. package/dist/management/school/settingsWindow.d.ts +1 -0
  54. package/dist/management/school/settingsWindow.d.ts.map +1 -1
  55. package/dist/management/school/settingsWindow.js +2 -0
  56. package/dist/management/school/settingsWindow.js.map +1 -1
  57. package/dist/management/updates/selfUpdate.d.ts +86 -0
  58. package/dist/management/updates/selfUpdate.d.ts.map +1 -0
  59. package/dist/management/updates/selfUpdate.js +194 -0
  60. package/dist/management/updates/selfUpdate.js.map +1 -0
  61. package/package.json +1 -1
  62. package/school/paper_search_school/adapters/annual_reviews/__init__.py +1 -0
  63. package/school/paper_search_school/adapters/ieee/__init__.py +1 -0
  64. package/school/paper_search_school/assets/capsule.html +1152 -206
  65. package/school/paper_search_school/assets/capsule_en.json +467 -19
  66. package/school/paper_search_school/assets/capsule_fr.json +1331 -0
  67. package/school/paper_search_school/assets/capsule_ja.json +1331 -0
  68. package/school/paper_search_school/assets/capsule_ko.json +1331 -0
  69. package/school/paper_search_school/assets/capsule_zh-Hant.json +2462 -0
  70. package/school/paper_search_school/browser/backend.py +15 -5
  71. package/school/paper_search_school/cli.py +15 -1
  72. package/school/paper_search_school/cold_start.py +70 -8
  73. package/school/paper_search_school/config.py +2 -0
  74. package/school/paper_search_school/download_diagnostics.py +4 -4
  75. package/school/paper_search_school/engine/batch_capture.py +37 -2
  76. package/school/paper_search_school/engine/batch_diagnostics.py +1 -1
  77. package/school/paper_search_school/engine/batch_institution.py +59 -0
  78. package/school/paper_search_school/engine/batch_login.py +117 -3
  79. package/school/paper_search_school/engine/batch_waits.py +42 -11
  80. package/school/paper_search_school/engine/bridge.py +11 -0
  81. package/school/paper_search_school/i18n.py +46 -22
  82. package/school/paper_search_school/orchestrator.py +60 -8
  83. package/school/paper_search_school/pro_status.py +54 -63
  84. package/school/paper_search_school/progress_capsule.py +349 -39
  85. package/school/paper_search_school/progress_reporter.py +51 -5
  86. package/school/paper_search_school/progress_view.py +3 -2
  87. package/school/paper_search_school/school_login.py +39 -2
  88. package/school/paper_search_school/school_switch.py +102 -0
  89. package/school/paper_search_school/school_test.py +335 -0
  90. package/school/paper_search_school/server.py +16 -0
  91. package/school/paper_search_school/updates.py +222 -0
  92. package/school/paper_search_school/user_settings.py +8 -3
  93. package/skills/paper-search/SKILL.md +1 -1
  94. package/skills/paper-search/references/browser-download.md +2 -2
  95. package/skills/paper-search/references/cli-contract.md +1 -1
  96. package/skills/paper-search/references/school-setup.md +1 -1
@@ -95,16 +95,28 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
95
95
  .head .title { font-weight: 600; font-size: 14px; }
96
96
  .head .sub { font-size: 12px; color: var(--dim); }
97
97
  /* The head's buttons close together (user, 2026-11-17): the pin's room comes from their gaps, not the text's. */
98
- .tools { display: flex; align-items: center; gap: 2px; margin-right: -3px; flex: none; }
99
- .tools .iconbtn { margin: 0; padding: 3px; }
98
+ .tools { display: flex; align-items: center; gap: 0; margin-right: -3px; flex: none; }
99
+ /* Each a 32 px target, drawn where it was (user, 2026-11-21: 最小化 was hard to hit): the margins take back what the
100
+ padding adds, the icons 24 px apart as before. */
101
+ .tools .iconbtn { margin: -4px; padding: 8px; }
100
102
  .iconbtn { background: none; border: none; padding: 4px; margin: -4px; border-radius: 6px; color: var(--dim); display: inline-flex; cursor: pointer; }
101
103
  .iconbtn:hover { background: var(--hover); color: var(--fg); }
102
104
  .paper { margin: 14px 0 12px; }
103
105
  .paper .name { line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
104
106
  .paper .where { color: var(--faint); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
105
- .paper .notice { color: var(--accent); font-size: 12px; margin-top: 3px; }
107
+ .paper .notice { color: var(--accent); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
106
108
  .paper-link { display: block; width: 100%; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: 6px; }
107
- .paper-link .name, .paper-link .where, .paper-link .notice { display: block; }
109
+ .paper-link .where, .paper-link .notice { display: block; }
110
+ /* The paper's block is one height whatever the paper (user, 2026-11-21: the card shook up and down as papers went by,
111
+ each change of height resizing the window, whose edge moves): the title two lines high even when one, the journal or
112
+ a notice one line, the step or the lane's line one row, each a fixed height. A title's symbols or another script, drawn
113
+ in a fallback font, made a line a pixel or two taller (Windows); the step's bar and the lane's line were not as tall
114
+ as each other. test_the_running_card_keeps_its_height_whatever_the_paper. */
115
+ .paper .name { height: 2.9em; }
116
+ .paper .where, .paper .notice { height: 1.45em; line-height: 1.45; }
117
+ .paper-status { display: flex; align-items: center; height: 18px; margin-top: 8px; overflow: hidden; }
118
+ .paper-status .steps { flex: 1; min-width: 0; margin-top: 0; }
119
+ .paper-status .line { flex: 1; min-width: 0; margin-top: 0; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
108
120
  .paper-link:hover .name { text-decoration: underline; }
109
121
  .paper-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
110
122
  .steps { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
@@ -219,17 +231,64 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
219
231
  .nav-sub { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
220
232
  .settings-note { font-size: 11px; color: var(--ok); margin-top: 8px; }
221
233
  .key-group { font-size: 11px; color: var(--faint); margin: 12px 0 2px; }
222
- .key-group.pro-group { margin-top: 16px; }
223
- /* The Markdown page (PaperSearch Pro): its tile and state, what it does, 安装 or its progress, where to report. */
224
- .pro-head { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
225
- .pro-tile { width: 34px; height: 34px; border-radius: 9px; flex: none; display: flex; align-items: center; justify-content: center;
226
- background: var(--accent); color: #fff; }
227
- .pro-tile svg.i { width: 18px; height: 18px; }
228
- .pro-name { display: flex; align-items: center; gap: 6px; font-weight: 600; }
234
+ /* The home page's last line (user, 2026-11-21): PaperSearch Pro, a blue link at its left; the language at its
235
+ right, one menu of the languages each in its own name. Installed, Pro's features are rows above, marked Pro. */
236
+ .settings .home-foot { gap: 12px; padding: 10px 0 0; }
237
+ /* 关于 PaperSearch (user, 2026-11-21): its icon and name centered, Pro's pill beside the name with the line a little to
238
+ the right (not the name alone centered: too far right), a wider space before Pro's part. */
239
+ .app-icon { display: block; flex: none; }
240
+ .about-hero { display: flex; flex-direction: column; align-items: center; margin-top: 12px; text-align: center; }
241
+ .about-name { font-size: 16px; font-weight: 600; margin-top: 8px; white-space: nowrap; }
242
+ .about-name.with-pill { transform: translateX(8px); }
243
+ .about-name .pro-pill { margin-left: 6px; vertical-align: 2px; }
244
+ .about-version { font-size: 12px; color: var(--dim); margin-top: 3px; }
245
+ .about-version.new, .about-version.bad { color: var(--bad); }
246
+ .about-action { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 14px; }
247
+ .about-action .btn.primary { width: 100%; justify-content: center; padding: 6px 10px; font-size: 13px; }
248
+ .about-action .btn.link { padding: 0; font-size: 12px; }
249
+ .about-action .pro-bar { width: 100%; }
250
+ .update-steps { align-self: stretch; }
251
+ .about-caption { text-align: center; font-size: 11px; color: var(--dim); margin-top: 6px; }
252
+ .about-gap { height: 18px; }
253
+ .about-sec { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; margin-top: 22px; padding-bottom: 8px;
254
+ border-bottom: 0.5px solid var(--line); }
255
+ .about-feat { padding: 6px 0; }
256
+ .about-feat b { font-weight: 600; font-size: 12px; }
257
+ .about-feat .pro-tag { display: inline-block; margin-left: 6px; vertical-align: 1px; }
258
+ .about-feat .pl-sub { display: block; font-size: 11.5px; color: var(--dim); line-height: 1.45; margin-top: 1px; }
259
+ .about-sub { font-size: 11px; color: var(--faint); margin: 12px 0 2px; }
260
+ .settings .pro-activate { margin-top: 14px; }
261
+ .version-link { display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding: 2px 0; border: none; background: none;
262
+ font: inherit; font-size: 12px; color: var(--dim); cursor: pointer; }
263
+ .version-link.new { color: var(--bad); font-weight: 600; }
264
+ .version-link .pl-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
265
+ .version-link:hover .pl-text { text-decoration: underline; }
266
+ .version-link svg.i { width: 14px; height: 14px; flex: none; }
267
+ .reopen-line { display: flex; align-items: center; gap: 8px; width: 100%; margin: 8px 0 0; padding: 7px 10px; border: none; border-radius: 8px;
268
+ background: rgba(22, 163, 74, 0.10); color: var(--ok); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
269
+ .reopen-line svg.i { width: 14px; height: 14px; flex: none; }
270
+ .reopen-line .k { margin-left: auto; font-weight: 600; white-space: nowrap; }
271
+ .iconbtn.has-dot { position: relative; }
272
+ .iconbtn.has-dot::after { content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
273
+ .tools .iconbtn.has-dot::after { top: 6px; right: 6px; }
274
+ .nav-row .app-icon { margin: 0 1px; }
275
+ .lang-btn { display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding: 2px 0; border: none;
276
+ background: none; font: inherit; font-size: 12px; cursor: pointer; }
277
+ .lang-btn svg.i { width: 14px; height: 14px; flex: none; }
278
+ .lang-wrap { position: relative; flex: none; }
279
+ .lang-btn { color: var(--dim); }
280
+ .lang-btn:hover, .lang-btn[aria-expanded="true"] { color: var(--fg); }
281
+ .lang-menu { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 5; min-width: 150px; box-sizing: border-box; padding: 4px;
282
+ background: var(--bg); border-radius: 10px; box-shadow: 0 0 0 0.5px var(--line), 0 6px 20px rgba(0, 0, 0, 0.14), 0 1px 3px rgba(0, 0, 0, 0.08); }
283
+ .lang-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 5px 8px;
284
+ border: none; border-radius: 6px; background: none; font: inherit; font-size: 12px; color: var(--fg); text-align: left; cursor: pointer; }
285
+ .lang-menu button:hover { background: var(--hover); }
286
+ .lang-menu button[aria-checked="true"] { color: var(--accent); }
287
+ .lang-menu button svg.i { width: 14px; height: 14px; }
288
+ .lang-more { margin: 4px 4px 0; padding: 5px 4px 2px; border-top: 0.5px solid var(--line); font-size: 11px; color: var(--faint); }
289
+ .nav-title .pro-pill.feature { margin-left: 6px; }
290
+ /* Pro's pill (蓝标) and its texts, on the home page, 关于 PaperSearch and Pro's feature pages. */
229
291
  .pro-pill { font-size: 10.5px; font-weight: 500; line-height: 1.5; color: var(--accent); background: var(--hover); border-radius: 999px; padding: 0 7px; }
230
- .pro-state { font-size: 12px; color: var(--dim); }
231
- .pro-state.ok { color: var(--ok); }
232
- .pro-state.bad { color: var(--bad); }
233
292
  .pro-desc { font-size: 12px; line-height: 1.55; color: var(--dim); margin-top: 10px; }
234
293
  .pro-action { margin-top: 12px; }
235
294
  .pro-action:empty { display: none; }
@@ -239,34 +298,143 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
239
298
  .pro-hint { font-size: 11px; color: var(--faint); text-align: center; margin-top: 6px; }
240
299
  .pro-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; padding-top: 10px;
241
300
  border-top: 0.5px solid var(--line); font-size: 12px; color: var(--dim); }
242
- .pro-foot .btn.link { padding-right: 0; gap: 2px; }
301
+ .pro-foot .btn.link { padding-right: 0; gap: 2px; white-space: nowrap; flex: none; }
243
302
  .pro-foot .btn.link svg.i { width: 13px; height: 13px; }
244
303
  /* What Pro keeps, its counts, its sites and whether it is free (user, 2026-11-19). */
245
304
  /* What a Markdown keeps, the counts, the sites and the usage, as drawn on 2026-11-19: taller than the
246
305
  other settings pages, which the user prefers to a crowded page (the window grows, as for API key). */
247
- .pro-check { margin-left: auto; padding-right: 0; font-size: 12px; }
248
306
  .pro-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
249
307
  .pro-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 9px 2px 7px; border-radius: 999px;
250
308
  border: 0.5px solid var(--line); color: var(--dim); }
251
309
  .pro-chip svg.i { width: 13px; height: 13px; }
310
+ /* What sets Pro's Markdown apart, a row that opens like the platforms' (user, 2026-11-21). */
311
+ .pro-merits { padding: 0 0 8px 26px; }
312
+ .pro-merit { display: flex; gap: 8px; padding: 6px 0; }
313
+ .pro-merit svg.i { width: 15px; height: 15px; margin-top: 1px; color: var(--dim); }
314
+ .pro-merit b { display: block; font-weight: 600; font-size: 12px; }
315
+ .pro-merit span { display: block; font-size: 11.5px; color: var(--dim); line-height: 1.45; margin-top: 1px; }
252
316
  .pro-stats { margin-top: 12px; }
253
- .pro-row.static { cursor: default; }
254
- .pro-sites { font-size: 12px; line-height: 1.6; color: var(--dim); padding: 0 0 8px 26px; }
317
+ /* Pro's page (user, 2026-11-21): what it does now and what is coming, each a line; the activation code. */
318
+ .pro-tag { flex: none; align-self: flex-start; font-size: 10.5px; line-height: 1.6; color: var(--dim); background: var(--hover);
319
+ border-radius: 4px; padding: 0 5px; }
320
+ .pro-activate { margin-top: 14px; padding-top: 12px; border-top: 0.5px solid var(--line); }
321
+ .pro-code-label { font-size: 11px; color: var(--dim); margin-bottom: 5px; }
322
+ .pro-code { display: flex; gap: 6px; }
323
+ .settings .pro-code input { flex: 1; min-width: 0; width: auto; height: 30px; text-align: left; background: var(--bg); padding: 0 8px;
324
+ font-size: 13px; letter-spacing: 0.04em; }
325
+ .pro-action .pro-code .btn.primary { width: auto; flex: none; padding: 5px 12px; }
326
+ .settings .pro-action .err { text-align: left; margin: 6px 0 0; }
327
+ .pro-needed { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 10px;
328
+ border-top: 0.5px solid var(--line); font-size: 12px; color: var(--dim); }
329
+ .pro-needed .btn.link { padding-right: 0; gap: 2px; white-space: nowrap; flex: none; }
330
+ .pro-needed .btn.link svg.i { width: 13px; height: 13px; }
331
+ .pro-use .ok { color: var(--ok); }
332
+ .pro-use .bad { color: var(--bad); }
333
+ .pro-sites { padding: 0 0 8px 26px; }
334
+ /* The platforms by kind, each site once (user, 2026-11-20: a list in groups, the multidisciplinary ones first). */
335
+ .site-group { font-size: 11px; color: var(--faint); margin: 6px 0 3px; }
336
+ .site-chips { display: flex; flex-wrap: wrap; gap: 4px; }
337
+ .site-chip { font-size: 11.5px; line-height: 1.6; padding: 0 7px; border-radius: 5px; border: 0.5px solid var(--line); color: var(--fg); }
255
338
  .key-row.editing { cursor: default; }
256
339
  .key-row.editing:hover .nav-title { color: inherit; }
257
340
  .key-set { font-size: 12px; color: var(--ok); white-space: nowrap; }
258
341
  .key-row .btn { pointer-events: none; }
259
342
  .key-edit { background: var(--hover); border-radius: 8px; padding: 8px 10px; margin: 0 0 6px; }
260
- /* The school sign-in page (PaperSearch Pro): each field under its name, room between them (user, 2026-11-19). */
261
- .login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
262
- .login-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--dim); }
263
- .settings .login-field input { width: 100%; box-sizing: border-box; text-align: left; background: var(--bg); padding: 7px 9px; font-size: 13px; }
264
- .login-pw { display: flex; align-items: center; gap: 6px; }
265
- .login-pw input { flex: 1; min-width: 0; }
266
- .login-pw .iconbtn { margin: 0; flex: none; }
267
- .login-form .key-note { margin: 0; }
343
+ /* The school sign-in page (PaperSearch Pro): the schools saved, one the default for downloads, each with its
344
+ account; the fields beside their names, close together (user, 2026-11-20). */
345
+ .login-school { border-bottom: 0.5px solid var(--line); }
346
+ .login-row { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 0; text-align: left; font-size: 13px;
347
+ border: none; background: none; color: inherit; font-family: inherit; cursor: pointer; }
348
+ .login-row:hover .ls-name { color: var(--accent); }
349
+ .login-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
350
+ .login-row .ls-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
351
+ .login-row .ls-n { flex: none; width: 12px; font-size: 11px; color: var(--faint); text-align: left; }
352
+ /* Under the schools, whose rows end in a line already: its own line below, none above (two showed, 2026-11-21). */
353
+ .settings .switch-row { border-top: none; border-bottom: 0.5px solid var(--line); }
354
+ .login-row .ls-acct { margin-left: auto; font-size: 11.5px; color: var(--dim); white-space: nowrap; }
355
+ .login-row svg.i { width: 13px; height: 13px; flex: none; color: var(--faint); }
356
+ .tag.fill { background: rgba(22, 163, 74, 0.12); color: var(--ok); }
357
+ .tag.trial { background: var(--hover); color: var(--accent); }
358
+ .tag.default { background: var(--accent); color: #fff; }
359
+ .tag.check { background: var(--warn-bg); color: var(--warn); }
360
+ .tag.none { background: var(--hover); color: var(--dim); }
361
+ .login-form { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; padding: 0 0 8px; font-size: 12px; color: var(--dim); }
362
+ .settings .login-form input { width: 100%; box-sizing: border-box; text-align: left; background: var(--bg); padding: 5px 8px; font-size: 13px; }
363
+ /* The eye inside the password's box, and the test article's line ending where the boxes end: the three rows' right
364
+ edges in line (user, 2026-11-21, 甲). */
365
+ .login-pw { position: relative; display: block; min-width: 0; }
366
+ .settings .login-pw input { padding-right: 30px; }
367
+ .login-pw .iconbtn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); margin: 0; }
368
+ .login-form .err, .login-form .key-actions { grid-column: 1 / -1; }
268
369
  .login-form .err { text-align: left; margin: 0; }
269
370
  .login-form .err:empty { display: none; }
371
+ .login-form .key-actions { margin-top: 2px; }
372
+ .login-form .key-actions .btn { white-space: nowrap; }
373
+ /* The less used ones under the buttons, the same for every school (user, 2026-11-20: rows of buttons that differed
374
+ from school to school, and wrapped). */
375
+ .login-links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; }
376
+ .login-links .link-btn { border: none; background: none; padding: 0; font: inherit; color: var(--dim); cursor: pointer; }
377
+ .login-links .link-btn:hover, .login-links .link-btn:focus-visible { color: var(--accent); }
378
+ .login-links .link-btn.danger:hover, .login-links .link-btn.danger:focus-visible, .login-links .link-btn.confirm { color: var(--bad); }
379
+ .login-links .sep { color: var(--dim); }
380
+ /* 测试登录 (user, 2026-11-21, as drawn): the article, then how the test went; while it runs, its steps in rows of their
381
+ own height and one line for what the download says, so that the page does not move as it goes. */
382
+ .login-form .test-result { grid-column: 1 / -1; }
383
+ .login-form .test-err { grid-column: 2; }
384
+ .test-article { display: flex; align-items: center; gap: 8px; min-width: 0; }
385
+ .test-article .what { flex: 1; min-width: 0; color: var(--fg); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
386
+ .test-article .what.empty { color: var(--dim); font-size: 11.5px; } /* none filled in: what to do */
387
+ .test-article .test-btn { padding: 3px 10px; flex: none; white-space: nowrap; }
388
+ .test-article .link-btn, .test-edit .link-btn { border: none; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; flex: none; }
389
+ /* The box holds the text and its button side by side: 查找中… is wider than 确定 and went over the text (user,
390
+ 2026-11-21); the text gives way to whatever the button says, in any language. */
391
+ .test-edit { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; height: 26px; box-sizing: border-box;
392
+ background: var(--bg); border: 0.5px solid var(--line); border-radius: 6px; padding: 0 8px; }
393
+ .test-edit:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
394
+ .settings .test-edit input { flex: 1; min-width: 0; width: auto; height: 24px; border: none; background: none; padding: 0;
395
+ text-align: left; font-size: 13px; }
396
+ .settings .test-edit input:focus { outline: none; }
397
+ .test-edit .link-btn { font-size: 12px; white-space: nowrap; }
398
+ .test-edit .link-btn:disabled { color: var(--dim); cursor: default; }
399
+ .test-result { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; }
400
+ .test-result svg.i { width: 15px; height: 15px; flex: none; margin-top: 1px; }
401
+ .test-result.ok { background: rgba(22, 163, 74, 0.10); } .test-result.ok svg.i { color: var(--ok); }
402
+ .test-result.bad { background: rgba(220, 38, 38, 0.08); } .test-result.bad svg.i { color: var(--bad); }
403
+ .test-result .t { color: var(--fg); font-weight: 600; } .test-result .d { margin-top: 2px; }
404
+ .login-test { padding: 2px 0 8px; font-size: 12px; color: var(--dim); }
405
+ .test-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
406
+ .test-steps li { display: flex; align-items: center; gap: 8px; height: 18px; color: var(--faint); }
407
+ .test-steps li svg.i { width: 15px; height: 15px; color: var(--ok); }
408
+ .test-steps li.done { color: var(--dim); }
409
+ .test-steps li.now { color: var(--fg); font-weight: 600; }
410
+ .test-steps .mark { width: 9px; height: 9px; margin: 0 3px; border-radius: 50%; border: 1.5px solid currentColor; box-sizing: border-box; }
411
+ .test-steps li.now .mark { background: var(--accent); border-color: var(--accent); }
412
+ .test-phase { height: 18px; line-height: 18px; margin: 6px 0 2px 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
413
+ .login-test .key-actions { margin-top: 6px; }
414
+ .login-add { padding: 0 0 10px; }
415
+ .login-add-row .ls-name { font-weight: 500; }
416
+ .login-add-row svg.i:first-child { color: var(--accent); }
417
+ .login-find { display: flex; gap: 6px; }
418
+ .settings .login-find input { flex: 1; min-width: 0; text-align: left; background: var(--bg); padding: 5px 8px; font-size: 13px; }
419
+ /* 支持的学校: a search field, its magnifier inside (user, 2026-11-21: the plain box looked out of place). */
420
+ .support-search { display: flex; align-items: center; gap: 6px; height: 32px; margin: 8px 0 6px; padding: 0 10px; box-sizing: border-box;
421
+ border: 0.5px solid var(--line); border-radius: 8px; background: var(--hover); color: var(--dim); }
422
+ .support-search:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
423
+ .settings .support-search input { flex: 1; min-width: 0; width: auto; height: 100%; padding: 0; border: none; background: none;
424
+ text-align: left; font-size: 13px; -webkit-appearance: none; appearance: none; }
425
+ .settings .support-search input:focus { outline: none; }
426
+ .login-found { display: flex; align-items: flex-start; gap: 6px; font-size: 12.5px; padding: 5px 0; border-bottom: 0.5px solid var(--line); }
427
+ /* A long name wraps, not cut (user, 2026-11-21); what is said of it stays at its top right. */
428
+ .login-found .ls-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
429
+ .login-found .tag, .login-found .btn { flex: none; }
430
+ .login-found .ls-fed { font-size: 11px; color: var(--faint); }
431
+ .login-found .btn { margin-left: auto; }
432
+ .login-add .login-found:last-child { border-bottom: none; }
433
+ .login-more { display: flex; justify-content: flex-end; margin-top: 8px; font-size: 12px; }
434
+ .login-more .btn.link { padding-right: 0; gap: 2px; }
435
+ .login-more .btn.link svg.i { width: 13px; height: 13px; }
436
+ .login-add .err { text-align: left; margin: 6px 0 0; }
437
+ .login-add .err:empty { display: none; }
270
438
  .settings .key-edit input { width: 100%; text-align: left; background: var(--bg); }
271
439
  .key-note { font-size: 11px; line-height: 1.5; color: var(--dim); margin-bottom: 8px; }
272
440
  .key-edit .err { text-align: left; margin: 6px 0 0; }
@@ -284,9 +452,6 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
284
452
  .strip .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
285
453
  .strip svg.i { width: 14px; height: 14px; }
286
454
  .strip.warn-strip { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
287
- .seg { display: inline-flex; border: 0.5px solid var(--line); border-radius: 7px; overflow: hidden; }
288
- .seg button { font: inherit; font-size: 12px; padding: 3px 10px; border: none; background: none; color: var(--dim); cursor: pointer; }
289
- .seg button.on { background: var(--accent); color: #fff; }
290
455
  .prompt { display: flex; align-items: center; gap: 10px; }
291
456
  .prompt svg.i { width: 22px; height: 22px; }
292
457
  .prompt .t { font-weight: 600; font-size: 14px; }
@@ -313,6 +478,17 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
313
478
  font: inherit; color: inherit; text-align: left; white-space: nowrap; cursor: pointer; }
314
479
  .grp .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
315
480
  .grp .row .reason { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
481
+ /* 支持的学校's head (back, title, the numbers, search) on top while its list scrolls (user, 2026-11-21). */
482
+ .support-top { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-bottom: 2px; }
483
+ #support-list .row { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 0; border: none;
484
+ border-bottom: 0.5px solid var(--line); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
485
+ #support-list .row:hover .reason { color: var(--accent); }
486
+ #support-list .row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }
487
+ #support-list .row .reason { flex: 1; min-width: 0; overflow-wrap: anywhere; }
488
+ #support-list .row .n { font-weight: 600; }
489
+ #support-list .row svg.i { width: 14px; height: 14px; color: var(--faint); }
490
+ .support-region > .row .reason { font-weight: 600; }
491
+ .support-countries { padding-left: 14px; }
316
492
  .grp .row .n { font-weight: 600; }
317
493
  .grp .row svg.i { width: 14px; height: 14px; color: var(--faint); }
318
494
  .grp .m { font-size: 12px; color: var(--faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@@ -340,42 +516,62 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
340
516
  <div id="root" class="pill capsule-drag-region"></div>
341
517
  <script>
342
518
  "use strict";
343
- // English: the window's progress_language. The table (assets/capsule_en.json) is put
344
- // in here when the window loads the page; every text shown passes through tr().
519
+ // The window's progress_language: Chinese (zh, simplified) is the page's
520
+ // own; English (assets/capsule_en.json) and Traditional Chinese (assets/capsule_zh-Hant.json, made from it by
521
+ // school/tools/zh_hant_table.py, user 2026-11-21) are put in here when the window loads the page; every text shown
522
+ // passes through tr().
523
+ // Japanese, Korean and French too (user, 2026-11-21: "中文、英文、日语、韩文,还有法语…都需要支持"): a text their table
524
+ // does not know is said in English, not left in Chinese.
345
525
  const EN = /*CAPSULE_EN*/null;
346
- const EN_PATTERNS = EN ? EN.patterns.map(([source, target]) => [new RegExp(source), target]) : [];
526
+ const HANT = /*CAPSULE_ZH_HANT*/null;
527
+ const JA = /*CAPSULE_JA*/null;
528
+ const KO = /*CAPSULE_KO*/null;
529
+ const FR = /*CAPSULE_FR*/null;
530
+ const TABLES = Object.fromEntries([["en", EN], ["zh-Hant", HANT], ["ja", JA], ["ko", KO], ["fr", FR]].filter(([, table]) => table)
531
+ .map(([code, table]) => [code, { ...table, patterns: table.patterns.map(([source, target]) => [new RegExp(source), target]) }]));
347
532
  const HAN = /[\u4e00-\u9fff]/;
348
533
  let lang = "zh";
534
+ // The languages that list with a comma, not 、 (Japanese keeps 、).
535
+ const commaLang = () => ["en", "ko", "fr"].includes(lang);
349
536
  const BRACKETS = /^(.+?)((.+))$/;
350
537
  const LISTED = /^([^:]+):(.+)$/;
351
- function trOne(core) {
538
+ function trOne(core, table = TABLES[lang]) {
352
539
  if (!HAN.test(core)) return core;
353
- let english = Object.hasOwn(EN.exact, core) ? EN.exact[core] : null;
354
- if (english === null) {
355
- const found = EN_PATTERNS.find(([pattern]) => pattern.test(core));
356
- if (found) english = core.replace(found[0], found[1]);
540
+ let said = Object.hasOwn(table.exact, core) ? table.exact[core] : null;
541
+ if (said === null) {
542
+ const found = table.patterns.find(([pattern]) => pattern.test(core));
543
+ // What the text names in it is said too where it is a text of the table ("更新学校订阅下载扩展出错"); a name keeps
544
+ // its words, in Traditional Chinese its characters ("没权限,换红木兰大学").
545
+ if (found) {
546
+ const parts = found[0].exec(core);
547
+ said = core.replace(found[0], found[1].replace(/\$(\d)/g, (_, i) => (HAN.test(parts[i] || "") ? trOne(parts[i], table) : parts[i] || "")));
548
+ }
357
549
  }
358
- const parts = english === null && BRACKETS.exec(core);
550
+ // Traditional Chinese: a text the table does not know, its characters (a name keeps its words).
551
+ if (said === null && table.chars) return core.replace(/[\u4e00-\u9fff]/g, (c) => table.chars[c] || c);
552
+ const parts = said === null && BRACKETS.exec(core);
359
553
  // "开放下载 18(出版社 API 3、预印本 1)": the text and what its brackets list, each on its own.
360
- if (parts) english = trOne(parts[1]) + " (" + parts[2].split("、").map(trOne).join(", ") + ")";
554
+ if (parts) said = trOne(parts[1], table) + " (" + parts[2].split("、").map((p) => trOne(p, table)).join(", ") + ")";
361
555
  // "不完整:参考文献少 1 条,少 1 张图": a known word, then what it lists, each on its own.
362
- const listed = english === null && LISTED.exec(core);
363
- if (listed && trOne(listed[1]) !== listed[1]) english = trOne(listed[1]) + ": " + listed[2].split(",").map(trOne).join(", ");
364
- return english === null ? core : english;
556
+ const listed = said === null && LISTED.exec(core);
557
+ if (listed && trOne(listed[1], table) !== listed[1]) said = trOne(listed[1], table) + ": " + listed[2].split(",").map((p) => trOne(p, table)).join(", ");
558
+ // Japanese, Korean, French: what their table does not know, in English rather than in Chinese.
559
+ if (said === null && table !== TABLES.en && TABLES.en) return trOne(core, TABLES.en);
560
+ return said === null ? core : said;
365
561
  }
366
562
  function tr(text) {
367
563
  // "PDF、Markdown": the kinds' names need no table, only their separator.
368
- if (lang === "en" && text && !HAN.test(text) && String(text).includes("、")) return String(text).replace(/、/g, ", ");
369
- if (lang !== "en" || !EN || !text || !HAN.test(text)) return text;
564
+ if (commaLang() && text && !HAN.test(text) && String(text).includes("、")) return String(text).replace(/、/g, ", ");
565
+ if (!TABLES[lang] || !text || !HAN.test(text)) return text;
370
566
  return String(text).split(" · ").map((part) => {
371
567
  const core = part.trim();
372
568
  if (!core || !HAN.test(core)) return part;
373
- const english = trOne(core);
374
- return english === core ? part : part.replace(core, english);
569
+ const said = trOne(core);
570
+ return said === core ? part : part.replace(core, said);
375
571
  }).join(" · ");
376
572
  }
377
573
  function localize(node) {
378
- if (lang !== "en" || !EN) return;
574
+ if (!TABLES[lang]) return;
379
575
  const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);
380
576
  for (let text = walker.nextNode(); text; text = walker.nextNode()) {
381
577
  const english = tr(text.nodeValue);
@@ -404,6 +600,13 @@ const ICONS = {
404
600
  left: '<path d="M15 6l-6 6 6 6"/>',
405
601
  right: '<path d="M9 6l6 6-6 6"/>',
406
602
  down: '<path d="M6 9l6 6 6-6"/>',
603
+ up: '<path d="M6 15l6-6 6 6"/>',
604
+ tick: '<path d="M5 12.5l4.5 4.5L19 7.5"/>',
605
+ // Two four-pointed stars: PaperSearch Pro's link (user, 2026-11-21).
606
+ upcircle: '<circle cx="12" cy="12" r="9"/><path d="M12 16V8M8.5 11.5L12 8l3.5 3.5"/>',
607
+ refresh: '<path d="M19.5 12a7.5 7.5 0 1 1-2.2-5.3"/><path d="M19.5 4.5v4h-4"/>',
608
+ sparkles: '<path d="M10 7a6 6 0 0 0 6 6a6 6 0 0 0 -6 6a6 6 0 0 0 -6 -6a6 6 0 0 0 6 -6z"/>'
609
+ + '<path d="M18.5 3a2.5 2.5 0 0 0 2.5 2.5a2.5 2.5 0 0 0 -2.5 2.5a2.5 2.5 0 0 0 -2.5 -2.5a2.5 2.5 0 0 0 2.5 -2.5z"/>',
407
610
  gear: gearPath(),
408
611
  clock: '<circle cx="12" cy="12" r="8.5"/><path d="M12 7.5V12l3 2"/>',
409
612
  key: '<circle cx="8" cy="15" r="4"/><path d="M10.8 12.2L19 4M16 7l2.5 2.5M14 9l2 2"/>',
@@ -414,7 +617,10 @@ const ICONS = {
414
617
  formula: '<path d="M17 5H7l5 7-5 7h10"/>',
415
618
  list: '<path d="M9.5 7h10.5M9.5 12h10.5M9.5 17h10.5"/><circle cx="5" cy="7" r="1"/><circle cx="5" cy="12" r="1"/><circle cx="5" cy="17" r="1"/>',
416
619
  gift: '<rect x="4" y="9" width="16" height="11" rx="1.5"/><path d="M3 9h18M12 9v11M12 9c-1.4-2.8-4.8-3.4-4.8-1.1 0 1.1 2.4 1.1 4.8 1.1zM12 9c1.4-2.8 4.8-3.4 4.8-1.1 0 1.1-2.4 1.1-4.8 1.1z"/>',
620
+ plus: '<path d="M12 5v14M5 12h14"/>',
417
621
  globe: '<circle cx="12" cy="12" r="8.5"/><path d="M3.5 12h17M12 3.5c2.4 2.4 3.5 5.4 3.5 8.5s-1.1 6.1-3.5 8.5c-2.4-2.4-3.5-5.4-3.5-8.5s1.1-6.1 3.5-8.5z"/>',
622
+ search: '<circle cx="11" cy="11" r="6.5"/><path d="M20 20l-4.2-4.2"/>',
623
+ link: '<path d="M10 14a4.5 4.5 0 0 0 6.4 0l3.2-3.2a4.5 4.5 0 0 0-6.4-6.4L12 5.6"/><path d="M14 10a4.5 4.5 0 0 0-6.4 0l-3.2 3.2a4.5 4.5 0 0 0 6.4 6.4l1.2-1.2"/>',
418
624
  external: '<path d="M14 5h5v5M19 5l-8 8"/><path d="M18 14v4a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 4 18V7a1.5 1.5 0 0 1 1.5-1.5H10"/>',
419
625
  };
420
626
  function gearPath() {
@@ -427,6 +633,27 @@ function gearPath() {
427
633
  return '<polygon points="' + pts.join(" ") + '"/><circle cx="12" cy="12" r="3"/>';
428
634
  }
429
635
  const icon = (name, extra) => '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"' + (extra || "") + ">" + ICONS[name] + "</svg>";
636
+ // PaperSearch's own icon (assets/icon.svg), and Pro's: the same paper and lens on a blue-violet turning to a soft rose
637
+ // gold, a light from its top left (user, 2026-11-21: 丙, elegant beside the plain one).
638
+ let appIconCount = 0;
639
+ function appIcon(size, pro) {
640
+ const id = "ai" + (++appIconCount);
641
+ const fill = pro ? '<linearGradient id="' + id + 'g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#6F78F2"/>'
642
+ + '<stop offset=".5" stop-color="#A67BD9"/><stop offset="1" stop-color="#E3AFC0"/></linearGradient>'
643
+ + '<radialGradient id="' + id + 's" cx=".28" cy=".2" r=".75"><stop offset="0" stop-color="#fff" stop-opacity=".3"/>'
644
+ + '<stop offset=".5" stop-color="#fff" stop-opacity=".05"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></radialGradient>'
645
+ : '<linearGradient id="' + id + 'g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#5B9BFF"/><stop offset="1" stop-color="#9A72FF"/></linearGradient>';
646
+ return '<svg class="app-icon' + (pro ? " pro" : "") + '" width="' + size + '" height="' + size + '" viewBox="0 0 512 512" aria-hidden="true"><defs>' + fill + "</defs>"
647
+ + '<rect x="32" y="32" width="448" height="448" rx="104" fill="url(#' + id + 'g)"/>'
648
+ + (pro ? '<rect x="32" y="32" width="448" height="448" rx="104" fill="url(#' + id + 's)"/>' : "")
649
+ + '<g transform="rotate(-8 220 240)"><rect x="112" y="100" width="206" height="270" rx="30" fill="#fff" opacity=".96"/>'
650
+ + '<rect x="148" y="148" width="116" height="18" rx="9" fill="#DCE3FF"/><rect x="148" y="192" width="134" height="18" rx="9" fill="#DCE3FF"/>'
651
+ + '<rect x="148" y="236" width="80" height="18" rx="9" fill="#DCE3FF"/></g><circle cx="306" cy="300" r="92" fill="#8C8BFF" opacity=".55"/>'
652
+ + '<circle cx="306" cy="300" r="92" fill="none" stroke="#fff" stroke-width="26"/>'
653
+ + '<line x1="374" y1="368" x2="424" y2="418" stroke="#fff" stroke-width="32" stroke-linecap="round"/>'
654
+ + '<path d="M306 248 Q306 300 358 300 Q306 300 306 352 Q306 300 254 300 Q306 300 306 248Z" fill="#fff"/>'
655
+ + '<path d="M352 236 Q352 252 368 252 Q352 252 352 268 Q352 252 336 252 Q352 252 352 236Z" fill="#fff" opacity=".9"/></svg>';
656
+ }
430
657
  const esc = (s) => String(s == null ? "" : s).replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c]));
431
658
  function ring(pct, size, stroke, label) {
432
659
  const r = (size - stroke) / 2, c = 2 * Math.PI * r, d = Math.max(0, Math.min(100, pct)) / 100 * c;
@@ -456,14 +683,15 @@ let settingsDraft = {};
456
683
  let notifyCheck = null; // the notification check under the switch: {state: testing, sent, off, unseen or failed}
457
684
  // Settings pages: "home" lists download, wait and keys. settingsOnly: this window was started
458
685
  // just to show them (`paper-search-school settings`), so it closes with them unless a download runs.
459
- const SETTINGS_PAGES = ["home", "download", "wait", "keys", "pro", "markdown", "login"];
686
+ const SETTINGS_PAGES = ["home", "about", "download", "wait", "keys", "pro", "markdown", "login"];
460
687
  // PaperSearch Pro's pages (config/edition.ts): Pro itself (installing it, its version and updates), and
461
688
  // each of its features (user, 2026-11-19: the Markdown, the school's sign-in, more to come).
462
689
  const PRO_PAGES = ["pro", "markdown", "login"];
463
- // Installed, Pro's features are on the home page (the user's choice, 2026-11-19: 铺开); not yet, on
464
- // Pro's own page, under 安装.
690
+ // Pro's features are on the home page, under its title, installed or not (user, 2026-11-19: 铺开; 2026-11-21: C).
465
691
  const proInstalled = () => !!(proStatus && proStatus.ok && proStatus.installed) && proInstall.state !== "running";
466
- const parentPage = (page) => ["markdown", "login"].includes(page) && !proInstalled() ? "pro" : "home";
692
+ const parentPage = (page) => page === "login_schools" ? "login" : page === "pro_activate" ? "about" : "home";
693
+ // Pro's page became 关于 PaperSearch (user, 2026-11-21: one version, Pro part of it); asked for by its old name too.
694
+ const pageNamed = (page) => page === "pro" ? "about" : page;
467
695
  // The Markdown page is one of PaperSearch Pro's features: the backend says whether this edition has it (edition.py).
468
696
  const proOn = () => !settings || settings.pro !== false;
469
697
  let settingsPage = "home", settingsNote = "", settingsOnly = false, lastStrip = "";
@@ -474,9 +702,95 @@ let apiKeys = null, editing = "", editValues = {}, confirmClear = "", revealed =
474
702
  let proStatus = null, proInstall = { state: "idle" }, proInstallTimer = 0;
475
703
  // The school sign-in page (school_login_state); its error line.
476
704
  let schoolLogin = null, loginError = "", loginValues = {}, loginShown = false;
705
+ // The school whose account is open on the page (its entityID), and 添加学校: what was typed, what was found.
706
+ let loginOpen = "", schoolQuery = "", schoolFound = null, schoolFinding = false, confirmForget = "", loginAdding = false;
707
+ // 测试登录 (school_test.py): the test as the window runs it ({state: idle, running (key, step, phase), done (key, ok,
708
+ // title, detail, seconds)}); the article it opens for the school open ({doi}: "" while none is set), and its box: open
709
+ // or not, what is typed, why it was not taken, a lookup going on; the account as saved (the test uses that: changed
710
+ // fields are saved first).
711
+ // One version and one update (user, 2026-11-21; updates.py): the version this window runs and the one installed now
712
+ // (an update elsewhere: they differ, 重新打开), the check's answer, the update as it goes.
713
+ let versionInfo = { running: "", installed: "" }, versionCheck = { state: "idle" }, updateRun = { state: "idle" };
714
+ let versionTimer = 0, updateTimer = 0;
715
+ const newerVersion = () => versionCheck.state === "done" && !!(versionCheck.update || versionCheck.pro_update) && updateRun.state !== "done";
716
+ async function refreshVersions() {
717
+ try { versionInfo = (await api().versions()) || versionInfo; } catch (error) { /* an older backend: none */ }
718
+ }
719
+ async function checkVersions(again = false) {
720
+ await refreshVersions();
721
+ try { versionCheck = (await api().check_versions(again)) || { state: "idle" }; } catch (error) { return; }
722
+ watchVersions();
723
+ if (panel === "settings") render(true);
724
+ }
725
+ function watchVersions() {
726
+ clearInterval(versionTimer);
727
+ if (versionCheck.state !== "running") return;
728
+ versionTimer = setInterval(async () => {
729
+ let next;
730
+ try { next = await api().versions_state(); } catch (error) { return; }
731
+ versionCheck = next || { state: "idle" };
732
+ if (versionCheck.state === "running") return;
733
+ clearInterval(versionTimer);
734
+ render(true); // the card's dot, the foot's line, the about page
735
+ }, 700);
736
+ }
737
+ // 更新 as it goes: each step, then (PaperSearch itself updated) the window opening again with the new one.
738
+ function watchUpdate() {
739
+ clearInterval(updateTimer);
740
+ if (updateRun.state !== "running") return;
741
+ updateTimer = setInterval(async () => {
742
+ let next;
743
+ try { next = await api().update_state(); } catch (error) { return; }
744
+ const before = JSON.stringify(updateRun);
745
+ updateRun = next || { state: "idle" };
746
+ if (updateRun.state !== "running") {
747
+ clearInterval(updateTimer);
748
+ if (updateRun.state === "done" && updateRun.reopen) {
749
+ render(true);
750
+ try { await api().reopen_window("about"); } catch (error) { /* the window stays; 重新打开 says the rest */ }
751
+ return;
752
+ }
753
+ if (updateRun.state === "done") {
754
+ // Pro alone updated: read again, the page as it is now.
755
+ try { proStatus = await api().pro_status(); } catch (error) { /* as it was */ }
756
+ updateRun = { state: "idle" };
757
+ await checkVersions(true);
758
+ }
759
+ }
760
+ if (JSON.stringify(updateRun) !== before && panel === "settings") render(true);
761
+ }, 600);
762
+ }
763
+ // Installed elsewhere since this window started (a terminal, an AI tool): said on every settings page, 重新打开.
764
+ const reopenLine = () => versionInfo.installed && versionInfo.running && versionInfo.installed !== versionInfo.running
765
+ && updateRun.state === "idle" ? '<button type="button" class="reopen-line" data-act="reopen_window">' + icon("refresh")
766
+ + "<span>" + esc("已更新到 " + versionInfo.installed) + '</span><span class="k">' + esc("重新打开") + "</span></button>" : "";
767
+ let schoolTest = { state: "idle" }, testArticle = null, testArticleFor = null, testTimer = 0, loginSavedValues = {};
768
+ let testEditing = false, testArticleText = "", testArticleError = "", testArticleSaving = false;
769
+ // 支持哪些学校: the list Pro gives, what is typed to narrow it, the regions open, the country whose page is open, its
770
+ // parts open, and where the regions' page was scrolled to, for going back to it.
771
+ let supportList = null, supportFilter = "", supportOpen = "", supportRegions = new Set(), supportParts = new Set(), supportBack = 0;
772
+ // Where the page was scrolled, put back once it is drawn again (user, 2026-11-21: a press on the card's background
773
+ // sent 支持的学校's long list to its top); where a page gone to or back to is to be (pageScroll, its top: 0).
774
+ let keepScroll = null, pageScroll = null;
775
+ const surfaceTop = () => root.querySelector(":scope > .surface")?.scrollTop || 0;
776
+ // What scrolls a row: the nearest box that scrolls its content, else the page.
777
+ function scrollerOf(el) {
778
+ for (let node = el.parentElement; node; node = node.parentElement) {
779
+ if (/(auto|scroll)/.test(getComputedStyle(node).overflowY) && node.scrollHeight > node.clientHeight) return node;
780
+ }
781
+ return document.scrollingElement || document.documentElement;
782
+ }
477
783
  // What the last 保存, 清除 or switch did, said under the fields (user, 2026-11-19: 保存 said nothing).
478
784
  let loginDone = "";
479
- let proCheck = { state: "idle" }, proCheckTimer = 0, proSitesOpen = false;
785
+ // The Save button saying "已保存" a moment once pressed (user, 2026-11-20: not a line below).
786
+ let loginSaved = false, loginSavedTimer = 0;
787
+ let proSitesOpen = false, proMeritsOpen = false;
788
+ // The activation code typed on Pro's page, and why it was not sent (none typed).
789
+ let proCode = "", proCodeError = "";
790
+ // The languages the window speaks, each in its own name, in one menu at the home page's foot (user, 2026-11-21:
791
+ // more to come, 日本語, 한국어, Français among them); whether that menu is open.
792
+ const LANGUAGES = [["zh", "简体中文"], ["zh-Hant", "繁體中文"], ["en", "English"], ["ja", "日本語"], ["ko", "한국어"], ["fr", "Français"]];
793
+ let languageOpen = false;
480
794
  let lastHtml = "", hoverTimer = 0, leaveTimer = 0, pollTimer = 0, kinds = [];
481
795
  const api = () => window.pywebview.api;
482
796
 
@@ -522,7 +836,7 @@ function header(title, sub, closable) {
522
836
  + (V.mode === "running" || V.mode === "attention" ? ring(V.pct, 40, 4, V.pct + "%") : "")
523
837
  + '<div class="text"><div class="title">' + esc(title) + '</div>' + (sub ? '<div class="sub">' + esc(sub) + "</div>" : "") + "</div></div>"
524
838
  + '<div class="tools">' + pinButton()
525
- + '<button class="iconbtn" data-act="settings" aria-label="设置">' + icon("gear") + "</button>"
839
+ + '<button class="iconbtn' + (newerVersion() ? " has-dot" : "") + '" data-act="settings" aria-label="设置">' + icon("gear") + "</button>"
526
840
  + '<button class="iconbtn" data-act="' + (closable ? "close" : "minimize") + '" aria-label="' + (closable ? "关闭" : "最小化")
527
841
  + '" title="' + (closable ? "关闭" : "最小化到程序坞") + '">' + icon(closable ? "close" : "minimize") + "</button></div></div>";
528
842
  }
@@ -538,13 +852,17 @@ function paperBlock() {
538
852
  html += note ? "<" + tag + ' class="notice">' + esc(note) + "</" + tag + ">"
539
853
  : (v.where ? "<" + tag + ' class="where">' + esc(v.where) + (v.title && v.current ? " · " + esc(v.current) : "") + "</" + tag + ">" : "");
540
854
  if (v.browser) html += "</button>";
855
+ // The step or the lane's line in one row of its own height, there when neither is (see .paper-status); a line
856
+ // longer than the row says the rest on hover.
857
+ html += '<div class="paper-status">';
541
858
  if (v.step) {
542
859
  html += '<div class="steps"><div class="bars">' + v.steps.map((_, i) =>
543
860
  "<span" + (i < v.step.index ? ' class="done"' : i === v.step.index ? ' class="now"' : "") + "></span>").join("")
544
861
  + '</div><span class="label">' + esc(v.step.label) + "</span></div>";
545
862
  } else if (v.line) {
546
- html += '<div class="line">' + esc(v.line) + "</div>";
863
+ html += '<div class="line" title="' + esc(v.line) + '">' + esc(v.line) + "</div>";
547
864
  }
865
+ html += "</div>";
548
866
  // What each lane got (开放下载, 机构下载), on one line.
549
867
  return html + "</div>";
550
868
  }
@@ -599,11 +917,11 @@ function heldBlock() {
599
917
  // The button says 已确认; the line, when they go on.
600
918
  const copy = V.held_wait ? "正在继续下载 " + heldCount() + " 篇" : "本篇完成后继续下载 " + heldCount() + " 篇";
601
919
  return '<div class="held"><div class="head"><span class="copy">' + esc(copy) + '</span><span class="btn done">' + icon("check") + "已确认</span></div>"
602
- + '<div class="names">' + esc(held.map((h) => h.name).join(lang === "en" ? ", " : "、")) + "</div></div>";
920
+ + '<div class="names">' + esc(held.map((h) => h.name).join(commaLang() ? ", " : "、")) + "</div></div>";
603
921
  }
604
922
  return '<div class="held"><div class="head"><span class="copy">' + esc("学校登录中途失败,已暂停 " + heldCount() + " 篇")
605
923
  + '</span><button class="btn" data-act="resume_held">登录并继续</button></div>'
606
- + '<div class="names">' + esc(held.map((h) => h.name).join(lang === "en" ? ", " : "、")) + "</div></div>";
924
+ + '<div class="names">' + esc(held.map((h) => h.name).join(commaLang() ? ", " : "、")) + "</div></div>";
607
925
  }
608
926
 
609
927
  // Pages from sites not yet supported this batch: the site (or how many), how their Markdown
@@ -679,7 +997,7 @@ function attentionCard() {
679
997
  + '<button type="button" class="prompt attention-target" data-act="show_browser" aria-label="打开下载浏览器">' + icon(a.login ? "lock" : "alert")
680
998
  + '<div class="attention-copy"><div class="t">' + esc(title) + '</div><div class="s">点击打开浏览器,查看并继续</div></div><span class="attention-arrow" aria-hidden="true">›</span></button>';
681
999
  if (panel === "confirm") return html + actionsBlock() + "</div>";
682
- html += '<div class="actions"><button class="iconbtn" data-act="settings" aria-label="设置">' + icon("gear")
1000
+ html += '<div class="actions"><button class="iconbtn' + (newerVersion() ? " has-dot" : "") + '" data-act="settings" aria-label="设置">' + icon("gear")
683
1001
  + '</button><span class="grow"></span>';
684
1002
  if (V.actions) {
685
1003
  html += '<button class="btn" data-act="skip_item">跳过本篇</button>'
@@ -843,13 +1161,16 @@ function taskStrip() {
843
1161
  return "";
844
1162
  }
845
1163
 
846
- function settingsHead(title) {
1164
+ function settingsHead(title, sub = "设置") {
1165
+ return settingsHeadOnly(title, sub) + reopenLine();
1166
+ }
1167
+ function settingsHeadOnly(title, sub = "设置") {
847
1168
  // A window opened just for the settings closes from any page; the home page has nothing to go back to.
848
1169
  const closable = settingsOnly && !busy(), home = settingsPage === "home";
849
1170
  lastStrip = taskStrip();
850
1171
  return '<div class="head">' + (home && closable ? "" : '<button class="iconbtn" data-act="back" aria-label="返回">' + icon("left") + "</button>")
851
1172
  + '<div class="drag capsule-drag-region"><div class="text"><div class="title">' + esc(title) + "</div>"
852
- + (home ? "" : '<div class="sub">设置</div>') + "</div></div>"
1173
+ + (home || !sub ? "" : '<div class="sub">' + esc(sub) + "</div>") + "</div></div>"
853
1174
  + (closable ? '<button class="iconbtn" data-act="close_settings" aria-label="关闭">' + icon("close") + "</button>" : "")
854
1175
  + '</div><div id="task-strip">' + lastStrip + "</div>";
855
1176
  }
@@ -857,25 +1178,43 @@ function settingsHead(title) {
857
1178
  const fieldsOn = (page) => settings.fields.filter((f) => (f.page || "wait") === page);
858
1179
  const field = (name) => settings.fields.find((f) => f.name === name);
859
1180
 
1181
+ // The user's own folder as ~ on the home page's line (user, 2026-11-21: /Users/<name>/Downloads and the hourly limit
1182
+ // did not fit one line in English); the download page shows the folder whole.
1183
+ const shortPath = (path) => String(path || "").replace(/^(?:\/Users\/[^/]+|\/home\/[^/]+|[A-Za-z]:\\Users\\[^\\]+)(?=[\/\\]|$)/, "~");
860
1184
  function settingsHome() {
861
1185
  const hourly = field("hourly"), login = field("login");
862
1186
  const rows = [
863
- ["download", "folder", "下载", [settings.download_dir, hourly ? "每家每小时 " + hourly.value + " 篇" : ""]],
1187
+ ["download", "folder", "下载", [shortPath(settings.download_dir), hourly ? "每家每小时 " + hourly.value + " 篇" : ""]],
864
1188
  ["wait", "clock", "等待和提醒", [login ? "登录页 " + login.value + " 秒" : "", "系统通知" + (notifyOn ? "开" : "关")]],
865
1189
  ["keys", "key", "API key", [apiKeys && apiKeys.ok ? "已填 " + apiKeys.filled + "/" + apiKeys.total : ""]],
866
1190
  ];
867
- return settingsHead("设置") + rows.map(navRow).join("") + (proOn() ? proHomeRows() : "")
868
- // The language row reads the same in both languages.
869
- + '<div class="row"><span>语言</span><span class="seg">' + ["zh", "en"].map((code) => '<button type="button" data-act="language" data-lang="'
870
- + code + '" aria-pressed="' + (lang === code) + '"' + (lang === code ? ' class="on"' : "") + ">" + (code === "zh" ? "中文" : "English")
871
- + "</button>").join("") + "</span></div>"
1191
+ const installed = proOn() && !!(proStatus && proStatus.ok && proStatus.installed);
1192
+ // Pro not there: one row of its own, last, to 关于 PaperSearch where it is introduced (user, 2026-11-21: 乙, its
1193
+ // line saying 需要激活); there: its features' rows.
1194
+ const pro = !proOn() ? "" : installed ? proFeatures().map(navRow).join("")
1195
+ : navRow(["about", "pro-app", "PaperSearch", [proActivated() ? "已激活 · 未安装" : proActivation().state === "expired" ? "激活已过期" : "需要激活"], "Pro"]);
1196
+ return settingsHead("设置") + rows.map(navRow).join("") + pro
1197
+ + '<div class="row home-foot">' + versionLink() + languageMenu() + "</div>"
872
1198
  + (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
873
1199
  }
874
1200
 
1201
+ // The language, at the right of the home page's foot: its own name, and open, the others each in theirs.
1202
+ function languageMenu() {
1203
+ const name = (LANGUAGES.find(([code]) => code === lang) || LANGUAGES[0])[1];
1204
+ return '<span class="lang-wrap"><button type="button" class="lang-btn" data-act="language_menu" aria-haspopup="menu" aria-expanded="'
1205
+ + languageOpen + '" aria-label="' + esc("语言 · " + name) + '">' + icon("globe") + "<span>" + name + "</span>"
1206
+ + icon(languageOpen ? "up" : "down") + "</button>"
1207
+ + (languageOpen ? '<div class="lang-menu" role="menu">' + LANGUAGES.map(([code, own]) => '<button type="button" role="menuitemradio"'
1208
+ + ' data-act="language" data-lang="' + code + '" aria-checked="' + (code === lang) + '"><span>' + own + "</span>"
1209
+ + (code === lang ? icon("tick") : "") + "</button>").join("")
1210
+ + '<div class="lang-more">' + esc("更多语言陆续加入") + "</div></div>" : "") + "</span>";
1211
+ }
1212
+
875
1213
  // A row that opens a page: its icon, its name, what it holds now.
876
- function navRow([page, glyph, title, sub]) {
877
- return '<button type="button" class="nav-row" data-act="settings_page" data-page="' + page + '">' + icon(glyph)
878
- + '<span class="nav-text"><span class="nav-title">' + esc(title) + '</span><span class="nav-sub">'
1214
+ function navRow([page, glyph, title, sub, badge]) {
1215
+ return '<button type="button" class="nav-row" data-act="settings_page" data-page="' + page + '">' + (glyph === "pro-app" ? appIcon(16, true) : icon(glyph))
1216
+ + '<span class="nav-text"><span class="nav-title">' + esc(title)
1217
+ + (badge ? '<span class="pro-pill feature">' + esc(badge) + "</span>" : "") + '</span><span class="nav-sub">'
879
1218
  + esc(sub.filter(Boolean).join(" · ")) + "</span></span>" + icon("right") + "</button>";
880
1219
  }
881
1220
 
@@ -958,21 +1297,13 @@ function settingsKeys() {
958
1297
  + "</div>";
959
1298
  }
960
1299
 
961
- // The Markdown page (user, 2026-11-18): PaperSearch Pro, a beta (测试版); what it does; 安装 when it
962
- // is not here, with its progress, or 重试 after a failed one; and where to report a conversion.
963
- // Nothing of subscriptions or keys while it is free.
964
- function proStateLine() {
965
- if (proInstall.state === "running") return ["", "正在安装…"];
966
- if (proInstall.state === "failed") return ["bad", "安装没有完成:" + (proInstall.message || "安装出错")];
967
- if (!proStatus || !proStatus.ok) return ["bad", (proStatus && proStatus.error) || "读取失败"];
968
- if (!proStatus.installed) return ["", "未安装"];
969
- const installed = "已安装" + (proStatus.version ? " · " + proStatus.version : "");
970
- // 检查更新 (user, 2026-11-19): its answer after the version.
971
- if (proCheck.state === "running") return ["ok", installed + " · 正在检查更新…"];
972
- if (proCheck.state === "failed") return ["bad", installed + " · " + (proCheck.message || "检查更新出错")];
973
- if (proCheck.state === "done") return ["ok", installed + " · " + (proCheck.update ? "有新版本 " + proCheck.latest : "已是最新")];
974
- return ["ok", installed];
975
- }
1300
+
1301
+ // PaperSearch Pro's state (user, 2026-11-18, -21): not installed, whether this computer is activated
1302
+ // (src/management/pro/activate.ts: PaperSearch's activation server, its address still to come); installing,
1303
+ // activating first when a code was typed.
1304
+ const proActivation = () => (proStatus && proStatus.activation) || { state: "none", tail: "", until: "" };
1305
+ const proActivated = () => proActivation().state === "active";
1306
+ const proActivating = () => proInstall.state !== "idle" && proInstall.step === "activate";
976
1307
 
977
1308
  function proProgress() {
978
1309
  const done = proInstall.done || 0, total = proInstall.total || 0, mb = (bytes) => (bytes / 1048576).toFixed(1);
@@ -980,24 +1311,67 @@ function proProgress() {
980
1311
  note: total ? "正在下载 " + mb(done) + " / " + mb(total) + " MB" : "正在下载…" };
981
1312
  }
982
1313
 
1314
+ // Under Pro's state: the download's progress; installed, 更新到 a newer one; not installed,
1315
+ // 激活 Pro (the activation's own page), or 安装 once activated. No notes beside them (user, 2026-11-21).
983
1316
  function proAction() {
984
- const install = (label, hint) => '<button type="button" class="btn primary" data-act="install_pro">' + esc(label) + "</button>"
985
- + '<div class="pro-hint">' + esc(hint) + "</div>";
1317
+ const button = (label) => '<button type="button" class="btn primary" data-act="install_pro">' + esc(label) + "</button>";
986
1318
  if (proInstall.state === "running") {
1319
+ if (proActivating()) return "";
987
1320
  const progress = proProgress();
988
1321
  return '<div class="pro-bar"><span style="width:' + progress.width.toFixed(1) + '%"></span></div>'
989
1322
  + '<div class="pro-hint" id="pro-progress">' + esc(progress.note) + "</div>";
990
1323
  }
991
- if (proInstall.state === "failed") return install("重试", "已下载的部分不会留下");
992
- if (proStatus && proStatus.ok && proStatus.installed && proCheck.state === "done" && proCheck.update) {
993
- return install("更新到 " + proCheck.latest, "核对完整后才替换原有的,转换记录保留");
1324
+ if (!proStatus || !proStatus.ok) return "";
1325
+ if (proInstall.state === "failed" && (proStatus.installed || proActivated()) && !proActivating()) return button("重试");
1326
+ if (proStatus.installed) {
1327
+ if (proActivation().state === "expired") return proCodeField("重新激活");
1328
+ // Its updates come with PaperSearch's, on the same page (user, 2026-11-21: one version, one button).
1329
+ return "";
994
1330
  }
995
- // About the size of Pro's bundle (pro/build.mjs --release), said before the download tells it.
996
- return proStatus && proStatus.ok && !proStatus.installed ? install("安装", "约 4 MB · PDF 和补充材料不需要它") : "";
1331
+ return proActivated() ? button("安装")
1332
+ : '<button type="button" class="btn primary" data-act="settings_page" data-page="pro_activate">' + esc("激活 Pro") + "</button>";
1333
+ }
1334
+
1335
+ // The activation code, typed and kept through a redraw; why it was not taken, under it. While the code is sent,
1336
+ // its button says so.
1337
+ function proCodeField(label, sending = false) {
1338
+ const error = proCodeError || (proInstall.state === "failed" && proActivating() ? proInstall.message || "激活出错" : "");
1339
+ return '<div class="pro-code-label">' + esc("激活码") + '</div><div class="pro-code"><input id="pro-code" type="text" autocomplete="off"'
1340
+ + ' spellcheck="false" value="' + esc(proCode) + '" placeholder="XXXX-XXXX-XXXX" aria-label="' + esc("激活码") + '">'
1341
+ + '<button type="button" class="btn primary" data-act="activate_pro"' + (sending ? " disabled" : "") + ">"
1342
+ + esc(sending ? "正在激活…" : label) + "</button></div>"
1343
+ + (error ? '<div class="err pro-code-err" role="alert">' + esc(error) + "</div>" : "");
1344
+ }
1345
+
1346
+ // The activation, a page of its own from Pro's (user, 2026-11-21): the code and 激活; taken, the install's
1347
+ // progress here; installed, the home page, where Pro's features are now. An install that failed after the
1348
+ // activation: why, and 重试.
1349
+ function settingsProActivate() {
1350
+ const installing = proInstall.state === "running" && !proActivating();
1351
+ const failed = proInstall.state === "failed" && !proActivating() && proActivated();
1352
+ const body = installing ? proAction()
1353
+ : failed ? proAction() + '<div class="err pro-code-err" role="alert">' + esc("安装没有完成:" + (proInstall.message || "安装出错")) + "</div>"
1354
+ : proCodeField("激活", proInstall.state === "running");
1355
+ return settingsHead("激活 Pro") + '<div class="pro-action">' + body + "</div>"
1356
+ + (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
997
1357
  }
998
1358
 
999
1359
  // What a Markdown keeps, beside the description.
1000
1360
  const PRO_KEEPS = [["photo", "图片"], ["table", "表格"], ["formula", "公式"], ["list", "参考文献"]];
1361
+ // What sets it apart (user, 2026-11-21): a row like the platforms', its three names under the title; opened, each
1362
+ // said in full.
1363
+ const PRO_MERITS = [
1364
+ ["file", "出版社原文", "取自出版社网页或 XML,不从 PDF 识别:章节、图注、表格(含合并单元格)和 LaTeX 公式按原文还原,避免识别错误。"],
1365
+ ["check", "完整才保存", "图片或表格有缺失就不生成,记为失败并说明原因,后续重试。"],
1366
+ ["link", "来源可追溯", "每篇保留出版社原始网页或 XML,以及来源清单:来源地址、DOI 核对结果和获取时间。"],
1367
+ ];
1368
+ function proMerits() {
1369
+ return '<button type="button" class="nav-row pro-row" data-act="pro_merits" aria-expanded="' + proMeritsOpen + '">' + icon("shield")
1370
+ + '<span class="nav-text"><span class="nav-title">' + esc("三项特点") + '</span><span class="nav-sub">'
1371
+ + esc("出版社原文 · 完整才保存 · 来源可追溯") + "</span></span>" + icon(proMeritsOpen ? "down" : "right") + "</button>"
1372
+ + (proMeritsOpen ? '<div class="pro-merits">' + PRO_MERITS.map(([glyph, title, said]) => '<div class="pro-merit">' + icon(glyph)
1373
+ + "<div><b>" + esc(title) + "</b><span>" + esc(said) + "</span></div></div>").join("") + "</div>" : "");
1374
+ }
1001
1375
 
1002
1376
  // The Markdown saved on this computer, how many complete, and the publishers' platforms with rules.
1003
1377
  function proStats() {
@@ -1016,60 +1390,153 @@ function proSites() {
1016
1390
  + '<span class="nav-text"><span class="nav-title">' + esc("支持的出版社平台") + '</span><span class="nav-sub">'
1017
1391
  + esc("共 " + sites.length + " 个,平台下的期刊都适用") + "</span></span>"
1018
1392
  + icon(proSitesOpen ? "down" : "right") + "</button>"
1019
- + (proSitesOpen ? '<div class="pro-sites">' + esc(sites.join("、")) + "</div>" : "");
1020
- }
1021
-
1022
- // Whether Pro is free now and until when (the user, 2026-11-19: the page ends with it).
1023
- function proAccessSaid() {
1024
- const access = (proStatus && proStatus.access) || {};
1025
- return access.mode === "key" ? "需要密钥" : access.until ? "测试期间免费,至 " + access.until : "测试期间免费,截止日期待定";
1026
- }
1027
-
1028
- function proAccess() {
1029
- const said = proAccessSaid();
1030
- return '<div class="nav-row pro-row static">' + icon("gift") + '<span class="nav-text"><span class="nav-title">' + esc("使用状态")
1031
- + '</span><span class="nav-sub">' + esc(said) + "</span></span></div>";
1032
- }
1033
-
1034
- // PaperSearch Pro's page (user, 2026-11-19): installing it, its version and whether it is free, then
1035
- // its features, each a page of its own; where to report a problem at the foot.
1393
+ + (proSitesOpen ? '<div class="pro-sites">' + siteGroups(sites).map(([group, names]) =>
1394
+ '<div class="site-group">' + esc(group) + " · " + names.length + '</div><div class="site-chips">'
1395
+ + names.map((name) => '<span class="site-chip">' + esc(name) + "</span>").join("") + "</div>").join("") + "</div>" : "");
1396
+ }
1397
+
1398
+ // The platforms by kind, each site once, the multidisciplinary platforms first (user, 2026-11-20): the big
1399
+ // publishers' platforms hold every subject; the others are a journal's, a society's or a field's own sites.
1400
+ // A site Pro adds later and not listed here goes under 其他.
1401
+ const SITE_GROUPS = [
1402
+ ["多学科出版平台", ["ScienceDirect", "SpringerLink", "Wiley", "Taylor & Francis", "Sage", "Oxford Academic"]],
1403
+ ["综合期刊", ["Science", "Nature", "PNAS", "Cell Press", "Annual Reviews", "Royal Society"]],
1404
+ ["医学", ["NEJM", "The Lancet", "JAMA Network", "BMJ", "AHA journals", "JACC journals", "Neurology", "ASH Publications",
1405
+ "LWW (Ovid)", "Karger", "Thieme", "Dove Medical Press"]],
1406
+ ["理工", ["ACS Publications", "RSC Publishing", "AIP Publishing", "APS Physics", "IOPscience", "Optica Publishing Group",
1407
+ "IEEE Xplore", "ACM Digital Library", "ASCE Library", "AMS journals", "World Scientific", "Copernicus"]],
1408
+ ["开放获取", ["PLOS", "MDPI", "Frontiers", "BMC"]],
1409
+ ];
1410
+ function siteGroups(sites) {
1411
+ const listed = new Set(SITE_GROUPS.flatMap(([, names]) => names));
1412
+ const groups = SITE_GROUPS.map(([group, names]) => [group, names.filter((name) => sites.includes(name))]);
1413
+ groups.push(["其他", sites.filter((name) => !listed.has(name)).sort()]);
1414
+ return groups.filter(([, names]) => names.length);
1415
+ }
1416
+
1417
+ // What Pro does now and what is coming (user, 2026-11-21: Zotero, a map of related papers as ResearchRabbit
1418
+ // draws one, and new papers pushed by subscription), on its page, installed or not.
1419
+ const PRO_NOW = [
1420
+ ["file", "Markdown 全文", "出版社原文转成 Markdown,图表、公式完整"],
1421
+ ["lock", "学校自动登录", "学校登录页自动填写账号,批量下载不用守着"],
1422
+ ];
1423
+ const PRO_COMING = [
1424
+ ["Zotero 整合", "文献库里缺 PDF 的条目自动补下,挂回原条目"],
1425
+ ["文献关系图", "从一篇论文出发,沿引用找相关文献,画成关系图"],
1426
+ // User, 2026-11-21: what each one wants, pushed to them.
1427
+ ["文献订阅", "按关注的主题、期刊或作者,定期推送新论文"],
1428
+ ];
1429
+ // 使用状态 on Pro's page once installed: activated, its code's last four characters and until when; before the
1430
+ // activation server (none kept), whether Pro is free and until when (Pro's own switch).
1431
+ function proUsage(heading = true) {
1432
+ const activation = proActivation(), access = (proStatus && proStatus.access) || {};
1433
+ const row = (label, value, tone) => '<div class="row pro-use"><span>' + esc(label) + '</span><span class="' + (tone || "dim") + '">'
1434
+ + esc(value) + "</span></div>";
1435
+ const rows = activation.state !== "none"
1436
+ ? row("激活状态", activation.state === "active" ? "已激活" : "已过期", activation.state === "active" ? "ok" : "bad")
1437
+ + row("激活码", "••••" + activation.tail) + row("有效期", activation.until ? "至 " + activation.until : "不限")
1438
+ : access.mode === "key" ? row("使用方式", "需要激活")
1439
+ : row("使用方式", "测试期间免费") + row("截止日期", access.until || "待定");
1440
+ return (heading ? '<div class="key-group">' + esc("使用状态") + "</div>" : "") + rows;
1441
+ }
1442
+
1443
+ // PaperSearch Pro's features (user, 2026-11-19), each a page of its own; on the home page under Pro's title once installed.
1036
1444
  function proFeatures() {
1037
- const installed = !!(proStatus && proStatus.ok && proStatus.installed);
1038
- const converted = installed ? (proStatus.converted || 0) : 0, sites = installed ? (proStatus.sites || []).length : 0;
1445
+ const converted = proStatus.converted || 0, sites = (proStatus.sites || []).length;
1039
1446
  return [
1040
- ["markdown", "file", "Markdown 全文", installed ? ["已转换 " + converted.toLocaleString("en-US") + " 篇", sites + " 个平台"]
1041
- : ["把论文全文转成 Markdown"]],
1447
+ ["markdown", "file", "Markdown 全文", ["已转换 " + converted.toLocaleString("en-US") + " 篇", sites + " 个平台"], "Pro"],
1042
1448
  ["login", "lock", "学校自动登录", !schoolLogin || !schoolLogin.ok ? [] : !schoolLogin.saved ? ["未填"]
1043
- : [schoolLogin.enabled ? "已打开" : "已关闭", schoolLogin.username]],
1449
+ : [schoolLogin.enabled ? "已打开" : "已关闭", schoolLogin.username], "Pro"],
1044
1450
  ];
1045
1451
  }
1046
1452
 
1047
- // The home page's part of Pro (user, 2026-11-19: 铺开). Installed: its features under its name, then
1048
- // its version and updates; not yet (or installing): one row to Pro's page.
1049
- function proHomeRows() {
1050
- if (!proInstalled()) {
1051
- return navRow(["pro", "shield", "PaperSearch Pro", proInstall.state === "running" ? ["正在安装…"]
1052
- : [proStatus && proStatus.ok ? "未安装" : ""]]);
1053
- }
1054
- return '<div class="key-group pro-group">' + esc("PaperSearch Pro · 测试版") + "</div>"
1055
- + proFeatures().map(navRow).join("")
1056
- + navRow(["pro", "shield", "版本与更新", [proStatus.version || "", proAccessSaid()]]);
1453
+ // PaperSearch's version at the left of the home page's foot, for everyone, to 关于 PaperSearch (user, 2026-11-21: one
1454
+ // version and one update, Pro with it); a newer one there, the whole line in red saying so (乙).
1455
+ function versionLink() {
1456
+ const update = newerVersion();
1457
+ const said = update ? (versionCheck.update ? "有新版本 " + versionCheck.latest + ",点此更新" : "有新版本,点此更新")
1458
+ : "PaperSearch" + (versionInfo.running ? " " + versionInfo.running : "");
1459
+ return '<button type="button" class="version-link' + (update ? " new" : "") + '" data-act="settings_page" data-page="about">'
1460
+ + (update ? icon("upcircle") : "") + '<span class="pl-text">' + esc(said) + "</span></button>";
1057
1461
  }
1058
1462
 
1059
- function settingsPro() {
1060
- const [tone, state] = proStateLine();
1061
- const installed = proInstalled();
1062
- return settingsHead(installed ? "版本与更新" : "PaperSearch Pro")
1063
- + '<div class="pro-head"><span class="pro-tile">' + icon("shield") + '</span><span class="nav-text">'
1064
- + '<span class="pro-name">PaperSearch Pro<span class="pro-pill">' + esc("测试版") + "</span></span>"
1065
- + '<span class="pro-state' + (tone ? " " + tone : "") + '" role="status">' + esc(state) + "</span></span>"
1066
- + (installed && proCheck.state !== "running" ? '<button type="button" class="btn link pro-check" data-act="check_pro">'
1067
- + esc("检查更新") + "</button>" : "") + "</div>"
1068
- + '<div class="pro-action">' + proAction() + "</div>"
1069
- // Not installed yet: what it brings, each to its page; installed, they are on the home page.
1070
- + (installed ? proAccess() : '<div class="key-group">' + esc("功能") + "</div>" + proFeatures().map(navRow).join(""))
1071
- + '<div class="pro-foot"><span>' + esc("用着有问题?") + "</span>"
1072
- + '<button type="button" class="btn link" data-act="pro_issue">' + esc("提交 issue") + icon("right") + "</button></div>"
1463
+
1464
+ // A Pro feature's page before Pro is there (user, 2026-11-21: as one not paid for sees it): what it needs, and
1465
+ // the way to Pro's page.
1466
+ function proNeeded() {
1467
+ const activated = proActivated();
1468
+ return '<div class="pro-needed"><span>' + esc(activated ? "安装 PaperSearch Pro 后可用" : "激活 PaperSearch Pro 后可用") + "</span>"
1469
+ + '<button type="button" class="btn link" data-act="settings_page" data-page="about">' + esc(activated ? "去安装" : "去激活")
1470
+ + icon("right") + "</button></div>";
1471
+ }
1472
+
1473
+ // 关于 PaperSearch (user, 2026-11-21, as drawn): its icon, name and version, and its update, Pro's with it; then Pro.
1474
+ // Not bought: its features, what is coming (计划中 after each name), 激活 Pro at the foot. Bought: the icon Pro's, Pro
1475
+ // beside the name (the line shifted a little to the right), its state, what is coming, 提交 issue.
1476
+ const UPDATE_STEPS = { paper_search: "PaperSearch", school: "学校订阅下载扩展", skills: "Skill", pro: "Pro" };
1477
+ function versionLine() {
1478
+ const running = versionInfo.running || versionCheck.current || "";
1479
+ const at = (said) => (running ? running + " · " : "") + said;
1480
+ if (updateRun.state === "running" || (updateRun.state === "done" && updateRun.reopen)) {
1481
+ return ["", updateRun.state === "done" ? "正在重新打开…" : updateRun.target ? "正在更新到 " + updateRun.target + "…" : "正在更新…"];
1482
+ }
1483
+ if (updateRun.state === "failed") return ["bad", at(updateRun.message || "更新出错")];
1484
+ if (versionCheck.state === "running") return ["", at("正在检查更新…")];
1485
+ if (versionCheck.state === "failed") return ["bad", at(versionCheck.message || "检查更新出错")];
1486
+ if (newerVersion()) return ["new", at(versionCheck.update ? "有新版本 " + versionCheck.latest : "有新版本")];
1487
+ if (versionCheck.state === "done") return ["", at("已是最新版本")];
1488
+ return ["", running];
1489
+ }
1490
+ function aboutAction() {
1491
+ const steps = updateRun.steps || [];
1492
+ if (updateRun.state === "running" || (updateRun.state === "done" && updateRun.reopen)) {
1493
+ const done = updateRun.state === "done" ? steps.length : updateRun.step || 0;
1494
+ return '<div class="about-action"><div class="pro-bar"><span style="width:' + (steps.length ? (done / steps.length) * 100 : 0).toFixed(1)
1495
+ + '%"></span></div><ol class="test-steps update-steps">' + steps.map((step, i) => '<li class="' + (i < done ? "done" : i === done ? "now" : "")
1496
+ + '">' + (i < done ? icon("check") : '<span class="mark"></span>') + "<span>"
1497
+ + esc(step === "paper_search" && updateRun.target ? "PaperSearch " + updateRun.target : UPDATE_STEPS[step] || step) + "</span></li>").join("")
1498
+ + "</ol>" + (steps.includes("paper_search") ? '<div class="about-caption">' + esc("完成后窗口会自动重新打开") + "</div>" : "") + "</div>";
1499
+ }
1500
+ if (updateRun.state === "failed") {
1501
+ return '<div class="about-action"><button type="button" class="btn primary" data-act="update_all">' + esc("重试") + "</button></div>";
1502
+ }
1503
+ if (newerVersion()) {
1504
+ const label = versionCheck.update ? "更新到 " + versionCheck.latest : "更新";
1505
+ return '<div class="about-action">' + (busy()
1506
+ ? '<button type="button" class="btn primary" disabled>' + esc("下载结束后更新") + "</button>"
1507
+ : '<button type="button" class="btn primary" data-act="update_all">' + esc(label) + "</button>")
1508
+ + (versionCheck.update && versionCheck.notes ? '<button type="button" class="btn link" data-act="release_notes">' + esc("这次更新了什么") + "</button>" : "")
1509
+ + "</div>";
1510
+ }
1511
+ return versionCheck.state === "running" ? "" : '<div class="about-action"><button type="button" class="btn link" data-act="check_versions">'
1512
+ + esc("检查更新") + "</button></div>";
1513
+ }
1514
+ const aboutFeature = ([title, said], planned) => '<div class="about-feat"><b>' + esc(title) + "</b>"
1515
+ + (planned ? '<span class="pro-tag">' + esc("计划中") + "</span>" : "") + '<span class="pl-sub">' + esc(said) + "</span></div>";
1516
+ const aboutComing = () => '<div class="about-sub">' + esc("即将推出") + "</div>" + PRO_COMING.map((f) => aboutFeature(f, true)).join("");
1517
+ function settingsAbout() {
1518
+ const installed = proOn() && !!(proStatus && proStatus.ok && proStatus.installed);
1519
+ const [tone, line] = versionLine();
1520
+ const hero = '<div class="about-hero">' + appIcon(56, installed) + '<div class="about-name' + (installed ? " with-pill" : "") + '">PaperSearch'
1521
+ + (installed ? '<span class="pro-pill">Pro</span>' : "") + '</div><div class="about-version' + (tone ? " " + tone : "") + '" role="status">'
1522
+ + esc(line) + "</div></div>" + aboutAction();
1523
+ let pro = "";
1524
+ if (proOn() && installed) {
1525
+ pro = '<div class="about-gap"></div>' + (proAction() ? '<div class="pro-action">' + proAction() + "</div>" : "") + proUsage(false) + aboutComing()
1526
+ + '<div class="pro-foot"><span>' + esc("用着有问题?") + "</span>"
1527
+ + '<button type="button" class="btn link" data-act="pro_issue">' + esc("提交 issue") + icon("right") + "</button></div>";
1528
+ } else if (proOn()) {
1529
+ const access = (proStatus && proStatus.access) || {};
1530
+ pro = '<div class="about-sec">' + appIcon(20, true) + '<span>PaperSearch</span><span class="pro-pill">Pro</span></div>'
1531
+ + PRO_NOW.map(([, title, said]) => aboutFeature([title, said], false)).join("") + aboutComing()
1532
+ + '<div class="pro-action pro-activate">' + proAction() + "</div>"
1533
+ // An install that did not finish says why under its 重试 (the activation's own page says it too).
1534
+ + (proInstall.state === "failed" && !proActivating() && proActivated() ? '<div class="err pro-code-err" role="alert">'
1535
+ + esc("安装没有完成:" + (proInstall.message || "安装出错")) + "</div>" : "")
1536
+ + (proInstall.state !== "running" && access.mode !== "key" && !proActivated() ? '<div class="about-caption">' + esc("测试期间免费") + "</div>" : "");
1537
+ }
1538
+ // Its head says 设置 alone: the name is the page's own, under the icon (user, 2026-11-21).
1539
+ return settingsHead("设置", "") + hero + pro
1073
1540
  + (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
1074
1541
  }
1075
1542
 
@@ -1079,52 +1546,320 @@ function settingsMarkdown() {
1079
1546
  return settingsHead("Markdown 全文")
1080
1547
  + '<div class="pro-desc">' + esc("把论文全文转成 Markdown,以下内容一并保留:") + "</div>"
1081
1548
  + '<div class="pro-chips">' + PRO_KEEPS.map(([glyph, text]) => '<span class="pro-chip">' + icon(glyph) + esc(text) + "</span>").join("") + "</div>"
1082
- + (installed ? proStats() + proSites() : '<div class="pro-desc">' + esc("安装 PaperSearch Pro 后可用") + "</div>")
1083
- + '<div class="pro-foot"><span>' + esc("转换有缺漏或出错?") + "</span>"
1084
- + '<button type="button" class="btn link" data-act="pro_issue">' + esc("提交 issue") + icon("right") + "</button></div>"
1549
+ + (installed ? proStats() + proMerits() + proSites()
1550
+ + '<div class="pro-foot"><span>' + esc("转换有缺漏、出错,或想加出版社?") + "</span>"
1551
+ + '<button type="button" class="btn link" data-act="pro_issue">' + esc("提交 issue") + icon("right") + "</button></div>"
1552
+ : proMerits() + proNeeded())
1085
1553
  + (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
1086
1554
  }
1087
1555
 
1088
- // The school sign-in page (PaperSearch Pro, user 2026-11-19): the school's account, filled in on the
1089
- // school's own login page once Pro has tested that school. Each field under its name, with room; the
1090
- // saved password in its field, hidden until the eye shows it (the user's: they may see it).
1091
- function loginStatus(s) {
1092
- if (!s.pro) return ["bad", "需要 PaperSearch Pro"];
1093
- if (s.status === "verified") return ["ok", "这所学校已实测,会自动登录"];
1094
- if (s.status === "surveyed") return ["ok", "这所学校已摸底,会自动登录"];
1095
- if (s.status === "trial") return ["", "这所学校正在实测,暂时只对维护者开放"];
1096
- return ["", "这所学校还没实测,暂时不能自动登录"];
1556
+ // The school sign-in page (PaperSearch Pro): the schools saved, each with its account, filled in on the
1557
+ // school's own login page once Pro has tested that school; one of them the default for downloads, switched
1558
+ // here; another added by finding it in the federations' lists, in any language (user, 2026-11-20). The saved
1559
+ // password in its field, hidden until the eye shows it (the user's: they may see it).
1560
+ function schoolTag(status) {
1561
+ if (status === "verified" || status === "surveyed") return ["fill", "自动填写"];
1562
+ if (status === "trial") return ["trial", "实测中"];
1563
+ if (status === "check") return ["check", "需自己登录"];
1564
+ return ["none", "暂不支持"];
1565
+ }
1566
+ function tagHtml(status) {
1567
+ const [cls, text] = schoolTag(status);
1568
+ return '<span class="tag ' + cls + '">' + esc(text) + "</span>";
1569
+ }
1570
+ // A school's name in the window's language (user, 2026-11-21): in English its English name; in another its name in
1571
+ // that language where Pro has one (Wikidata's), in Traditional Chinese else its Chinese one (tr() turns its
1572
+ // characters); else its own name as its federation lists it, not a translation.
1573
+ function schoolName(s) {
1574
+ const names = s.names || {};
1575
+ if (lang === "en") return s.name_en || s.name || s.key;
1576
+ return names[lang] || (lang === "zh-Hant" ? names.zh : "") || s.name || s.name_en || s.key;
1097
1577
  }
1098
1578
 
1099
1579
  async function loadLoginValues() {
1100
- try { loginValues = (await api().school_login_saved()) || {}; } catch (error) { loginValues = {}; }
1580
+ try { loginValues = (await api().school_login_saved(loginOpen)) || {}; } catch (error) { loginValues = {}; }
1581
+ loginSavedValues = { ...loginValues };
1582
+ // 测试登录's article for the school open, and a test going on when the page was left.
1583
+ if (testArticleFor !== loginOpen) {
1584
+ testArticleFor = loginOpen; testArticle = null; testEditing = false; testArticleError = ""; testArticleText = "";
1585
+ try {
1586
+ const answer = await api().school_test_article(loginOpen);
1587
+ if (answer && answer.ok) testArticle = answer;
1588
+ } catch (error) { testArticle = null; }
1589
+ }
1590
+ try { schoolTest = (await api().school_test_state()) || { state: "idle" }; } catch (error) { schoolTest = { state: "idle" }; }
1591
+ if (schoolTest.state === "running") watchSchoolTest();
1101
1592
  }
1102
1593
 
1103
- function settingsLogin() {
1104
- const s = schoolLogin, head = settingsHead("学校自动登录");
1105
- if (!s || !s.ok) return head + '<div class="err" style="text-align:left">' + esc((s && s.error) || "读取失败") + "</div>";
1106
- if (!s.entity) return head + '<div class="settings-note">' + esc("还没有设置学校:设置好学校后再来填账号") + "</div>";
1107
- const [tone, line] = loginStatus(s);
1108
- return head
1109
- + '<div class="pro-head"><span class="pro-tile">' + icon("lock") + '</span><span class="nav-text">'
1110
- + '<span class="pro-name">' + esc(s.school || "当前学校") + "</span>"
1111
- + '<span class="pro-state' + (tone ? " " + tone : "") + '" role="status">' + esc(line) + "</span></span></div>"
1112
- + (s.off === "rejected" ? '<div class="err" style="text-align:left;margin-top:10px">'
1594
+ // While a test runs, how it goes is asked for each second; the page is drawn again as its step or line changes.
1595
+ function watchSchoolTest() {
1596
+ clearInterval(testTimer);
1597
+ testTimer = setInterval(async () => {
1598
+ let next;
1599
+ try { next = await api().school_test_state(); } catch (error) { return; }
1600
+ const before = JSON.stringify(schoolTest);
1601
+ schoolTest = next || { state: "idle" };
1602
+ if (schoolTest.state !== "running") {
1603
+ clearInterval(testTimer);
1604
+ // The school's account may have been turned off (a password the school refused).
1605
+ try { const state = await api().school_login_state(); if (state && state.ok) schoolLogin = state; } catch (error) { /* as it was */ }
1606
+ }
1607
+ if (JSON.stringify(schoolTest) !== before && panel === "settings" && settingsPage === "login") render(true);
1608
+ }, 1000);
1609
+ }
1610
+
1611
+ // 测试登录 going on (user, 2026-11-21, as drawn): its steps, the one it is at and what the download says there; 停止测试.
1612
+ const TEST_STEPS = ["打开文章页", "学校登录", "下载全文", "核对 PDF"];
1613
+ function loginTesting(t) {
1614
+ return '<div class="login-test" role="status"><ol class="test-steps">' + TEST_STEPS.map((label, i) =>
1615
+ '<li class="' + (i < t.step ? "done" : i === t.step ? "now" : "") + '">' + (i < t.step ? icon("check") : '<span class="mark"></span>')
1616
+ + "<span>" + esc(label) + "</span></li>").join("") + "</ol>"
1617
+ + '<div class="test-phase">' + esc(t.stopping ? "正在停止…" : t.phase || "") + "</div>"
1618
+ + '<div class="key-actions"><span class="grow"></span><button class="btn" data-act="school_test_stop"' + (t.stopping ? " disabled" : "")
1619
+ + ">" + esc("停止测试") + "</button></div></div>";
1620
+ }
1621
+ // Before and after: how the last test of this school went, and the article the next opens, set by the user (user,
1622
+ // 2026-11-21: its DOI and 修改, which opens a box for a DOI or the article's address; none set for them, a short line
1623
+ // saying what to do and 填写), the test's own button 测试 at its end (甲: beside its article, so that it says what it
1624
+ // tests). 文章 beside 账号 and 密码, two characters each; its line ends where their boxes end.
1625
+ function loginTest(s) {
1626
+ if (!testArticle) return "";
1627
+ const label = "<span>" + esc("文章") + "</span>";
1628
+ const t = schoolTest.state === "done" && schoolTest.key === s.key ? schoolTest : null;
1629
+ const result = t ? '<div class="test-result ' + (t.ok ? "ok" : "bad") + '" role="status">' + icon(t.ok ? "check" : "alert")
1630
+ + '<div><div class="t">' + esc(t.title) + "</div>" + (t.detail ? '<div class="d">' + esc(t.detail) + "</div>" : "")
1631
+ + (t.ok ? '<div class="d">' + esc("用时 " + t.seconds + " 秒 · 测试下的 PDF 已删掉") + "</div>" : "") + "</div></div>" : "";
1632
+ // Also for a school whose account is not saved yet: 测试 saves what is typed first.
1633
+ const test = '<button class="btn test-btn" data-act="school_test">' + esc("测试") + "</button>";
1634
+ if (testEditing) {
1635
+ return result + label + '<div class="test-article"><span class="test-edit">'
1636
+ + '<input id="test-article" type="text" autocomplete="off" spellcheck="false" value="' + esc(testArticleText)
1637
+ + '" placeholder="' + esc("DOI 或文章网址") + '" aria-label="' + esc("测试文章") + '">'
1638
+ + '<button type="button" class="link-btn" data-act="test_article_save"' + (testArticleSaving ? " disabled" : "") + ">"
1639
+ + esc(testArticleSaving ? "查找中…" : "确定") + "</button></span>" + test + "</div>"
1640
+ + (testArticleError ? '<div class="err test-err" role="status">' + esc(testArticleError) + "</div>" : "");
1641
+ }
1642
+ const doi = testArticle.doi;
1643
+ return result + label + '<div class="test-article"><span class="what' + (doi ? "" : " empty") + '"' + (doi ? ' title="' + esc(doi) + '"' : "")
1644
+ + ">" + esc(doi || "填入学校订阅文章 DOI 或网址") + "</span>"
1645
+ + '<button type="button" class="link-btn" data-act="test_article_edit">' + esc(doi ? "修改" : "填写") + "</button>" + test + "</div>";
1646
+ }
1647
+
1648
+ function loginSchool(s, index) {
1649
+ const shown = loginOpen === s.key;
1650
+ // Their order, where there is more than one (user, 2026-11-21: 没权限时换下一所学校 goes down it; 1 the default).
1651
+ const many = ((schoolLogin && schoolLogin.schools) || []).length > 1;
1652
+ const row = '<button type="button" class="login-row" data-act="login_open" data-key="' + esc(s.key) + '" aria-expanded="' + shown + '">'
1653
+ + (many ? '<span class="ls-n">' + (index + 1) + "</span>" : "") + '<span class="ls-name">' + esc(schoolName(s)) + "</span>"
1654
+ + (s.current ? '<span class="tag default">' + esc("默认") + "</span>" : "") + tagHtml(s.status)
1655
+ + '<span class="ls-acct">' + esc(s.saved ? (s.enabled ? s.username : "已关闭") : "未填账号") + "</span>"
1656
+ + icon(shown ? "down" : "right") + "</button>";
1657
+ if (!shown) return '<div class="login-school">' + row + "</div>";
1658
+ if (schoolTest.state === "running" && schoolTest.key === s.key) return '<div class="login-school">' + row + loginTesting(schoolTest) + "</div>";
1659
+ return '<div class="login-school">' + row
1660
+ + (s.off === "rejected" ? '<div class="err" style="text-align:left;margin:0 0 8px">'
1113
1661
  + esc("学校没有接受保存的密码,自动登录已关闭;更新密码后保存,就会重新打开") + "</div>" : "")
1114
1662
  + '<div class="login-form">'
1115
- + '<label class="login-field"><span>' + esc("账号") + '</span><input id="login-user" type="text" autocomplete="off" spellcheck="false" value="'
1116
- + esc(loginValues.username || "") + '" placeholder="' + esc("学号或工号") + '"></label>'
1117
- + '<label class="login-field"><span>' + esc("密码") + '</span><span class="login-pw"><input id="login-password" type="'
1118
- + (loginShown ? "text" : "password") + '" autocomplete="new-password" spellcheck="false" value="' + esc(loginValues.password || "") + '">'
1663
+ + "<span>" + esc("账号") + '</span><input id="login-user" type="text" autocomplete="off" spellcheck="false" value="'
1664
+ + esc(loginValues.username || "") + '" placeholder="' + esc("学号或工号") + '" aria-label="' + esc("账号") + '">'
1665
+ + "<span>" + esc("密码") + '</span><span class="login-pw"><input id="login-password" type="'
1666
+ + (loginShown ? "text" : "password") + '" autocomplete="new-password" spellcheck="false" value="' + esc(loginValues.password || "")
1667
+ + '" aria-label="' + esc("密码") + '">'
1119
1668
  + '<button type="button" class="iconbtn" data-act="login_reveal" aria-label="' + esc("显示密码") + '" aria-pressed="' + loginShown + '">'
1120
- + icon("eye") + "</button></span></label>"
1121
- + '<div class="key-note">' + esc("只在学校自己的登录页上填写;密码不对只试一次,然后自动关闭。账号和密码存在这台电脑的设置文件里。") + "</div>"
1669
+ + icon("eye") + "</button></span>"
1670
+ // A line for an error, or the next step once a school is added; "saved" said on the button itself (user, 2026-11-20).
1122
1671
  + '<div class="err' + (loginError ? "" : " ok") + '" id="login-error" role="status">' + esc(loginError || loginDone) + "</div>"
1672
+ + loginTest(s)
1123
1673
  + '<div class="key-actions">'
1124
1674
  + (s.saved ? '<button class="btn" data-act="login_switch">' + esc(s.enabled ? "关闭自动登录" : "打开自动登录") + "</button>" : "")
1125
1675
  + '<span class="grow"></span>'
1126
- + (s.saved ? '<button class="btn danger" data-act="clear_login">' + esc(confirmClear === "login" ? "确认清除" : "清除") + "</button>" : "")
1127
- + '<button class="btn primary" data-act="save_login">' + esc("保存") + "</button></div></div>";
1676
+ + '<button class="btn primary" data-act="save_login">' + (loginSaved ? icon("check") + esc("已保存") : esc("保存")) + "</button></div>"
1677
+ + loginLinks(s) + "</div></div>";
1678
+ }
1679
+
1680
+ // Under the buttons, the same for every school: set it as the default (not the default already), clear its account
1681
+ // and password (saved ones), remove it (not the default: another is made the default first); the last two asked twice.
1682
+ function loginLinks(s) {
1683
+ const links = [];
1684
+ if (!s.current) links.push('<button type="button" class="link-btn" data-act="set_default" data-key="' + esc(s.key) + '">' + esc("设为默认") + "</button>");
1685
+ if (s.saved) links.push('<button type="button" class="link-btn danger' + (confirmClear === "login" ? " confirm" : "") + '" data-act="clear_login">'
1686
+ + esc(confirmClear === "login" ? "确认清除账号密码" : "清除账号密码") + "</button>");
1687
+ if (!s.current) links.push('<button type="button" class="link-btn danger' + (confirmForget === s.key ? " confirm" : "") + '" data-act="forget_school" data-key="'
1688
+ + esc(s.key) + '">' + esc(confirmForget === s.key ? "确认移除" : "移除这所学校") + "</button>");
1689
+ return links.length ? '<div class="login-links">' + links.join('<span class="sep">·</span>') + "</div>" : "";
1690
+ }
1691
+
1692
+ function loginFound() {
1693
+ if (schoolFinding) return '<div class="err ok" role="status">' + esc("查找中…") + "</div>";
1694
+ if (!schoolFound) return "";
1695
+ if (!schoolFound.ok) return '<div class="err" role="status">' + esc(schoolFound.error || "查找失败") + "</div>";
1696
+ return (schoolFound.results || []).map((s) => '<div class="login-found"><span class="ls-name">' + esc(schoolName(s)) + "</span>"
1697
+ + (s.federation ? '<span class="ls-fed">' + esc(s.federation) + "</span>" : "") + tagHtml(s.status)
1698
+ + (s.added ? '<span class="ls-fed" style="margin-left:auto">' + esc("已添加") + "</span>"
1699
+ : '<button class="btn" data-act="add_school" data-key="' + esc(s.key) + '">' + esc("添加") + "</button>") + "</div>").join("")
1700
+ + (schoolFound.note ? '<div class="err" role="status">' + esc(schoolFound.note) + "</div>" : "");
1701
+ }
1702
+
1703
+ function settingsLogin() {
1704
+ const s = schoolLogin, head = settingsHead("学校自动登录");
1705
+ if (!s || !s.ok) return head + '<div class="err" style="text-align:left">' + esc((s && s.error) || "读取失败") + "</div>";
1706
+ if (!s.pro) return head + '<div class="pro-desc">' + esc("学校登录页自动填写账号和密码,批量下载不用守着。") + "</div>" + proNeeded();
1707
+ // 添加学校 a row like the schools', opened to its search (user, 2026-11-20: a box alone said nothing).
1708
+ return head + '<div style="margin-top:8px">' + (s.schools || []).map(loginSchool).join("")
1709
+ + '<div class="login-school"><button type="button" class="login-row login-add-row" data-act="login_add" aria-expanded="' + loginAdding + '">'
1710
+ + icon("plus") + '<span class="ls-name">' + esc("添加学校") + "</span>" + icon(loginAdding ? "down" : "right") + "</button>"
1711
+ + (loginAdding ? '<div class="login-add"><div class="login-find"><input id="school-query" type="text" autocomplete="off" spellcheck="false" value="'
1712
+ + esc(schoolQuery) + '" placeholder="' + esc("中文名、英文名或学校网址") + '" aria-label="' + esc("学校名称") + '">'
1713
+ + '<button class="btn" data-act="find_school">' + esc("查找") + "</button></div>" + loginFound() + "</div>" : "")
1714
+ + "</div></div>"
1715
+ // 没权限时换下一所学校 (user, 2026-11-21; school_switch.py): one row, its switch at its right, on by default; there
1716
+ // with more than one school only.
1717
+ + ((s.schools || []).length > 1 ? '<div class="row switch-row"><span>' + esc("没权限时换下一所学校") + "</span>"
1718
+ + '<button class="switch' + (s.switch !== false ? " on" : "") + '" data-act="school_switch" role="switch" aria-checked="'
1719
+ + (s.switch !== false) + '" aria-label="' + esc("没权限时换下一所学校") + '"></button></div>' : "")
1720
+ // How many schools and which, on a page of their own (user, 2026-11-20: a link, not a line of numbers).
1721
+ + '<div class="login-more"><button type="button" class="btn link" data-act="settings_page" data-page="login_schools">'
1722
+ + esc("支持哪些学校") + icon("right") + "</button></div>";
1723
+ }
1724
+
1725
+ // 支持哪些学校: the schools Pro knows, how many of each kind, in two pages (user, 2026-11-21): the world's regions, each
1726
+ // opening in place to its countries (several may be open), and a country's schools on a page of their own (nested in one
1727
+ // list, they would not fit the window; a page for the regions' countries too was a level too many). On a big country's
1728
+ // page its parts open in place the same way (user, 2026-11-21, 甲): China's provinces, then Hong Kong, Macao and Taiwan;
1729
+ // a US school's state, a UK one's nation; Germany's by kind (Pro names no German states yet); a smaller country's schools
1730
+ // listed whole. Asia first and China first in it. The page's head (back, title, search) stays on top while its list
1731
+ // scrolls; a long name wraps. What is typed narrows the page's own country, or all; a province's or state's name finds
1732
+ // its schools. Each school with what Pro does for it.
1733
+ const SUPPORT_REGIONS = ["亚洲", "欧洲", "北美洲", "南美洲", "非洲", "大洋洲", "其他"];
1734
+ const CHINA_PLACES = ["香港", "澳门", "台湾"];
1735
+ // Each country the school lists name, by its region; one not here is listed under 其他 (Pro's tests check the lists
1736
+ // against this table).
1737
+ const SUPPORT_COUNTRIES = {
1738
+ "亚洲": "以色列 伊朗 卡塔尔 印度 印度尼西亚 哈萨克斯坦 土耳其 塞浦路斯 孟加拉国 巴基斯坦 巴林 斯里兰卡 新加坡 日本 沙特阿拉伯 泰国 科威特 约旦 菲律宾 越南 阿塞拜疆 阿曼 阿联酋 韩国 马来西亚 黎巴嫩 老挝 文莱",
1739
+ "欧洲": "丹麦 乌克兰 保加利亚 克罗地亚 冰岛 匈牙利 北马其顿 卢森堡 塞尔维亚 奥地利 希腊 德国 意大利 拉脱维亚 挪威 捷克 摩尔多瓦 斯洛伐克 斯洛文尼亚 比利时 法国 波兰 爱尔兰 爱沙尼亚 瑞典 瑞士 白俄罗斯 立陶宛 罗马尼亚 芬兰 英国 荷兰 葡萄牙 西班牙 阿尔巴尼亚 马耳他 黑山 安道尔 马恩岛 法罗群岛",
1740
+ "北美洲": "加拿大 哥斯达黎加 墨西哥 多米尼加 安圭拉 巴巴多斯 巴拿马 洪都拉斯 牙买加 特立尼达和多巴哥 美国 危地马拉 圣基茨和尼维斯",
1741
+ "南美洲": "乌拉圭 厄瓜多尔 哥伦比亚 巴西 智利 秘鲁 阿根廷",
1742
+ "非洲": "乌干达 加纳 南非 博茨瓦纳 坦桑尼亚 埃及 多哥 安哥拉 尼日利亚 布基纳法索 摩洛哥 肯尼亚 苏丹 赞比亚 马拉维 马里 阿尔及利亚 埃塞俄比亚 卢旺达 莱索托 埃斯瓦蒂尼 利比里亚 塞舌尔",
1743
+ "大洋洲": "新西兰 澳大利亚 斐济"
1744
+ };
1745
+ const REGION_OF = Object.fromEntries(Object.entries(SUPPORT_COUNTRIES).flatMap(([region, names]) =>
1746
+ names.split(" ").map((name) => [name, region])));
1747
+ const inChina = (s) => s.country === "中国" || CHINA_PLACES.includes(s.country);
1748
+ function supportRegion(s) {
1749
+ return inChina(s) ? "亚洲" : REGION_OF[s.country] || "其他";
1750
+ }
1751
+ function supportGroup(s) {
1752
+ return inChina(s) ? "中国" : s.country || "国家未注明";
1753
+ }
1754
+ // A country's part: a mainland school's province (Hong Kong, Macao and Taiwan their own), a US school's state or a UK
1755
+ // one's nation where Pro names them, else its kind for a country of more schools than BIG_COUNTRY (Germany's 382:
1756
+ // user, 2026-11-21, by kind until Pro names its states); "" for a country listed whole.
1757
+ const BIG_COUNTRY = 350;
1758
+ const KIND_ORDER = ["大学", "研究机构", "医院", "其他"];
1759
+ const UNSTATED = ["未注明省份", "未注明州", "未注明地区", "国家未注明"];
1760
+ function supportPartOf(country, list) {
1761
+ if (country === "中国") return (s) => s.country === "中国" ? s.province || "未注明省份" : s.country;
1762
+ if (list.some((s) => s.area)) return (s) => s.area || (country === "美国" ? "未注明州" : "未注明地区");
1763
+ if (list.length > BIG_COUNTRY && list.some((s) => s.kind)) return (s) => KIND_ORDER.includes(s.kind) ? s.kind : "其他";
1764
+ return null;
1765
+ }
1766
+ // China first; the most schools first; Hong Kong, Macao and Taiwan after the provinces; a kind in KIND_ORDER's order;
1767
+ // a place not given last.
1768
+ function supportOrder(entries) {
1769
+ const rank = (name) => name === "中国" ? -1 : CHINA_PLACES.includes(name) ? 1 : UNSTATED.includes(name) ? 2 : 0;
1770
+ const kinds = entries.every(([name]) => KIND_ORDER.includes(name));
1771
+ return entries.sort((a, b) => (rank(a[0]) - rank(b[0]))
1772
+ || (kinds ? KIND_ORDER.indexOf(a[0]) - KIND_ORDER.indexOf(b[0]) : b[1].length - a[1].length));
1773
+ }
1774
+ function groupBy(list, key) {
1775
+ const groups = new Map();
1776
+ for (const s of list) groups.set(key(s), [...(groups.get(key(s)) || []), s]);
1777
+ return supportOrder([...groups.entries()]);
1778
+ }
1779
+ function supportRows(list, where = null) {
1780
+ // Its name in the window's language (schoolName), wrapped when long; found by a search, where it is beside it (its
1781
+ // country, or its part of the country open).
1782
+ return list.map((s) => '<div class="login-found"><span class="ls-name">' + esc(schoolName(s))
1783
+ + (where && where(s) ? '<span class="ls-fed"> · ' + esc(where(s)) + "</span>" : "") + "</span>" + tagHtml(s.status) + "</div>").join("");
1784
+ }
1785
+ function supportRow(act, key, count, open) {
1786
+ return '<button type="button" class="row" data-act="' + act + '" data-key="' + esc(key) + '"'
1787
+ + (open === undefined ? "" : ' aria-expanded="' + open + '"') + '>'
1788
+ + '<span class="reason">' + esc(key) + '</span><span class="n">' + count + "</span>" + icon(open ? "down" : "right") + "</button>";
1789
+ }
1790
+ // A school in two federations (its country's and OpenAthens: a university of Beijing's listed twice; 91 such in Chinese,
1791
+ // 2026-11-21) listed once, by its country and its name as the window shows it; what Pro does for it the better of the
1792
+ // two. Counted once in the numbers too.
1793
+ const STATUS_RANK = { verified: 0, surveyed: 0, trial: 1, check: 2 };
1794
+ let supportOnce = { list: null, lang: "", schools: [] };
1795
+ function supportSchools() {
1796
+ const listed = (supportList && supportList.schools) || [];
1797
+ if (supportOnce.list !== listed || supportOnce.lang !== lang) {
1798
+ const kept = new Map(), rank = (s) => STATUS_RANK[s.status] ?? 3;
1799
+ for (const s of listed) {
1800
+ const key = s.country + "\n" + schoolName(s), there = kept.get(key);
1801
+ if (!there || rank(s) < rank(there)) kept.set(key, s);
1802
+ }
1803
+ supportOnce = { list: listed, lang, schools: [...kept.values()] };
1804
+ }
1805
+ return supportOnce.schools;
1806
+ }
1807
+ // The schools of the page open: a country's, by their names as the window shows them, in its language's order (pinyin
1808
+ // in Chinese, strokes in Traditional Chinese; China's mainland first, then Hong Kong, Macao and Taiwan), or all.
1809
+ function supportHere() {
1810
+ const all = supportSchools();
1811
+ if (!supportOpen) return all;
1812
+ let order;
1813
+ try { order = new Intl.Collator(lang); } catch (error) { order = new Intl.Collator(); }
1814
+ const place = (s) => supportOpen === "中国" ? CHINA_PLACES.indexOf(s.country) : 0;
1815
+ return all.filter((s) => supportGroup(s) === supportOpen).map((s) => [place(s), schoolName(s), s])
1816
+ .sort((a, b) => a[0] - b[0] || order.compare(a[1], b[1])).map(([, , s]) => s);
1817
+ }
1818
+ function supportListHtml() {
1819
+ const here = supportHere(), wanted = supportFilter.trim().toLowerCase();
1820
+ if (wanted) {
1821
+ // Found by any of its names, whatever the window's language, or its province's, state's or country's.
1822
+ const said = (s) => [s.name, s.name_en, ...Object.values(s.names || {}), s.province, s.area, s.country, tr(s.province || ""),
1823
+ tr(s.area || ""), tr(s.country || "")].join(" ").toLowerCase();
1824
+ const found = here.filter((s) => said(s).includes(wanted));
1825
+ const where = supportOpen ? supportPartOf(supportOpen, here) : (s) => s.country;
1826
+ return found.length ? supportRows(found.slice(0, 200), where) : '<div class="key-note">' + esc("没有符合的学校") + "</div>";
1827
+ }
1828
+ if (supportOpen) {
1829
+ // A big country's parts, each opening in place to its schools (several may be open), as the regions do.
1830
+ const part = supportPartOf(supportOpen, here);
1831
+ if (!part) return supportRows(here);
1832
+ return groupBy(here, part).map(([key, there]) => {
1833
+ const open = supportParts.has(key);
1834
+ return '<div class="support-region">' + supportRow("support_part", key, there.length, open)
1835
+ + (open ? '<div class="support-countries">' + supportRows(there) + "</div>" : "") + "</div>";
1836
+ }).join("");
1837
+ }
1838
+ return SUPPORT_REGIONS.map((region) => [region, here.filter((s) => supportRegion(s) === region)]).filter(([, list]) => list.length)
1839
+ .map(([region, list]) => {
1840
+ const open = supportRegions.has(region);
1841
+ return '<div class="support-region">' + supportRow("support_region", region, list.length, open)
1842
+ + (open ? '<div class="support-countries">' + groupBy(list, supportGroup)
1843
+ .map(([key, there]) => supportRow("support_group", key, there.length)).join("") + "</div>" : "") + "</div>";
1844
+ }).join("");
1845
+ }
1846
+ function settingsLoginSchools() {
1847
+ const here = supportList && supportList.ok ? supportHere() : [];
1848
+ const head = settingsHead(supportOpen || "支持的学校", supportOpen ? here.length + " 所" : "设置");
1849
+ if (!supportList) return head + '<div class="key-note">' + esc("读取中…") + "</div>";
1850
+ if (!supportList.ok) return head + '<div class="err" style="text-align:left">' + esc(supportList.error || "读取失败") + "</div>";
1851
+ const all = supportSchools();
1852
+ const filled = all.filter((s) => s.status === "surveyed" || s.status === "verified").length;
1853
+ const check = all.filter((s) => s.status === "check").length;
1854
+ // The numbers, each saying what it counts, on the first page only; the line explaining them was removed (user,
1855
+ // 2026-11-21).
1856
+ const stats = supportOpen ? "" : '<div class="stats" style="margin-top:10px"><div><b>' + filled + "</b><span>" + esc("所学校自动填写账号密码")
1857
+ + "</span></div><div><b>" + check + "</b><span>" + esc("所学校需自己登录") + "</span></div></div>";
1858
+ const hint = supportOpen ? "搜索学校" : "搜索学校或地区";
1859
+ return '<div class="support-top">' + head + stats
1860
+ + '<label class="support-search">' + icon("search") + '<input id="support-filter" type="search" autocomplete="off" spellcheck="false" value="'
1861
+ + esc(supportFilter) + '" placeholder="' + esc(hint) + '" aria-label="' + esc(hint) + '"></label></div>'
1862
+ + '<div id="support-list">' + supportListHtml() + "</div>";
1128
1863
  }
1129
1864
 
1130
1865
  // While an install runs, its progress is asked for a few times a second: the bar and its line
@@ -1136,35 +1871,28 @@ function watchProInstall() {
1136
1871
  let next;
1137
1872
  try { next = await api().pro_install_state(); } catch (error) { return; }
1138
1873
  proInstall = next || { state: "idle" };
1139
- if (proInstall.state === "running") return updateProProgress();
1874
+ if (proInstall.state === "running") return proActivating() ? undefined : updateProProgress();
1140
1875
  clearInterval(proInstallTimer);
1876
+ // Read again however it ended: an activation taken before a failed install is kept (重试, not the code again).
1877
+ const fresh = !(proStatus && proStatus.installed);
1878
+ try { proStatus = await api().pro_status(); } catch (error) { proStatus = null; }
1141
1879
  if (proInstall.state === "done") {
1142
- try { proStatus = await api().pro_status(); } catch (error) { proStatus = null; }
1143
1880
  proInstall = { state: "idle" };
1144
- proCheck = { state: "idle" }; // updated: what was found is installed now
1881
+ proCode = "";
1882
+ // Activated and installed (user, 2026-11-21): back on the home page, where its features are now.
1883
+ if (fresh && proStatus && proStatus.installed && panel === "settings" && ["about", "pro_activate"].includes(settingsPage)) {
1884
+ settingsPage = "home"; settingsNote = "PaperSearch Pro 已安装";
1885
+ }
1145
1886
  }
1146
1887
  // Not over another settings page, where something may be being typed.
1147
- if (panel === "settings" && ["home", "pro", "markdown"].includes(settingsPage)) render(true);
1888
+ if (panel === "settings" && ["home", "about", "pro_activate", "markdown"].includes(settingsPage)) render(true);
1148
1889
  }, 300);
1149
1890
  }
1150
1891
 
1151
- // 检查更新 runs a few seconds: asked for until it is done, then the page is drawn again.
1152
- function watchProCheck() {
1153
- clearInterval(proCheckTimer);
1154
- if (proCheck.state !== "running") return;
1155
- proCheckTimer = setInterval(async () => {
1156
- let next;
1157
- try { next = await api().pro_check_state(); } catch (error) { return; }
1158
- proCheck = next || { state: "idle" };
1159
- if (proCheck.state === "running") return;
1160
- clearInterval(proCheckTimer);
1161
- if (panel === "settings" && settingsPage === "pro") render(true);
1162
- }, 400);
1163
- }
1164
1892
 
1165
1893
  function updateProProgress() {
1166
1894
  const bar = root.querySelector(".pro-bar span"), line = root.querySelector("#pro-progress");
1167
- if (!bar || !line) return panel === "settings" && settingsPage === "pro" ? render(true) : undefined;
1895
+ if (!bar || !line) return panel === "settings" && ["about", "pro_activate"].includes(settingsPage) ? render(true) : undefined;
1168
1896
  const progress = proProgress();
1169
1897
  bar.style.width = progress.width.toFixed(1) + "%";
1170
1898
  line.textContent = tr(progress.note);
@@ -1208,7 +1936,9 @@ function holdSettingsHeight() {
1208
1936
 
1209
1937
  function settingsCard() {
1210
1938
  const page = { download: settingsDownload, wait: settingsWait, keys: settingsKeys,
1211
- ...(proOn() ? { pro: settingsPro, markdown: settingsMarkdown, login: settingsLogin } : {}) }[settingsPage] || settingsHome;
1939
+ about: settingsAbout,
1940
+ ...(proOn() ? { pro_activate: settingsProActivate, markdown: settingsMarkdown, login: settingsLogin,
1941
+ login_schools: settingsLoginSchools } : {}) }[settingsPage] || settingsHome;
1212
1942
  return '<div class="card-body settings">' + page() + "</div>";
1213
1943
  }
1214
1944
 
@@ -1288,8 +2018,10 @@ async function loadSettings() {
1288
2018
 
1289
2019
  async function openSettings(request) {
1290
2020
  await loadSettings();
1291
- panel = "settings"; open = true; settingsNote = ""; confirmClear = ""; revealed = false;
1292
- settingsPage = SETTINGS_PAGES.includes(request.page) && (!PRO_PAGES.includes(request.page) || proOn()) ? request.page : "home";
2021
+ panel = "settings"; open = true; settingsNote = ""; confirmClear = ""; revealed = false; languageOpen = false;
2022
+ const asked = pageNamed(request.page);
2023
+ settingsPage = SETTINGS_PAGES.includes(asked) && (!PRO_PAGES.includes(asked) || proOn()) ? asked : "home";
2024
+ refreshVersions();
1293
2025
  editing = settingsPage === "keys" ? request.service || "" : "";
1294
2026
  editValues = editing ? await savedValues(editing) : {};
1295
2027
  loginShown = false;
@@ -1354,12 +2086,18 @@ function render(force) {
1354
2086
  // Keep the real button (and its pointer/focus target) through countdown ticks.
1355
2087
  if (unchanged && (!attention || !updateAttentionCountdown())) return;
1356
2088
  const previous = root.getBoundingClientRect();
2089
+ // Read before the height it scrolls in is taken off, which puts it back at its top.
2090
+ const scrolledTo = surfaceTop();
1357
2091
  root.style.width = ""; root.style.height = "";
1358
2092
  root.style.removeProperty("--content-max-height");
1359
2093
  if (!unchanged) {
1360
2094
  // A scrolled list keeps its place while its page is redrawn (a key opened or saved, a group opened).
1361
2095
  const place = panel + ":" + (panel === "settings" ? settingsPage : papersKind);
1362
2096
  const scrolled = place === lastPlace ? root.querySelector(".papers-scroll, .keys-scroll")?.scrollTop || 0 : 0;
2097
+ // The page itself scrolled (支持的学校's long list) keeps its place too (user, 2026-11-21: a press on the card's
2098
+ // background, which starts and ends a drag, drew it again at its top), put back once it scrolls (keepSupportPlace).
2099
+ if (pageScroll !== null) { keepScroll = pageScroll || null; pageScroll = null; }
2100
+ else if (place === lastPlace && scrolledTo > 0) keepScroll = scrolledTo;
1363
2101
  lastPlace = place;
1364
2102
  root.className = cls + " capsule-drag-region" + (cls !== lastCls ? " fade" : "");
1365
2103
  root.innerHTML = '<div class="surface">' + html + "</div>";
@@ -1373,6 +2111,17 @@ function render(force) {
1373
2111
  lastHtml = html;
1374
2112
  lastCls = cls;
1375
2113
  fit(previous);
2114
+ keepSupportPlace(!root.classList.contains("animating"));
2115
+ }
2116
+
2117
+ // The page stays where it was scrolled when drawn again (keepScroll). A page taller than the screen scrolls only once the
2118
+ // window has its size: the native resize (animateFit) sets the height it scrolls in, after the page was drawn anew at
2119
+ // its top, so it is put back then, and again when the resize ends; a page whose window does not change, at once.
2120
+ function keepSupportPlace(last) {
2121
+ if (keepScroll === null) return;
2122
+ const surface = root.querySelector(":scope > .surface");
2123
+ if (surface && surface.scrollHeight > surface.clientHeight) surface.scrollTop = keepScroll;
2124
+ if (last) keepScroll = null;
1376
2125
  }
1377
2126
 
1378
2127
  let fitGeneration = 0, layoutQueue = Promise.resolve();
@@ -1414,6 +2163,7 @@ async function animateFit(generation, expanded, from, to, pad) {
1414
2163
  const border = document.body.classList.contains("mac") ? 1 : 0;
1415
2164
  root.style.setProperty("--content-max-height", Math.max(0, to[1] - border) + "px");
1416
2165
  root.firstElementChild.style.width = Math.max(0, to[0] - border) + "px";
2166
+ keepSupportPlace(false);
1417
2167
  const duration = matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 240;
1418
2168
  const started = performance.now();
1419
2169
  // One outstanding native resize at a time; a newer layout cancels this animation.
@@ -1433,6 +2183,7 @@ async function animateFit(generation, expanded, from, to, pad) {
1433
2183
  if (generation === fitGeneration) {
1434
2184
  root.classList.remove("animating");
1435
2185
  settledGeneration = generation; settledSize = to; settledExpanded = expanded;
2186
+ keepSupportPlace(true);
1436
2187
  }
1437
2188
  }
1438
2189
  observeHover();
@@ -1465,8 +2216,16 @@ async function act(action, target) {
1465
2216
  switch (action) {
1466
2217
  // Back as a capsule when restored, unless pinned: a pinned card comes back open (user, 2026-11-20:
1467
2218
  // on Windows, minimized and restored, the pinned card had shrunk to the capsule).
1468
- case "minimize": if (!pinned) open = false; panel = ""; render(true); return api().minimize();
1469
- case "close": closing = true; ++fitGeneration; clearInterval(pollTimer); clearInterval(proInstallTimer); clearTimeout(hoverTimer); clearTimeout(leaveTimer); return api().request_close(); // no call left waiting on a closed page
2219
+ case "minimize": {
2220
+ if (!pinned) open = false;
2221
+ panel = ""; minimizing = true;
2222
+ render(true);
2223
+ // Folded to the capsule before it goes into the Dock or the taskbar (user, 2026-11-21): minimized while it
2224
+ // still shrank, the window went at the card's size, and brought back showed the card a moment first.
2225
+ await layoutQueue;
2226
+ try { return await api().minimize(); } finally { setTimeout(() => { minimizing = false; }, 400); }
2227
+ }
2228
+ case "close": closing = true; ++fitGeneration; clearInterval(pollTimer); clearInterval(proInstallTimer); clearInterval(testTimer); clearInterval(versionTimer); clearInterval(updateTimer); clearTimeout(hoverTimer); clearTimeout(leaveTimer); return api().request_close(); // no call left waiting on a closed page
1470
2229
  case "folder": return api().open_folder();
1471
2230
  case "expand": open = true; panel = ""; return render(true);
1472
2231
  case "pin":
@@ -1518,18 +2277,38 @@ async function act(action, target) {
1518
2277
  return say(said);
1519
2278
  }
1520
2279
  case "settings": return openSettings({ page: "home" });
2280
+ case "language_menu":
2281
+ languageOpen = !languageOpen;
2282
+ render(true);
2283
+ return root.querySelector(languageOpen ? ".lang-menu [aria-checked=true]" : ".lang-btn")?.focus();
1521
2284
  case "language": {
2285
+ languageOpen = false;
1522
2286
  const result = await api().set_language(target.dataset.lang);
1523
2287
  if (result.ok) lang = result.language;
1524
2288
  return render(true);
1525
2289
  }
1526
2290
  case "settings_page":
1527
- settingsPage = target.dataset.page; settingsErrors = {}; settingsDraft = {}; settingsNote = ""; editing = ""; editValues = {};
1528
- loginError = ""; loginDone = ""; confirmClear = ""; loginShown = false;
1529
- if (settingsPage === "login") await loadLoginValues();
2291
+ settingsPage = pageNamed(target.dataset.page); settingsErrors = {}; settingsDraft = {}; settingsNote = ""; editing = ""; editValues = {};
2292
+ loginError = ""; loginDone = ""; confirmClear = ""; loginShown = false; languageOpen = false;
2293
+ if (settingsPage === "login") {
2294
+ // The default school open first; 添加学校 starts empty.
2295
+ loginOpen = ((schoolLogin && schoolLogin.schools) || []).find((s) => s.current)?.key || "";
2296
+ schoolQuery = ""; schoolFound = null; confirmForget = ""; await loadLoginValues();
2297
+ loginAdding = !loginOpen; // no school yet: straight to finding one
2298
+ }
2299
+ if (settingsPage === "login_schools") {
2300
+ supportFilter = ""; supportOpen = ""; supportRegions = new Set(); supportParts = new Set(); supportBack = 0; supportList = null; render(true);
2301
+ try { supportList = await api().school_support_list(); } catch (error) { supportList = { ok: false, error: "读取失败" }; }
2302
+ }
1530
2303
  return render(true);
1531
2304
  case "back":
1532
2305
  if (panel !== "settings") { panel = ""; return render(true); }
2306
+ languageOpen = false;
2307
+ if (settingsPage === "login_schools" && supportOpen) {
2308
+ // From a country's page to the regions', where it was.
2309
+ supportOpen = ""; supportParts = new Set(); supportFilter = ""; pageScroll = supportBack || 0;
2310
+ return render(true);
2311
+ }
1533
2312
  if (settingsPage === "home") return leaveSettings();
1534
2313
  settingsPage = parentPage(settingsPage); editing = ""; editValues = {}; settingsErrors = {}; settingsDraft = {};
1535
2314
  loginError = ""; confirmClear = ""; return render(true);
@@ -1551,15 +2330,22 @@ async function act(action, target) {
1551
2330
  render(true);
1552
2331
  return watchProInstall();
1553
2332
  }
1554
- case "check_pro": {
1555
- try { proCheck = (await api().check_pro()) || { state: "idle" }; }
1556
- catch (error) { proCheck = { state: "failed", message: "检查更新出错" }; }
2333
+ case "activate_pro": {
2334
+ // 激活 (user, 2026-11-21): the code to the activation server, then the install.
2335
+ const code = proCode.trim();
2336
+ if (!code) { proCodeError = "请输入激活码"; render(true); return root.querySelector("#pro-code")?.focus(); }
2337
+ proCodeError = "";
2338
+ try { proInstall = (await api().install_pro(code)) || { state: "idle" }; }
2339
+ catch (error) { proInstall = { state: "failed", step: "activate", message: "激活出错" }; }
1557
2340
  render(true);
1558
- return watchProCheck();
2341
+ return watchProInstall();
1559
2342
  }
1560
2343
  case "pro_sites":
1561
2344
  proSitesOpen = !proSitesOpen;
1562
2345
  return render(true);
2346
+ case "pro_merits":
2347
+ proMeritsOpen = !proMeritsOpen;
2348
+ return render(true);
1563
2349
  case "pro_issue": {
1564
2350
  const result = await api().open_issue();
1565
2351
  if (!result.ok) { settingsNote = result.message; render(true); }
@@ -1583,17 +2369,135 @@ async function act(action, target) {
1583
2369
  }
1584
2370
  case "save_login": case "clear_login": case "login_switch": {
1585
2371
  if (action === "clear_login" && confirmClear !== "login") { confirmClear = "login"; return render(true); }
1586
- const user = root.querySelector("#login-user"), password = root.querySelector("#login-password");
1587
- const result = action === "clear_login" ? await api().clear_school_login()
1588
- : action === "login_switch" ? await api().save_school_login("", "", !schoolLogin.enabled)
1589
- : await api().save_school_login(user ? user.value : "", password ? password.value : "", true);
2372
+ const school = ((schoolLogin && schoolLogin.schools) || []).find((s) => s.key === loginOpen) || {};
2373
+ const result = action === "clear_login" ? await api().clear_school_login(loginOpen)
2374
+ : action === "login_switch" ? await api().save_school_login("", "", !school.enabled, loginOpen)
2375
+ : await api().save_school_login(loginValues.username || "", loginValues.password || "", true, loginOpen);
1590
2376
  confirmClear = "";
1591
2377
  if (!result.ok) { loginError = result.error || "保存失败"; loginDone = ""; return render(true); }
2378
+ schoolLogin = result; loginError = ""; loginDone = "";
2379
+ if (action === "save_login") {
2380
+ loginSaved = true;
2381
+ clearTimeout(loginSavedTimer);
2382
+ // Back to "保存" in place: drawing the page again would move the cursor of someone typing.
2383
+ loginSavedTimer = setTimeout(() => {
2384
+ loginSaved = false;
2385
+ const button = root.querySelector('[data-act="save_login"]');
2386
+ if (button) button.textContent = tr("保存");
2387
+ }, 2000);
2388
+ }
2389
+ await loadLoginValues(); return render(true);
2390
+ }
2391
+ case "school_test": {
2392
+ // The test uses the account as saved: fields changed since are saved first.
2393
+ loginError = ""; loginDone = "";
2394
+ if ((loginValues.username || "") !== (loginSavedValues.username || "") || (loginValues.password || "") !== (loginSavedValues.password || "")) {
2395
+ const saved = await api().save_school_login(loginValues.username || "", loginValues.password || "", true, loginOpen);
2396
+ if (!saved.ok) { loginError = saved.error || "保存失败"; return render(true); }
2397
+ schoolLogin = saved; loginSavedValues = { ...loginValues };
2398
+ }
2399
+ if (testEditing && testArticleText.trim()) {
2400
+ // An article typed and not yet taken: taken first, or why not said.
2401
+ await act("test_article_save");
2402
+ if (testEditing) return;
2403
+ }
2404
+ if (!testArticle || !testArticle.doi) {
2405
+ // None filled in: its box opened for one.
2406
+ testEditing = true; testArticleError = "先填测试文章"; render(true);
2407
+ return root.querySelector("#test-article")?.focus();
2408
+ }
2409
+ const started = await api().start_school_test(loginOpen, testArticle ? testArticle.doi : "");
2410
+ if (started.error) { loginError = started.error; return render(true); }
2411
+ schoolTest = started; watchSchoolTest();
2412
+ return render(true);
2413
+ }
2414
+ case "school_switch": {
2415
+ let answer;
2416
+ try { answer = await api().set_school_switch(!(schoolLogin && schoolLogin.switch !== false)); } catch (error) { answer = null; }
2417
+ if (answer && answer.ok) schoolLogin = answer;
2418
+ else { loginError = (answer && answer.error) || "保存失败"; }
2419
+ return render(true);
2420
+ }
2421
+ case "check_versions":
2422
+ versionCheck = { state: "running" }; render(true);
2423
+ return checkVersions(true);
2424
+ case "update_all": {
2425
+ let started;
2426
+ try { started = await api().update_all(); } catch (error) { started = { state: "idle", error: "更新出错" }; }
2427
+ if (started && started.error) { settingsNote = started.error; return render(true); }
2428
+ updateRun = started || { state: "idle" }; settingsNote = "";
2429
+ watchUpdate();
2430
+ return render(true);
2431
+ }
2432
+ case "release_notes": {
2433
+ const answer = await api().open_release_notes();
2434
+ if (answer && !answer.ok) say(answer.message);
2435
+ return;
2436
+ }
2437
+ case "reopen_window": {
2438
+ const answer = await api().reopen_window(settingsPage === "about" ? "about" : "home");
2439
+ if (answer && !answer.ok) { settingsNote = answer.message; render(true); }
2440
+ return;
2441
+ }
2442
+ case "school_test_stop":
2443
+ schoolTest = await api().stop_school_test();
2444
+ return render(true);
2445
+ case "test_article_edit":
2446
+ testEditing = true; testArticleError = ""; testArticleText = (testArticle && testArticle.doi) || "";
2447
+ render(true);
2448
+ return root.querySelector("#test-article")?.focus();
2449
+ case "test_article_save": {
2450
+ // By its DOI or its page's address, the DOI looked up (school_test.doi_of); emptied, none.
2451
+ testArticleSaving = true; testArticleError = ""; render(true);
2452
+ let answer;
2453
+ try { answer = await api().set_school_test_article(loginOpen, testArticleText); } catch (error) { answer = { ok: false, error: "保存失败" }; }
2454
+ testArticleSaving = false;
2455
+ if (answer && answer.ok) { testArticle = answer; testEditing = false; } else testArticleError = (answer && answer.error) || "保存失败";
2456
+ return render(true);
2457
+ }
2458
+ case "support_region": case "support_part": {
2459
+ // Its countries (a country's part: its schools) shown or hidden in place, the page where it was; the others left
2460
+ // as they are.
2461
+ const open = action === "support_region" ? supportRegions : supportParts, key = target.dataset.key;
2462
+ if (!open.delete(key)) open.add(key);
2463
+ return render(true);
2464
+ }
2465
+ case "support_group":
2466
+ // The country's page, at its top, its parts closed; where the regions' page was kept for coming back.
2467
+ supportBack = surfaceTop(); supportOpen = target.dataset.key; supportParts = new Set(); supportFilter = ""; pageScroll = 0;
2468
+ return render(true);
2469
+ case "login_add": {
2470
+ loginAdding = !loginAdding; schoolFound = null; loginError = "";
2471
+ render(true);
2472
+ if (loginAdding) root.querySelector("#school-query")?.focus();
2473
+ return;
2474
+ }
2475
+ case "login_open": {
2476
+ loginOpen = loginOpen === target.dataset.key ? "" : target.dataset.key;
2477
+ loginError = ""; loginDone = ""; confirmClear = ""; confirmForget = ""; loginShown = false; loginSaved = false;
2478
+ await loadLoginValues(); return render(true);
2479
+ }
2480
+ case "set_default": case "forget_school": case "add_school": {
2481
+ const key = target.dataset.key;
2482
+ if (action === "forget_school" && confirmForget !== key) { confirmForget = key; return render(true); }
2483
+ // Said at once, the school found kept for it (user, 2026-11-20: the page seemed stuck once 添加 was pressed).
2484
+ if (action === "add_school") { target.disabled = true; target.textContent = tr("添加中…"); }
2485
+ const result = action === "set_default" ? await api().set_default_school(key)
2486
+ : action === "forget_school" ? await api().forget_school(key) : await api().add_school(key);
2487
+ confirmForget = "";
2488
+ if (!result.ok) { loginError = result.error || "没有完成"; loginDone = ""; return render(true); }
1592
2489
  schoolLogin = result; loginError = "";
1593
- loginDone = action === "clear_login" ? "已清除" : action === "login_switch"
1594
- ? (result.enabled ? "已打开自动登录" : "已关闭自动登录") : "已保存";
2490
+ if (action === "add_school") { loginOpen = key; schoolQuery = ""; schoolFound = null; loginAdding = false; loginDone = "已添加,请填账号和密码"; }
2491
+ else if (action === "forget_school") { loginOpen = ""; loginDone = ""; }
2492
+ else loginDone = ""; // its 默认 tag says so
1595
2493
  await loadLoginValues(); return render(true);
1596
2494
  }
2495
+ case "find_school": {
2496
+ if (!schoolQuery.trim()) { schoolFound = { ok: false, error: "请输入学校名称" }; return render(true); }
2497
+ schoolFinding = true; schoolFound = null; render(true);
2498
+ try { schoolFound = await api().find_school(schoolQuery); } catch (error) { schoolFound = { ok: false, error: "查找失败" }; }
2499
+ schoolFinding = false; return render(true);
2500
+ }
1597
2501
  case "login_reveal": {
1598
2502
  loginShown = !loginShown;
1599
2503
  target.setAttribute("aria-pressed", String(loginShown));
@@ -1681,8 +2585,9 @@ async function act(action, target) {
1681
2585
  }
1682
2586
  }
1683
2587
 
1684
- // A paper list scrolls; pressing in it must not drag the window.
1685
- const interactive = (target) => target.closest('button, input, select, textarea, a, [contenteditable="true"], [role="button"], .paper-list, .papers-scroll, .keys-scroll');
2588
+ // A paper list scrolls; pressing in it must not drag the window. Nor in 支持的学校's list (user, 2026-11-21: a press
2589
+ // between its rows dragged, and the redraw after it went back to the top).
2590
+ const interactive = (target) => target.closest('button, input, select, textarea, a, [contenteditable="true"], [role="button"], .paper-list, .papers-scroll, .keys-scroll, #support-list');
1686
2591
  // The dot's card: open while the pointer is on the dot or the card, a moment's grace between
1687
2592
  // them. Told by where the pointer moves, not by its leaving: the card is redrawn every second
1688
2593
  // and a dot redrawn under the pointer never says it was left.
@@ -1762,11 +2667,45 @@ root.addEventListener("input", (event) => {
1762
2667
  if (input.dataset.field) settingsDraft[input.dataset.field] = input.value;
1763
2668
  else if (input.id === "download-dir") settingsDraft.download_dir = input.value;
1764
2669
  else if (input.dataset.key && editing) editValues[input.dataset.key] = input.value;
2670
+ // The sign-in page's fields and 添加学校 (user, 2026-11-20: a click elsewhere had emptied them).
2671
+ else if (input.id === "login-user") loginValues.username = input.value;
2672
+ else if (input.id === "login-password") loginValues.password = input.value;
2673
+ else if (input.id === "school-query") schoolQuery = input.value;
2674
+ else if (input.id === "test-article") { testArticleText = input.value; testArticleError = ""; }
2675
+ else if (input.id === "pro-code") {
2676
+ proCode = input.value;
2677
+ // Typing again clears why the last code was not taken.
2678
+ if (proCodeError || (proInstall.state === "failed" && proActivating())) {
2679
+ proCodeError = "";
2680
+ if (proInstall.state === "failed") proInstall = { state: "idle" };
2681
+ root.querySelector(".pro-code-err")?.remove();
2682
+ }
2683
+ }
2684
+ else if (input.id === "support-filter") {
2685
+ supportFilter = input.value;
2686
+ const box = root.querySelector("#support-list");
2687
+ if (box) { box.innerHTML = supportListHtml(); localize(box); }
2688
+ }
1765
2689
  });
1766
2690
  root.addEventListener("click", (event) => {
1767
2691
  const target = event.target.closest("[data-act]");
1768
2692
  if (target) { event.stopPropagation(); act(target.dataset.act, target); }
1769
2693
  });
2694
+ // The language menu closes on a press anywhere else, taken off at once: a press on the card's background starts
2695
+ // the window's drag, while which the page is not drawn again.
2696
+ document.addEventListener("pointerdown", (event) => {
2697
+ if (languageOpen && !event.target.closest(".lang-wrap")) closeLanguageMenu();
2698
+ }, true);
2699
+ function closeLanguageMenu() {
2700
+ languageOpen = false;
2701
+ root.querySelector(".lang-menu")?.remove();
2702
+ const button = root.querySelector(".lang-btn");
2703
+ if (!button) return;
2704
+ button.setAttribute("aria-expanded", "false");
2705
+ button.lastElementChild.outerHTML = icon("down");
2706
+ }
2707
+ // While the card folds to go into the Dock, the pointer still on it does not open it again.
2708
+ let minimizing = false;
1770
2709
  function setHover(inside, force = false) {
1771
2710
  // Minimize/task transitions can fold the card while the pointer stays inside.
1772
2711
  if (!force && hovering === inside && (!inside || open)) return;
@@ -1774,7 +2713,7 @@ function setHover(inside, force = false) {
1774
2713
  clearTimeout(hoverTimer); clearTimeout(leaveTimer);
1775
2714
  if (dragging || attentionPointer !== null) return;
1776
2715
  if (inside) {
1777
- hoverTimer = setTimeout(() => { if (!open) { open = true; render(true); } }, 100);
2716
+ hoverTimer = setTimeout(() => { if (!open && !minimizing) { open = true; render(true); } }, 100);
1778
2717
  } else {
1779
2718
  // Leave enough time to cross the edge; open menus and settings stay usable.
1780
2719
  leaveTimer = setTimeout(() => { if (!panel && !pinned) { open = false; render(true); } }, 280);
@@ -1817,12 +2756,17 @@ window.addEventListener("pointercancel", endAttentionPress);
1817
2756
  window.addEventListener("blur", endAttentionPress);
1818
2757
  document.addEventListener("keydown", (event) => {
1819
2758
  if (event.key === "Escape" && panel) {
2759
+ if (languageOpen) { closeLanguageMenu(); return root.querySelector(".lang-btn")?.focus(); }
2760
+ // Its box closed, the article as it was.
2761
+ if (testEditing && event.target.id === "test-article") { testEditing = false; testArticleError = ""; return render(true); }
1820
2762
  if (panel !== "settings") { panel = ""; render(true); }
1821
2763
  else act(editing ? "cancel_key" : "back");
1822
2764
  }
1823
2765
  if (event.key === "Enter" && panel === "settings" && event.target.tagName === "INPUT") {
1824
2766
  if (settingsPage === "keys" && editing) act("save_key", { dataset: { service: editing }, textContent: "" });
1825
2767
  else if (settingsPage === "download" || settingsPage === "wait") act("save");
2768
+ else if (settingsPage === "login") act(event.target.id === "school-query" ? "find_school" : event.target.id === "test-article" ? "test_article_save" : "save_login", { dataset: {} });
2769
+ else if (["about", "pro_activate"].includes(settingsPage) && event.target.id === "pro-code") act("activate_pro");
1826
2770
  }
1827
2771
  });
1828
2772
 
@@ -1831,6 +2775,8 @@ window.addEventListener("pywebviewready", async () => {
1831
2775
  document.body.classList.add(platform === "darwin" ? "mac" : platform === "win32" ? "win" : "other");
1832
2776
  await tick();
1833
2777
  pollTimer = setInterval(tick, 500);
2778
+ setTimeout(() => checkVersions(), 3000);
2779
+ setInterval(() => checkVersions(), 6 * 3600 * 1000);
1834
2780
  });
1835
2781
  </script>
1836
2782
  </body>