Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

chore: comments are for humans, consume tokens

Luigi Agosti27e78e586547
diff --git a/dashboard/agents.css b/dashboard/agents.css
index 143340a2..66ac157b 100644
--- a/dashboard/agents.css
+++ b/dashboard/agents.css
@@ -1,4 +1,4 @@
- /* Left panel — agents */
+
.agents-panel {
width: 340px;
border-right: 1px solid var(--border);
@@ -53,7 +53,7 @@
gap: 12px;
}
- /* Right panel — activity feed */
+
.feed-panel {
flex: 1;
display: flex;
diff --git a/dashboard/agents.js b/dashboard/agents.js
index 30d5a32d..1459aa14 100644
--- a/dashboard/agents.js
+++ b/dashboard/agents.js
@@ -1,9 +1,5 @@
'use strict';
-// ---------------------------------------------------------------------------
-// Agent tracking — SSE feed + agent cards
-// ---------------------------------------------------------------------------
-
const MAX_EVENTS = 500;
const events = [];
const agents = {};
@@ -118,7 +114,6 @@ function selectAgent(id) {
renderFeed();
}
-// Filter buttons
document.querySelectorAll('.filter-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
diff --git a/dashboard/app.js b/dashboard/app.js
index 5b0fd5a7..2ce4a2bc 100644
--- a/dashboard/app.js
+++ b/dashboard/app.js
@@ -1,9 +1,5 @@
'use strict';
-// ---------------------------------------------------------------------------
-// App init — view switching, SSE connection
-// ---------------------------------------------------------------------------
-
let profilesInterval = null;
function switchView(view) {
@@ -18,7 +14,6 @@ function switchView(view) {
if (view === 'profiles') loadProfiles();
if (view === 'settings') loadSettings();
- // Auto-refresh profiles every 3s while on that view
if (profilesInterval) { clearInterval(profilesInterval); profilesInterval = null; }
if (view === 'profiles') {
profilesInterval = setInterval(loadProfiles, 3000);
@@ -29,5 +24,4 @@ function openInstanceDirect(port) {
window.open('http://localhost:' + port + '/dashboard', '_blank');
}
-// Boot
connect();
diff --git a/dashboard/base.css b/dashboard/base.css
index a992d26a..7c59931e 100644
--- a/dashboard/base.css
+++ b/dashboard/base.css
@@ -1,9 +1,9 @@
:root {
- /* Brand */
+
--primary: #f5c542;
--primary-dark: #0a0a0a;
- /* Surfaces */
+
--bg: #0a0a0a;
--bg-raised: #111;
--bg-card: #151515;
@@ -11,12 +11,12 @@
--bg-hover: #1a1a1a;
--bg-subtle: #0d0d0d;
- /* Borders */
+
--border: #222;
--border-light: #333;
--border-active: #444;
- /* Text */
+
--text: #e0e0e0;
--text-muted: #888;
--text-dim: #666;
@@ -24,7 +24,7 @@
--text-subtle: #aaa;
--text-bright: #ccc;
- /* Status */
+
--success: #4ade80;
--success-bg: #064e3b;
--warning: #fbbf24;
@@ -33,7 +33,7 @@
--danger-bg: #3a1a1a;
--inactive-bg: #1c1917;
- /* Typography */
+
--font: 'SF Mono', 'Fira Code', monospace;
}
@@ -69,7 +69,7 @@
.container { display: flex; height: calc(100vh - 60px); }
- /* View toggle */
+
.view-toggle { margin-left: auto; display: flex; gap: 4px; }
.view-btn {
background: var(--bg-hover);
@@ -91,7 +91,7 @@
}
.empty-state .crab { font-size: 48px; margin-bottom: 12px; }
- /* Profile management modal */
+
.modal-overlay {
display: none;
position: fixed;
@@ -136,7 +136,7 @@
.modal button.secondary { background: var(--border-light); color: var(--text); }
.modal button.danger { background: var(--danger); color: #fff; }
- /* Loading spinner */
+
.spinner {
display: inline-block;
width: 16px; height: 16px;
diff --git a/dashboard/dashboard.html b/dashboard/dashboard.html
index 59e8801a..ab9c7b69 100644
--- a/dashboard/dashboard.html
+++ b/dashboard/dashboard.html
@@ -23,7 +23,7 @@
</div>
</header>
-<!-- Live screencast view (hidden by default) -->
+
<div id="live-view" class="live-view" style="display:none">
<div class="live-toolbar">
<button onclick="refreshTabs()" style="background:#333;color:#e0e0e0;border:1px solid #444;padding:6px 14px;border-radius:4px;cursor:pointer;font-family:inherit;font-size:12px">↻ Refresh Tabs</button>
@@ -32,7 +32,7 @@
<div id="screencast-grid" class="screencast-grid"></div>
</div>
-<!-- Profiles view -->
+
<div id="profiles-view" class="instances-view" style="display:none">
<div class="inst-toolbar">
<button onclick="showCreateProfileModal()" class="launch-btn">+ New Profile</button>
@@ -43,7 +43,7 @@
</div>
</div>
-<!-- Create profile modal -->
+
<div class="modal-overlay" id="create-profile-modal">
<div class="modal">
<h3>📁 New Profile</h3>
@@ -58,7 +58,7 @@
</div>
</div>
-<!-- Confirm/Alert modal -->
+
<div class="modal-overlay" id="confirm-modal">
<div class="modal">
<h3 id="confirm-title">Confirm</h3>
@@ -70,7 +70,7 @@
</div>
</div>
-<!-- Launch profile modal -->
+
<div class="modal-overlay" id="launch-modal">
<div class="modal">
<h3>🚀 Launch Profile</h3>
@@ -87,7 +87,7 @@
</div>
</div>
-<!-- Settings view -->
+
<div id="settings-view" class="settings-view" style="display:none">
<div class="settings-container">
<h2 class="settings-title">⚙️ Settings</h2>
@@ -170,7 +170,7 @@
</div>
</div>
-<!-- Feed view (default) -->
+
<div id="feed-view" class="container">
<div class="agents-panel">
<h2>Agents</h2>
@@ -195,9 +195,9 @@
</div>
</div>
-</div><!-- end feed-view -->
+</div>
+
-<!-- Profile management modal -->
<div class="modal-overlay" id="modal">
<div class="modal">
<h3 id="modal-title">Manage Profile</h3>
diff --git a/dashboard/profiles.css b/dashboard/profiles.css
index 18147311..5b45dc69 100644
--- a/dashboard/profiles.css
+++ b/dashboard/profiles.css
@@ -1,4 +1,4 @@
- /* Profiles panel (bottom) */
+
.profiles-bar {
border-top: 1px solid var(--border);
padding: 12px 24px;
@@ -22,7 +22,7 @@
.profile-chip .psize { color: var(--text-faint); margin-left: 8px; }
.profile-chip .psource { color: var(--primary); font-size: 10px; margin-left: 6px; }
- /* Instances view */
+
.instances-view { height: calc(100vh - 60px); display: flex; flex-direction: column; }
.inst-toolbar {
padding: 12px 24px;
diff --git a/dashboard/profiles.js b/dashboard/profiles.js
index 029a978f..cfa4af01 100644
--- a/dashboard/profiles.js
+++ b/dashboard/profiles.js
@@ -1,17 +1,12 @@
'use strict';
-// ---------------------------------------------------------------------------
-// Profile management — cards, launch, create, delete
-// ---------------------------------------------------------------------------
-
let profilesLoading = false;
async function loadProfiles() {
- if (profilesLoading) return; // debounce concurrent calls
+ if (profilesLoading) return;
profilesLoading = true;
const grid = document.getElementById('profiles-grid');
- // Show spinner only on first load (when grid is empty or has placeholder)
if (!grid.querySelector('.inst-card')) {
grid.innerHTML = '<div class="loading-overlay"><span class="spinner"></span>Loading profiles...</div>';
}
@@ -37,7 +32,6 @@ async function loadProfiles() {
const grid = document.getElementById('profiles-grid');
const cards = [];
- // Only show Main card if we're running in embedded mode (bridge serves /health with no "mode")
if (!health.mode) {
cards.push(renderMainCard(tabsData.tabs ? tabsData.tabs.length : 0));
}
@@ -119,9 +113,6 @@ function renderProfileCard(name, sizeMB, source, inst) {
`;
}
-// ---------------------------------------------------------------------------
-// Profile CRUD + launch
-// ---------------------------------------------------------------------------
function showCreateProfileModal() {
document.getElementById('create-profile-modal').classList.add('open');
@@ -157,9 +148,7 @@ async function doCreateProfile() {
} catch (e) { await appAlert('Failed: ' + e.message, 'Error'); }
}
-// ---------------------------------------------------------------------------
-// Port/mode memory (localStorage)
-// ---------------------------------------------------------------------------
+
function getProfilePort(name) {
const saved = localStorage.getItem('pinchtab-port-' + name);
@@ -236,9 +225,6 @@ async function resetProfile(name) {
loadProfiles();
}
-// ---------------------------------------------------------------------------
-// Instance lifecycle
-// ---------------------------------------------------------------------------
function pollInstanceStatus(id) {
let attempts = 0;
diff --git a/dashboard/screencast.css b/dashboard/screencast.css
index f2e18afe..bec8a516 100644
--- a/dashboard/screencast.css
+++ b/dashboard/screencast.css
@@ -1,4 +1,4 @@
- /* Live view */
+
.live-view { height: calc(100vh - 60px); display: flex; flex-direction: column; }
.live-toolbar { padding: 12px 24px; border-bottom: 1px solid var(--border); }
.screencast-grid {
diff --git a/dashboard/screencast.js b/dashboard/screencast.js
index 15dce78d..d7ed9a0c 100644
--- a/dashboard/screencast.js
+++ b/dashboard/screencast.js
@@ -1,9 +1,5 @@
'use strict';
-// ---------------------------------------------------------------------------
-// Screencast — WebSocket JPEG streaming from Chrome tabs
-// ---------------------------------------------------------------------------
-
const screencastSockets = {};
function getScreencastParams() {
@@ -133,7 +129,6 @@ async function viewInstanceLive(id, port) {
}
}
-// Cleanup on page unload
-window.addEventListener('beforeunload', () => {
+ window.addEventListener('beforeunload', () => {
Object.values(screencastSockets).forEach(s => s.close());
});
diff --git a/dashboard/settings.css b/dashboard/settings.css
index 9515f693..f5d4584d 100644
--- a/dashboard/settings.css
+++ b/dashboard/settings.css
@@ -1,4 +1,4 @@
- /* Settings view */
+
.settings-view { height: calc(100vh - 60px); overflow-y: auto; }
.settings-container { max-width: 600px; margin: 0 auto; padding: 24px; }
.settings-title { color: var(--primary); font-size: 18px; margin-bottom: 24px; }
diff --git a/dashboard/settings.js b/dashboard/settings.js
index 316bf57a..358aae5c 100644
--- a/dashboard/settings.js
+++ b/dashboard/settings.js
@@ -1,13 +1,8 @@
'use strict';
-// ---------------------------------------------------------------------------
-// Settings — screencast params, stealth, browser toggles
-// ---------------------------------------------------------------------------
-
const screencastSettings = { fps: 1, quality: 30, maxWidth: 800 };
async function loadSettings() {
- // Load stealth status
try {
const res = await fetch('/stealth/status');
const data = await res.json();
@@ -15,7 +10,6 @@ async function loadSettings() {
updateStealthInfo(data);
} catch (e) {}
- // Load server health info
try {
const res = await fetch('/health');
const data = await res.json();
@@ -30,13 +24,11 @@ async function loadSettings() {
document.getElementById('server-info').textContent = 'Failed to load server info';
}
- // Restore saved settings from localStorage
const saved = JSON.parse(localStorage.getItem('pinchtab-settings') || '{}');
if (saved.fps) { document.getElementById('set-fps').value = saved.fps; document.getElementById('fps-val').textContent = saved.fps + ' fps'; screencastSettings.fps = saved.fps; }
if (saved.quality) { document.getElementById('set-quality').value = saved.quality; document.getElementById('quality-val').textContent = saved.quality + '%'; screencastSettings.quality = saved.quality; }
if (saved.maxWidth) { document.getElementById('set-maxwidth').value = saved.maxWidth; screencastSettings.maxWidth = saved.maxWidth; }
- // Toggle labels
document.querySelectorAll('.toggle input').forEach(cb => {
cb.addEventListener('change', () => {
cb.parentElement.querySelector('.toggle-label').textContent = cb.checked ? 'On' : 'Off';
diff --git a/dashboard/utils.js b/dashboard/utils.js
index abc244ed..3046c35a 100644
--- a/dashboard/utils.js
+++ b/dashboard/utils.js
@@ -1,9 +1,5 @@
'use strict';
-// ---------------------------------------------------------------------------
-// Shared utilities
-// ---------------------------------------------------------------------------
-
function esc(s) {
if (!s) return '';
const d = document.createElement('div');
@@ -53,7 +49,6 @@ function closeModal() {
document.getElementById('modal').classList.remove('open');
}
-// Reusable modal — pass title + HTML content + optional footer buttons
function showModal(title, bodyHtml, buttons) {
const modal = document.getElementById('modal');
document.getElementById('modal-title').textContent = title;
@@ -67,7 +62,6 @@ function showModal(title, bodyHtml, buttons) {
modal.classList.add('open');
}
-// Fetch with error handling — returns {ok, data} or shows alert on failure
async function apiFetch(url, options) {
try {
const res = await fetch(url, options);
diff --git a/readability.js b/readability.js
index 997b9308..2bc77365 100644
--- a/readability.js
+++ b/readability.js
@@ -1,5 +1,3 @@
-// Lightweight readability extraction — strips nav/footer/aside/ads,
-// prefers article/main content, falls back to body.innerText.
(() => {
const strip = ['nav', 'footer', 'aside', 'header', '[role="navigation"]',
'[role="banner"]', '[role="contentinfo"]', '[aria-hidden="true"]',
@@ -9,13 +7,11 @@
'#Lb4nn', '.language-selector', '.locale-selector',
'[data-language-picker]', '#langsec-button'];
- // Try article or main first
let root = document.querySelector('article') ||
document.querySelector('[role="main"]') ||
document.querySelector('main');
if (!root) {
- // Clone body and strip junk
root = document.body.cloneNode(true);
for (const sel of strip) {
root.querySelectorAll(sel).forEach(el => el.remove());
@@ -24,7 +20,6 @@
root = root.cloneNode(true);
}
- // Clean up: remove scripts, styles, hidden elements
root.querySelectorAll('script, style, noscript, svg, [hidden]').forEach(el => el.remove());
return root.innerText.replace(/\n{3,}/g, '\n\n').trim();
diff --git a/stealth.js b/stealth.js
index 2e51cba2..5bad46aa 100644
--- a/stealth.js
+++ b/stealth.js
@@ -1,14 +1,5 @@
-// Enhanced stealth script injected into every new document via page.AddScriptToEvaluateOnNewDocument.
-// Hides automation indicators from sophisticated bot detection systems.
-
-// Session-stable seed injected by Go at launch time via __pinchtab_seed.
-// Falls back to a fixed value if not set (shouldn't happen in normal operation).
-// This seed is constant across all page loads within the same Pinchtab session,
-// so hardware fingerprint values stay consistent (as they would in a real browser).
const sessionSeed = (typeof __pinchtab_seed !== 'undefined') ? __pinchtab_seed : 42;
-// Mulberry32 PRNG — simple, fast, uniform distribution, deterministic.
-// Much better than Math.sin() which produces visible patterns.
const seededRandom = (function() {
const cache = {};
return function(seed) {
@@ -22,18 +13,15 @@ const seededRandom = (function() {
};
})();
-// Hide webdriver flag completely
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined,
configurable: true
});
-// Remove automation-related window properties
delete window.cdc_adoQpoasnfa76pfcZLmcfl_Array;
delete window.cdc_adoQpoasnfa76pfcZLmcfl_Promise;
delete window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol;
-// Fix chrome runtime to look more realistic
if (!window.chrome) { window.chrome = {}; }
if (!window.chrome.runtime) {
window.chrome.runtime = {
@@ -42,7 +30,6 @@ if (!window.chrome.runtime) {
};
}
-// Enhanced permissions API
const originalQuery = window.navigator.permissions.query;
window.navigator.permissions.query = (parameters) => (
parameters.name === 'notifications' ?
@@ -50,7 +37,6 @@ window.navigator.permissions.query = (parameters) => (
originalQuery(parameters)
);
-// Realistic plugins array (common plugins)
Object.defineProperty(navigator, 'plugins', {
get: () => [{
name: 'Chrome PDF Plugin',
@@ -67,31 +53,23 @@ Object.defineProperty(navigator, 'plugins', {
}],
});
-// Realistic language preferences
Object.defineProperty(navigator, 'languages', {
get: () => ['en-US', 'en'],
});
-// Hardware values defined later with proper seeding
-// Platform information (consistent with User-Agent)
Object.defineProperty(navigator, 'platform', {
get: () => 'MacIntel',
});
-// Fix missing properties that indicate automation
Object.defineProperty(navigator.connection || {}, 'rtt', {
get: () => 100,
});
-// Stealth level: 'light' = basic automation hiding only, 'full' = all fingerprint spoofing.
-// Light mode avoids canvas/WebGL/font overrides that can break sites like X.com.
-// Set via __pinchtab_stealth_level (injected by Go). Default: 'light'.
const stealthLevel = (typeof __pinchtab_stealth_level !== 'undefined') ? __pinchtab_stealth_level : 'light';
if (stealthLevel === 'full') {
-// Spoof WebGL for fingerprint resistance
const getParameter = WebGLRenderingContext.prototype.getParameter;
WebGLRenderingContext.prototype.getParameter = function(parameter) {
if (parameter === 37445) return 'Intel Inc.';
@@ -99,7 +77,6 @@ WebGLRenderingContext.prototype.getParameter = function(parameter) {
return getParameter.apply(this, arguments);
};
-// Canvas fingerprinting noise
const originalToDataURL = HTMLCanvasElement.prototype.toDataURL;
const originalToBlob = HTMLCanvasElement.prototype.toBlob;
const originalGetImageData = CanvasRenderingContext2D.prototype.getImageData;
@@ -148,7 +125,6 @@ CanvasRenderingContext2D.prototype.getImageData = function(...args) {
return imageData;
};
-// Font fingerprinting protection
const originalMeasureText = CanvasRenderingContext2D.prototype.measureText;
CanvasRenderingContext2D.prototype.measureText = function(text) {
const metrics = originalMeasureText.apply(this, arguments);
@@ -161,7 +137,6 @@ CanvasRenderingContext2D.prototype.measureText = function(text) {
});
};
-// WebRTC IP leak prevention
if (window.RTCPeerConnection) {
const originalRTCPeerConnection = window.RTCPeerConnection;
window.RTCPeerConnection = function(config, constraints) {
@@ -171,9 +146,7 @@ if (window.RTCPeerConnection) {
window.RTCPeerConnection.prototype = originalRTCPeerConnection.prototype;
}
-} // end stealthLevel === 'full'
-// Timezone spoofing - configurable via window.__pinchtab_timezone
const __pinchtab_origGetTimezoneOffset = Date.prototype.getTimezoneOffset;
Object.defineProperty(Date.prototype, 'getTimezoneOffset', {
value: function() {
@@ -181,8 +154,7 @@ Object.defineProperty(Date.prototype, 'getTimezoneOffset', {
}
});
-// Use the already-defined sessionSeed and seededRandom from top of file
-const hardwareCore = 2 + Math.floor(seededRandom(sessionSeed) * 6) * 2; // 2,4,6,8,10,12
+const hardwareCore = 2 + Math.floor(seededRandom(sessionSeed) * 6) * 2;
const deviceMem = [2, 4, 8, 16][Math.floor(seededRandom(sessionSeed * 2) * 4)];
Object.defineProperty(navigator, 'hardwareConcurrency', {