Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugins/mini-browser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0 - 2026-11-19

一个可以在ZTools使用的小浏览器,更方便完成轻量任务
21 changes: 21 additions & 0 deletions plugins/mini-browser/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Light_PolarisCN

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions plugins/mini-browser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 小浏览器

放在 ZTools 里的小浏览器。自己添加网页,在插件窗口里打开。

没有预置网址。第一次打开点「添加网页」,填写名称和地址,之后会出现在顶栏。齿轮里可以勾选显示、调整顺序、删除。

制作该插件目的是方便我使用网页版ai(bushi

![示例](./images/p1.png)
Binary file added plugins/mini-browser/images/p1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
228 changes: 228 additions & 0 deletions plugins/mini-browser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem:;" />
<title>小浏览器</title>
<style>
:root {
color-scheme: light dark;
--bar: #111827;
--line: rgba(255, 255, 255, 0.08);
--text: #f8fafc;
--muted: #94a3b8;
--active: #22c55e;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
background: #0b0f17;
color: var(--text);
font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
overflow: hidden;
}
header {
background: var(--bar);
border-bottom: 1px solid var(--line);
}
.tabbar, .addressbar {
display: flex;
align-items: center;
gap: 8px;
height: 40px;
padding: 0 8px;
}
.addressbar { height: 36px; padding-top: 0; }
#address {
flex: 1;
height: 28px;
min-width: 0;
border: 1px solid var(--line);
border-radius: 999px;
background: #0b0f17;
color: var(--text);
padding: 0 12px;
outline: none;
}
#address:focus { border-color: rgba(96, 165, 250, 0.8); }
#go {
background: rgba(255, 255, 255, 0.08);
color: var(--text);
}
nav {
display: flex;
gap: 4px;
overflow-x: auto;
flex: 1;
scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }
button {
border: 0;
background: transparent;
color: var(--muted);
height: 28px;
padding: 0 10px;
border-radius: 999px;
cursor: pointer;
white-space: nowrap;
}
button.active {
background: rgba(34, 197, 94, 0.16);
color: var(--text);
}
button:hover { color: var(--text); }
.tools { display: flex; gap: 4px; flex: none; }
.tools button { color: var(--text); background: rgba(255, 255, 255, 0.06); }
#stage {
position: fixed;
top: 76px;
right: 0;
bottom: 0;
left: 0;
background: #fff;
}
#pages {
position: absolute;
inset: 0;
}
#pages webview {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
border: 0;
background: #fff;
visibility: hidden;
}
#pages webview.active { visibility: visible; }
#status {
display: none;
position: absolute;
left: 12px;
right: 12px;
bottom: 12px;
padding: 8px 10px;
border-radius: 8px;
background: rgba(17, 24, 39, 0.92);
color: #e2e8f0;
z-index: 2;
}
#settings {
display: none;
position: fixed;
inset: 76px 0 0 0;
background: #0b0f17;
z-index: 5;
overflow: auto;
padding: 16px;
}
#settings.open { display: block; }
.settings-head {
display: flex;
align-items: center;
gap: 8px;
position: sticky;
top: 0;
z-index: 1;
background: #0b0f17;
padding-bottom: 8px;
}
.settings-head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 600; }
#settings-close {
background: rgba(255, 255, 255, 0.08);
color: var(--text);
}
#settings p, #empty p { margin: 0 0 14px; color: var(--muted); }
#empty {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #0b0f17;
z-index: 3;
}
#empty[hidden] { display: none; }
#empty button {
background: rgba(255, 255, 255, 0.08);
color: var(--text);
}
.row {
display: flex;
align-items: center;
gap: 10px;
padding: 8px 0;
border-bottom: 1px solid var(--line);
}
.row label { flex: 1; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.row small { color: var(--muted); }
.row .move { width: 28px; padding: 0; }
.add {
display: flex;
gap: 8px;
margin-top: 16px;
}
.add input, .foot button, .row input[type="text"] {
height: 32px;
border: 1px solid var(--line);
border-radius: 8px;
background: #111827;
color: var(--text);
padding: 0 10px;
}
.add input { flex: 1; min-width: 0; }
.foot { display: flex; gap: 8px; margin-top: 16px; }
.foot button, .add button {
height: 32px;
padding: 0 12px;
border-radius: 8px;
background: rgba(255, 255, 255, 0.08);
color: var(--text);
}
</style>
</head>
<body>
<header>
<div class="tabbar">
<nav id="tabs"></nav>
<div class="tools">
<button id="settings-open" type="button" title="管理标签页">⚙</button>
</div>
</div>
<form id="address-form" class="addressbar">
<button id="back" type="button" title="后退">←</button>
<button id="reload" type="button" title="刷新">↻</button>
<input id="address" type="text" placeholder="输入网址,回车打开" spellcheck="false" />
<button id="go" type="submit">打开</button>
<button id="external" type="button" title="用系统浏览器打开">↗</button>
</form>
</header>
<section id="settings">
<div class="settings-head">
<h2>标签页</h2>
<button id="settings-close" type="button">关闭</button>
</div>
<p>添加后出现在顶栏。勾选控制显示,箭头调整顺序,× 删除。</p>
<div id="setting-list"></div>
<form id="add-site" class="add">
<input id="add-name" type="text" maxlength="24" placeholder="名称,例如 DeepSeek" />
<input id="add-url" type="text" placeholder="deepseek.com" required spellcheck="false" />
<button type="submit">添加</button>
</form>
<div class="foot"></div>
</section>
<div id="stage">
<div id="pages"></div>
<div id="empty">
<p>还没有标签页</p>
<button id="empty-add" type="button">添加网页</button>
</div>
<div id="status"></div>
</div>
<script src="renderer.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions plugins/mini-browser/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions plugins/mini-browser/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "mini-browser",
"title": "小浏览器",
"pluginName": "小浏览器",
"description": "一个放在 ZTools 里的小浏览器,自己添加网页,在插件窗口里打开。",
"version": "1.0.0",
"author": "海湾上的北辰",
"logo": "logo.svg",
"main": "index.html",
"preload": "preload.js",
"pluginSetting": {
"height": 640
},
"features": [
{
"code": "open",
"explain": "小浏览器",
"icon": "logo.svg",
"cmds": ["小浏览器", "浏览器", "打开网页"]
}
]
}
63 changes: 63 additions & 0 deletions plugins/mini-browser/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const BAR_KEY = 'mini-browser:bar'
const LAST_KEY = 'mini-browser:last'

function normalizeBar(raw) {
const source = Array.isArray(raw) ? raw : []
const seen = new Set()
const items = []
source.forEach((item) => {
if (!item || item.builtin || seen.has(item.id)) return
if (!/^https?:\/\//i.test(item.url || '')) return
seen.add(item.id)
items.push({
id: String(item.id),
name: String(item.name || item.url).slice(0, 24),
url: item.url,
enabled: item.enabled !== false
})
})
return items
}

function loadBar() {
try {
const saved = window.ztools.dbStorage.getItem(BAR_KEY)
if (saved) return normalizeBar(JSON.parse(saved))
} catch (error) {
console.warn('[mini-browser] 读取顶栏失败', error)
}
return []
}

function saveBar(items) {
const next = normalizeBar(items)
window.ztools.dbStorage.setItem(BAR_KEY, JSON.stringify(next))
return next
}

function loadLast() {
try {
return window.ztools.dbStorage.getItem(LAST_KEY) || ''
} catch (error) {
return ''
}
}

function saveLast(id) {
try {
window.ztools.dbStorage.setItem(LAST_KEY, id || '')
} catch (error) {
console.warn('[mini-browser] 保存上次打开失败', error)
}
}

window.webAi = {
loadBar,
saveBar,
loadLast,
saveLast
}

window.ztools.onPluginEnter(() => {
window.dispatchEvent(new CustomEvent('mini-browser-open'))
})
Loading
Loading