Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
AI Agents¶
AI agents connected to Chromium-based browsers via the Chrome DevTools Protocol (CDP) (Runtime.evaluate) can execute arbitrary JavaScript in the page’s main world (window, document, etc.) and mutate the DOM on the fly—achieving the same page-modification capabilities as a userscript extension without installing one:
BrowserOS (
browseros-neo): Providespage.evaluateInPage(fn, arg)(inside batchedrunscripts) and theevaluate_in_pageMCP tool to run custom JavaScript directly in the page context. Furthermore,page.saveHelper(name, fn)persists reusable JavaScript helpers scoped to the current hostname (location.hostname), andsave_skill/run_skillsave and replay parameterized host-scoped scripts—functioning much like@matchrules in userscript managers (see AI Browsers and Agentic Web Automation).Google Chrome (and other Chromium browsers): Agents using
chrome-devtools-mcp(evaluate_script), Playwright (page.evaluate()), or Puppeteer connected over CDP (chrome://inspect/#remote-debuggingor--remote-debugging-port) can similarly inject and execute JavaScript to modify any open tab.
Example: Bypassing Chrome’s Built-in PDF Viewer “Save As” Dialog¶
When automating document downloads (such as paychecks or statements), clicking the “Download” button inside Chrome’s built-in PDF viewer invokes Chrome’s internal SavePackage / file-picker API, which always opens a native OS “Save As” dialog (even when “Ask where to save each file before downloading” is disabled) and stalls unattended automation.
An AI agent can bypass the PDF viewer entirely by mutating the page DOM on the fly—injecting a temporary same-origin <a href="..." download="filename.pdf"> anchor into document.body and triggering a direct download to ~/Downloads (e.g., via page.download(ref) in BrowserOS neo):
// Inside a BrowserOS neo `run` script:
await page.evaluateInPage(({ url, filename }) => {
let a = document.getElementById('__agent_dl');
if (!a) {
a = document.createElement('a');
a.id = '__agent_dl';
a.textContent = 'Agent Direct Download';
document.body.appendChild(a);
}
a.href = url;
a.setAttribute('download', filename);
}, { url: pdfUrl, filename: 'statement.pdf' });
const snap = await page.snapshot();
// Locate the injected link ref from `snap` and download directly:
const result = await page.download(dlRef);AI Agents vs. Userscript Extensions¶
Trigger model: Userscript extensions (like ScriptCat or Tampermonkey) inject scripts automatically on every page load matching
@match/@includerules. AI agents mutate the DOM on demand during a task, and those mutations only persist until the tab reloads or navigates.Stealth by default: In BrowserOS neo, standard accessibility and CDP primitives (
snapshot,read,grep,act,download) operate from the browser process without injecting JavaScript into the page’s main world;evaluateInPageis only invoked selectively when custom DOM manipulation is needed.
Browser Extensions¶
ScriptCat is preferred to TamperMonkey and ViolentMonkey as ScriptCat is opensource and support latest versions of Chrome. TamperMonkey is close sourced while ViolentMonkey doesn’t support the latest version of Chrome (due to Manifest V3).