feat(nav): auto-detect browser extension and offer one-click install

导航页现在会自动检测浏览历史插件是否已安装:

- 扩展在用户配置的服务地址上动态注册 content script
  (Chrome: chrome.scripting.registerContentScripts,
   Firefox: browser.contentScripts.register),
  于 document_start 给 <html> 打上 data-navi-ext 标记,
  不在其他站点运行。
- history-server 始终把「安装浏览历史插件」放在「历史访问」第一条
  (入口 url=/extension/install.html),启动时也会重建一次,
  不再需要等下一次同步。
- web/navi.js 读到标记后隐藏该入口(连 .item-wrapper 一起隐藏,
  避免留下空网格位)。
- 新增 /extension/install.html:自动识别浏览器,给出对应安装包与步骤;
  支持在 data 卷放 extension-store.json 配置商店链接,
  有商店链接时显示真正的「一键安装」。
- 段落名匹配同时兼容中英文(常用服务/Favorites、历史访问/History),
  修掉了公开示例 conf.yml 用英文名时重建逻辑完全失效的问题。
- 扩展升到 1.1.0(新增 scripting 权限与 detect.js)。

Note: Chrome/Edge 不允许从网站直接安装非商店扩展,
因此自托管场景下只能下载后手动加载;发布到商店后才会出现一键安装。
This commit is contained in:
JianFeeeee
2026-09-11 10:41:10 +08:00
parent 88e23861fe
commit ff0e6418f8
14 changed files with 440 additions and 45 deletions

View File

@ -22,8 +22,9 @@ pageInfo:
footer: ""
sections:
- name: Code Hosting
icon: fas fa-code-branch
# 名称必须是 Favorites / 常用服务 —— 服务端会把访问量最高的 4 个导航写到这里
- name: Favorites
icon: fas fa-star
collapsed: false
items:
- title: Gitea
@ -32,14 +33,17 @@ sections:
url: http://192.168.1.100:3000
statusCheck: true
# 名称必须是 History / 历史访问 ——
# 服务端会把插件安装入口固定放在第一条,其余按访问频次填充。
# 插件已安装的浏览器由 /navi.js 自动隐藏该入口。
- name: History
icon: fas fa-history
collapsed: false
items:
- title: Install browser extension...
description: History fills automatically after sync
icon: fas fa-info-circle
url: /admin/
- title: 安装浏览历史插件
description: 一键安装,自动按访问频次排序
icon: fas fa-download
url: /extension/install.html
- name: Tools
icon: fas fa-tools