mirror of
https://github.com/Such-Software/adaptive-multi-protocol-browser.git
synced 2026-10-25 02:08:33 +02:00
Harden browser docs and transport recovery
This commit is contained in:
+22
-2
@@ -549,8 +549,9 @@ def _route_helper_background_js() -> str:
|
||||
" }",
|
||||
" if (status.ready) return;",
|
||||
" pendingByTab.set(details.tabId, details.url);",
|
||||
" const installCommand = Array.isArray(status.install_command) ? status.install_command.join(' ') : '';",
|
||||
" const setupUrl = browser.runtime.getURL(",
|
||||
" `setup.html?transport=${encodeURIComponent(transport)}&url=${encodeURIComponent(details.url)}&message=${encodeURIComponent(status.message || '')}`",
|
||||
" `setup.html?transport=${encodeURIComponent(transport)}&url=${encodeURIComponent(details.url)}&message=${encodeURIComponent(status.message || '')}&hint=${encodeURIComponent(status.setup_hint || '')}&install=${encodeURIComponent(installCommand)}`",
|
||||
" );",
|
||||
" await browser.tabs.update(details.tabId, { url: setupUrl });",
|
||||
"}",
|
||||
@@ -584,6 +585,7 @@ def _route_helper_setup_html() -> str:
|
||||
' <p id="body">AMPB needs to start a local transport before opening this route.</p>',
|
||||
' <pre id="url"></pre>',
|
||||
' <p id="message" class="message"></p>',
|
||||
' <pre id="install-command" class="install-command" hidden></pre>',
|
||||
' <button id="approve" type="button">Start and open</button>',
|
||||
' <p id="status" class="status"></p>',
|
||||
" </main>",
|
||||
@@ -604,13 +606,27 @@ def _route_helper_setup_js() -> str:
|
||||
"const transport = params.get('transport') || '';",
|
||||
"const url = params.get('url') || '';",
|
||||
"const message = params.get('message') || '';",
|
||||
"const hint = params.get('hint') || '';",
|
||||
"const install = params.get('install') || '';",
|
||||
"const label = transport === 'tor' ? 'Tor' : transport === 'i2p' ? 'I2P' : transport;",
|
||||
"",
|
||||
"function showInstallCommand(value) {",
|
||||
" const installCommand = document.getElementById('install-command');",
|
||||
" if (!value) {",
|
||||
" installCommand.hidden = true;",
|
||||
" installCommand.textContent = '';",
|
||||
" return;",
|
||||
" }",
|
||||
" installCommand.hidden = false;",
|
||||
" installCommand.textContent = value;",
|
||||
"}",
|
||||
"",
|
||||
"document.getElementById('title').textContent = `Set up ${label}?`;",
|
||||
"document.getElementById('body').textContent = `AMPB can start a managed ${label} session and keep its state isolated.`;",
|
||||
"document.getElementById('url').textContent = url;",
|
||||
"document.getElementById('message').textContent = message;",
|
||||
"document.getElementById('message').textContent = hint || message;",
|
||||
"document.getElementById('approve').textContent = `Start ${label} and open`;",
|
||||
"showInstallCommand(install);",
|
||||
"",
|
||||
"document.getElementById('approve').addEventListener('click', async () => {",
|
||||
" const status = document.getElementById('status');",
|
||||
@@ -621,6 +637,9 @@ def _route_helper_setup_js() -> str:
|
||||
" window.location.href = url;",
|
||||
" return;",
|
||||
" }",
|
||||
" if (result && Array.isArray(result.install_command)) {",
|
||||
" showInstallCommand(result.install_command.join(' '));",
|
||||
" }",
|
||||
" status.textContent = (result && result.message) || `${label} did not become ready.`;",
|
||||
"});",
|
||||
"",
|
||||
@@ -637,6 +656,7 @@ def _route_helper_setup_css() -> str:
|
||||
".eyebrow { color: #36d1c4; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }",
|
||||
"h1 { font-size: 2rem; margin: 0 0 12px; }",
|
||||
"pre { white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px; border: 1px solid #444; }",
|
||||
".install-command { background: #1d1d1d; border-color: #36d1c4; color: #f7f1e8; }",
|
||||
"button { font: inherit; font-weight: 700; padding: 12px 16px; border: 0; background: #36d1c4; color: #111; }",
|
||||
".message, .status { color: #cfc7bb; }",
|
||||
"",
|
||||
|
||||
Reference in New Issue
Block a user