Skip to content

Getting Started ​

Welcome to ScriptX! This guide will help you get started with writing scripts on iOS.

What is ScriptX? ​

ScriptX is a powerful JavaScript automation tool for iOS. It allows you to:

  • Write and run JavaScript scripts directly on your iPhone/iPad
  • Create home screen widgets with custom content
  • Automate tasks using system APIs
  • Interact with Calendar, Reminders, Files, and more

Your First Script ​

Let's start with a simple "Hello World" example:

javascript
console.log("Hello, ScriptX!");

Run this script and you'll see the output in the console.

Working with Alerts ​

You can show alerts to interact with users:

javascript
let alert = new Alert();
alert.title = "Welcome";
alert.message = "This is your first ScriptX alert!";
alert.addAction("OK");
await alert.present();

Making HTTP Requests ​

Fetch data from the internet:

javascript
let req = new Request("https://api.github.com");
let response = await req.loadJSON();
console.log(response);

Reading and Writing Files ​

Work with files using FileManager:

javascript
let fm = FileManager.local();
let path = fm.documentsDirectory() + "/hello.txt";

// Write file
fm.writeString(path, "Hello, World!");

// Read file
let content = fm.readString(path);
console.log(content);

Creating Widgets ​

Build home screen widgets to display information:

javascript
let widget = new ListWidget();

// Set background
widget.backgroundColor = new Color("#1a1a2e");

// Add text
let title = widget.addText("Hello!");
title.textColor = Color.white();
title.font = Font.boldSystemFont(24);

widget.addSpacer();

let date = widget.addDate(new Date());
date.textColor = Color.gray();
date.applyRelativeStyle();

// Set widget and complete
Script.setWidget(widget);
widget.presentSmall();
Script.complete();

Working with Calendar ​

Access and create calendar events:

javascript
// Get today's events
let events = await CalendarEvent.today();
for (let event of events) {
    console.log(event.title);
}

// Create a new event
let event = new CalendarEvent();
event.title = "Meeting";
event.startDate = new Date();
event.endDate = new Date(Date.now() + 3600000); // 1 hour later
await event.save();

Working with Reminders ​

Manage your reminders:

javascript
// Get incomplete reminders
let reminders = await Reminder.allIncomplete();
for (let reminder of reminders) {
    console.log(reminder.title);
}

// Create a new reminder
let reminder = new Reminder();
reminder.title = "Buy groceries";
reminder.dueDate = new Date();
await reminder.save();

Clipboard Operations ​

Read and write to the clipboard:

javascript
// Copy text
Pasteboard.copyString("Hello from ScriptX!");

// Read text
let text = Pasteboard.getString();
console.log(text);

Sending Notifications ​

Send local notifications:

javascript
let notification = new Notification();
notification.title = "Reminder";
notification.body = "Don't forget to check ScriptX!";
notification.schedule();

Next Steps ​

Now that you know the basics, explore the API Reference to discover all available features:

Tips ​

Script Storage

Scripts are stored in the app's Documents directory. If iCloud is enabled, they sync across all your devices automatically.

Widget Parameter

You can pass parameters to widgets. Access them via args.widgetParameter in your script.

Running Context

Use config.runsInWidget to check if your script is running in a widget or in the app.