fix(browser-bridge): auth bypass when secret empty, popup status fix, force ping on open

This commit is contained in:
2026-06-09 00:44:51 +08:00
parent 58751945eb
commit fa5001341e
7 changed files with 134 additions and 4095 deletions
+15 -5
View File
@@ -7,9 +7,12 @@ const RECENT_KEY = 'verstak_recent';
const DEFAULT_PORT = 9786;
document.addEventListener('DOMContentLoaded', () => {
updateUI();
// Force a fresh ping check on popup open, don't rely on stale cache
chrome.runtime.sendMessage({ type: 'FORCE_PING' });
// Read cached state for immediate render
restoreToggleState();
restoreSettingsPanel();
updateUI();
document.getElementById('sync-btn').addEventListener('click', forceSync);
document.getElementById('track-toggle').addEventListener('change', onToggle);
@@ -32,16 +35,22 @@ function updateUI() {
const portEl = document.getElementById('bridge-port');
const dotEl = document.getElementById('status-dot');
if (config.bridgeReachable) {
if (config.bridgeReachable === true) {
statusEl.textContent = 'Доступен';
statusEl.className = 'value online';
dotEl.className = 'dot online';
portEl.textContent = '127.0.0.1:' + (config.port || DEFAULT_PORT);
} else {
} else if (config.bridgeReachable === false) {
statusEl.textContent = 'Недоступен';
statusEl.className = 'value offline';
dotEl.className = 'dot offline';
portEl.textContent = config.lastPing ? '—' : 'проверка...';
portEl.textContent = '127.0.0.1:' + (config.port || DEFAULT_PORT);
} else {
// Unknown — not yet checked
statusEl.textContent = 'Проверка...';
statusEl.className = 'value';
dotEl.className = 'dot';
portEl.textContent = '127.0.0.1:' + (config.port || DEFAULT_PORT);
}
// Update settings panel port field
@@ -146,11 +155,12 @@ function savePort() {
chrome.storage.local.get(BRIDGE_KEY, (data) => {
const config = data[BRIDGE_KEY] || {};
config.port = port;
config.bridgeReachable = null; // Force re-check on next popup open
chrome.storage.local.set({ [BRIDGE_KEY]: config }, () => {
statusEl.textContent = 'Сохранено';
statusEl.className = 'port-status ok';
// Trigger immediate ping with new port
chrome.runtime.sendMessage({ type: 'FORCE_FLUSH' });
chrome.runtime.sendMessage({ type: 'FORCE_PING' });
setTimeout(() => { updateUI(); statusEl.textContent = ''; }, 1500);
});
});