0.1.1 • Published 10 months ago

@kkoscielniak/arc-applescript-api v0.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

arc-applescript-api

A wrapper for Arc Browser's basic AppleScript APIs.

It partially implements Arc's AppleScript dictionary and exports functions for interacting with Arc from Node.js runtime. Might be helpful for writing small automations (e.g. using ScriptKit).

Requires Node.js 16+.

Install

npm install @kkoscielniak/arc-applescript-api

Usage

import { openTab } from "@kkoscielniak/arc-applescript-api";

await openTab("https://koscielniak.pro");

API

Types

Space

Represents an Arc's Space.

PropertyTypeDescription
idstringA unique identifier for the Space.
titlestringThe title of the Space.
indexnumberThe index of the Space (1-indexed).

Tab

Represents an Arc's Tab.

PropertyTypeDescription
titlestringThe title of the tab.
idstringA unique identifier of the tab.
urlstringThe URL of the tab.
isLoadingbooleanA flag indicating whether the tab is still loading.
location"pinned"|"unpinned"|"topApp"The location of the tab
spaceIdstringThe ID of the Space to which the tab belongs.

Spaces

getSpaces(): Promise<Space[]>

Returns a Promise that resolves to an array of Spaces.

getSpaceById(spaceId: string): Promise<Space>

Returns a Promise that resolves to the Space identified by given spaceId.

PropertyTypeDescription
spaceIdstringThe ID of the Space to retrieve.

Tabs

getTabs(): Promise<Tab[]>

Returns a Promise that resolves to an array of Tabs.

openTab(url: string): Promise<string>

Opens a new Tab in the Space currently selected in the front window.

Returns a Promise that resolves to the ID of the newly opened tab.

PropertyTypeDescription
urlstringThe URL to open in a new tab.

openTabInSpace(url: string, spaceId: string): Promise<string>

Opens new Tab in the chosen Space.

Returns a Promise that resolves to the ID of the newly opened tab.

PropertyTypeDescription
urlstringThe URL to open in a new tab.
spaceIdstringThe ID of the Space in which to open the tab.

closeTab(tabId: string): Promise<void>

Closes a Tab identified by the given tabId.

PropertyTypeDescription
tabIdstringThe ID of the tab to close.

Utils

exetuteJs(code: string): Promise<string>

Executes JavaScript code in the context of the current tab.

Returns the result of the JavaScript call

PropertyTypeDescription
codestringStringified JavaScript code

Contributing

This project is a side effect of my experiments with automating the Arc Browser. Its feature-set is limited as of now. I am gradually adding the features whenever I need them.

If there's a missing feature, a bug, or other improvement you'd like, I encourage you to contribute. Feel free to open an issue or, even better, a Pull Request.

License

This project is not affiliated with Arc Browser or The Browser Company in any way. Consider it a love letter to the Arc's community.

arc-applescript-api itself is available under DBAD license.