pnlng / jxa

JavaScript for Automation (JXA) scripting for Deno

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JXA

Deno modules for running JavaScript for Automation (JXA), mostly ported from Node packages by JXA-userland/JXA.

Run JXA in Deno

// script.js
import { run } from "https://deno.land/x/jxa_run/mod.ts"

const result = await run((name, emoji) =>
  `Hello ${name} ${emoji}!`, "Deno", "🦕");
console.log(result)
$ deno run --allow-run script.js
Hello Deno 🦕!

See run/ for detailed documentation.

TypeScript Support

// script.ts
import { run } from "https://deno.land/x/jxa_run/mod.ts";
import type {} from "https://deno.land/x/jxa_run/global.d.ts";
// Generated with @jxa/sdef-to-dts
import type { GoogleChrome } from "https://raw.githubusercontent.com/JXA-userland/JXA/master/packages/%40jxa/types/test/fixtures/GoogleChrome.d.ts";

const result = await run(
  () => {
    const chrome = Application<GoogleChrome>("Google Chrome");
    const windows: GoogleChrome.Window[] = chrome.windows();
    const activeTab: GoogleChrome.Tab = windows[0].activeTab();
    return activeTab.title();
  },
);
console.log(result);

deno run --allow-run script.ts will output the title of your active tab in Chrome.

See run/types/ for more information about TypeScript support.

About

JavaScript for Automation (JXA) scripting for Deno

License:MIT License


Languages

Language:TypeScript 96.3%Language:Makefile 3.7%