增加 Chromium 浏览器逐站权限管理

This commit is contained in:
xhgit committed 2026-11-13 19:31:39 +08:00
1 parent 0b89634af2
commit f4ea1f8e03
8 files changed
+165 -6

No files matched your search

+11
View File
@@ -92,10 +92,16 @@ function render(state) {
button('bookmark').textContent = state.bookmarked ? '取消书签' : '添加书签'
button('library').hidden = state.privateMode
document.querySelector('#show-downloads').hidden = state.privateMode
document.querySelector('#show-permissions').hidden = state.privateMode
button('library').setAttribute('aria-pressed', String(state.libraryMode && panel === 'library'))
document.querySelector('#show-downloads').setAttribute('aria-pressed', String(state.libraryMode && panel === 'downloads'))
document.querySelector('#show-permissions').setAttribute('aria-pressed', String(state.libraryMode && panel === 'permissions'))
document.querySelector('#library').hidden = !(state.libraryMode && panel === 'library')
document.querySelector('#download-panel').hidden = !(state.libraryMode && panel === 'downloads')
document.querySelector('#permission-panel').hidden = !(state.libraryMode && panel === 'permissions')
document.querySelector('#permission-origin').textContent = state.origin || '请先打开一个网站。'
document.querySelector('#site-grants').disabled = !state.origin
for (const input of document.querySelectorAll('#site-grants input')) input.checked = state.grants[input.value] === true
if (state.libraryMode && panel === 'library') {
renderEntries('#bookmarks', state.bookmarks, true)
renderEntries('#history', state.history, false)
@@ -108,6 +114,7 @@ async function command(action, value) {
try {
render(await api.command(action, value))
} catch (error) {
if (current) render(current)
status.textContent = error.message
}
}
@@ -131,6 +138,10 @@ function showPanel(next) {
button('library').onclick = () => showPanel('library')
document.querySelector('#show-downloads').onclick = () => showPanel('downloads')
document.querySelector('#show-permissions').onclick = () => showPanel('permissions')
for (const input of document.querySelectorAll('#site-grants input')) {
input.onchange = () => void command('siteGrant', [current.origin, input.value, input.checked ? 'allow' : 'block'].join('\n'))
}
document.querySelector('#address-form').onsubmit = (event) => {
event.preventDefault()