Docs

Running Automations

An automation in Tranquil Studio is a small .js file that controls a browser tab. The guided sample project ships several ready to run in Automations/browser/. Open the project with File → New Default Window and follow along.

Automations vs. workflows. This page is about browser automations — scripts you run inside the desktop app against a live page. Tranquil also has workflows: @tranquil/sdk programs that run headless on the Engine, on a schedule or webhook. Those are a separate topic — see Your First Workflow.

Dev preview — not stable. Tranquil is in early, active development. Everything here — APIs, interfaces, and behavior — is provisional and will change before a stable release, often without notice or backward compatibility. Don’t build anything you depend on against it.

The three moves

Almost every browser automation is the same shape:

const tab = await tranquil.getActiveTab();          // 1. grab the current browser tab
const n = await tab.evaluate(() => {                // 2. run code inside the page
  return document.querySelectorAll('img').length;
});
tranquil.notify(`This page has ${n} image(s).`);    // 3. report back

Code inside tab.evaluate(() => { … }) runs in the web page (where document and window live). Everything outside it runs in Tranquil.

Run one

  1. Open a browser tab on any page (double-click a .url shortcut, or press Cmd-T).
  2. Open an automation, e.g. Automations/browser/page-banner.js, so it’s the active editor.
  3. Press Cmd-Shift-R.

page-banner.js adds a banner to the page; run it again to remove it. Other samples read the page (page-info.js, count-elements.js) or restyle it (highlight-links.js, reader-mode.js).

Two things to know

  • Run with the .js editor focused, not the browser tab. The runner targets the last browser tab you viewed; from a focused browser tab, Cmd-Shift-R is the browser’s hard-reload instead.
  • Put page code inside tab.evaluate(). The outer script runs in Tranquil and can’t see the page’s document directly.

Tip: select a few lines and press Cmd-Shift-R to run only the selection — a quick way to experiment.


Next: Your First Automation — write your own.