options.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!doctype html>
  2. <html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Teams 本地记录助手 · 设置</title><link rel="stylesheet" href="style.css"></head>
  3. <body><main class="settings">
  4. <header><span class="eyebrow">TEAMS → LOCAL</span><h1>让工作记录留在本地</h1><p>使用已有的公司或学校账号登录 Teams,无需注册应用。采集已加载的聊天和日历,也可开启独立标签自动遍历聊天。</p></header>
  5. <section class="card"><h2>1. 登录并准备本地服务</h2><p>启动项目的本地服务,在控制台复制“扩展配对令牌”。然后打开 Teams,由 Microsoft 处理密码、公司单点登录和多重验证。</p><div class="actions"><button id="login" type="button">打开 Teams 登录</button><button id="dashboard" type="button" class="secondary">打开本地控制台</button></div></section>
  6. <form id="settings-form">
  7. <section class="card"><h2>2. 配对与账号标识</h2>
  8. <label for="account">唯一账号标签</label><input id="account" name="account" maxlength="100" placeholder="例如:contoso-工作账号" autocomplete="off"><p class="hint">这是本地数据隔离标识,不是登录凭据。扩展不会推断账号。一个浏览器配置请仅采集一个 Teams 账号;切换账号前先暂停,再改为不同标签。已有记录不会改名。</p>
  9. <label for="token">本地服务配对令牌</label><input id="token" name="token" type="password" maxlength="512" autocomplete="off" spellcheck="false"><p class="hint">仅用于写入本地服务,存于此浏览器的扩展设置中,不交给 Teams 页面。这里无需填写 Microsoft 密码或访问令牌。</p>
  10. <label for="port">本地服务端口</label><div class="endpoint"><span>http://127.0.0.1:</span><input id="port" name="port" type="number" min="1024" max="65535" value="4318" required></div>
  11. <div class="actions"><button id="ping" class="secondary" type="button">测试连接</button></div>
  12. </section>
  13. <section class="card"><h2>3. 开启采集</h2><label class="toggle"><input type="checkbox" id="enabled"> 启用此账号的可见页面采集</label><p class="hint">默认关闭。开启后,页面变化约 1 秒内触发采集,每 20 秒发送一次心跳。浏览器后台节流或本地服务未启动时会延迟。</p><label class="toggle"><input type="checkbox" id="activity"> 同时尝试记录可见活动项(实验性,可关闭)</label></section>
  14. <section class="card"><h2>4. 自动遍历聊天</h2>
  15. <label class="toggle"><input type="checkbox" id="automation-enabled"> 启用独立后台标签自动采集聊天</label>
  16. <p class="notice">自动打开聊天可能改变未读状态,并触发已读回执。默认关闭,保存后生效。扩展会新建一个后台 Teams 标签,不切换您正在使用的聊天页。</p>
  17. <div class="field-grid">
  18. <div><label for="automation-interval">每轮完成后等待(秒)</label><input id="automation-interval" type="number" min="30" max="3600" value="120" required></div>
  19. <div><label for="automation-dwell">聊天加载稳定时间(秒)</label><input id="automation-dwell" type="number" min="2" max="30" value="4" required></div>
  20. <div><label for="automation-max">每轮最多聊天数</label><input id="automation-max" type="number" min="1" max="200" value="50" required></div>
  21. <div><label for="automation-list-scroll">聊天列表最多滚动次数</label><input id="automation-list-scroll" type="number" min="0" max="30" value="8" required></div>
  22. <div><label for="automation-history-scroll">每个聊天向上加载历史次数</label><input id="automation-history-scroll" type="number" min="0" max="20" value="2" required></div>
  23. </div>
  24. <p class="hint">只遍历当前聊天列表能发现的会话,不保证完整历史。请保持采集标签和本地服务打开。操作采集标签会暂停遍历;关闭它、离开 Teams、暂停主采集或更改账号标签会停止自动采集。后台休眠可能延迟采集。</p>
  25. <p id="automation-status" role="status">自动采集尚未开启</p>
  26. <div class="actions"><button id="automation-start" type="button">保存并启动自动采集</button><button id="automation-stop" class="secondary" type="button">停止自动采集</button></div>
  27. <details class="automation-adapter"><summary>聊天列表适配</summary>
  28. <p class="hint">默认候选未识别到聊天时,可指定聊天行、聊天列表滚动容器和消息列表滚动容器。请使用具体容器,避免整个页面或菜单按钮。</p>
  29. <label for="chat-item-selector">聊天行选择器</label><textarea id="chat-item-selector" rows="2" maxlength="2000" spellcheck="false"></textarea>
  30. <label for="chat-list-selector">聊天列表滚动容器选择器</label><textarea id="chat-list-selector" rows="2" maxlength="2000" spellcheck="false"></textarea>
  31. <label for="message-list-selector">消息列表滚动容器选择器</label><textarea id="message-list-selector" rows="2" maxlength="2000" spellcheck="false"></textarea>
  32. <button id="preview-chats" class="secondary" type="button">预览能发现的聊天</button><pre id="chat-preview-result" aria-live="polite">尚未预览;预览不会打开聊天或写入数据库</pre>
  33. </details>
  34. </section>
  35. <section class="card"><h2>页面连接</h2><p id="connection" role="status">正在检查 Teams 页面…</p><button id="reconnect" class="secondary" type="button">重新连接页面</button><p class="hint">安装或重新加载扩展后,可直接连接已经打开的 Teams 标签。此按钮使用已保存设置。</p></section>
  36. <details class="card"><summary>高级:页面适配与选择器预览</summary><p>Teams 页面结构会更新。如果已经打开聊天/日历但记录数为 0,可填写具体消息或事件容器的 CSS 选择器。留空使用默认候选。不能选择 body、main 或整个列表。预览会显示最近使用的 Teams 页面的前 5 条,不会写入本地数据库。</p>
  37. <label for="message-selector">聊天消息选择器</label><textarea id="message-selector" rows="3" maxlength="2000" spellcheck="false"></textarea>
  38. <label for="event-selector">日历事件选择器</label><textarea id="event-selector" rows="3" maxlength="2000" spellcheck="false"></textarea>
  39. <label for="activity-selector">活动项选择器</label><textarea id="activity-selector" rows="2" maxlength="2000" spellcheck="false"></textarea>
  40. <button id="preview" class="secondary" type="button">预览当前匹配</button><pre id="preview-result" aria-live="polite">尚未预览</pre>
  41. </details>
  42. <div class="actions"><button type="submit">保存设置</button><span id="feedback" role="status" aria-live="polite"></span></div>
  43. </form>
  44. <section class="card limits"><h2>采集范围</h2><p>手动模式采集您打开的聊天或日历;自动模式只在专用标签中按上方限额遍历聊天。未加载历史、折叠内容、附件文件和隐藏事件不会被收集,也不能据此判断消息是否被删除。日历仍需手动打开。若日历被放在独立 Outlook 跨域框架中,本版本无法读取,预览为 0 不代表没有事件。</p><p>有稳定页面 ID 时可识别内容更新;缺少 ID 时使用“内容 + 会话”摘要,编辑可能成为新记录,相同内容也可能合并。只有明确日期、时间和时区才会生成标准时间,其他时间文字保留原文。</p><p>网络失败最多立即重试 3 次,此后随心跳重试;未发出的记录暂留在当前页面内存中(最多 1000 条),关闭或刷新页面会丢失这一队列。自动模式发送失败时暂停遍历,恢复服务后可重新启动。公司浏览器策略可能限制扩展安装。</p></section>
  45. </main><script type="module" src="options.js"></script></body></html>