Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

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:

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

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).