# Script Library Operations

---

## 1. Overview

The **Script Library** is an automation script management and execution center provided by the Quantum Cloud Phone platform. It allows users to browse public scripts, copy them to a personal library, and write and run JavaScript automation scripts. Scripts are executed on designated cloud phone devices to automate operations in apps such as TikTok, YouTube, Instagram, and more.

---

## 2. Accessing the Script Library

1. After logging into the Quantum Cloud Phone platform, click **"Script Library"** in the left navigation bar.
2. The page has two tabs at the top:
   - **Script Store**: Browse and use public scripts provided by the platform.
   - **My Scripts**: Manage scripts you have created or copied from the store.

![](./assets/2026-03-27-18-40-16-image.png)

---

## 3. Script Store

### 3.1 Overview

The Script Store is a collection of pre-built public scripts. Users can run them directly or copy them to their personal library for customization — no coding required.

### 3.2 Script Card Fields

Each script is displayed as a card with the following information:

| Field        | Description                                                                      |
| ------------ | -------------------------------------------------------------------------------- |
| Script Name  | e.g., `tiktok_follow`, `youtube_view`                                            |
| Language Tag | Currently all `Javascript`                                                       |
| Step Summary | Brief description of the execution flow                                          |
| Copy Script  | Copies the script to "My Scripts" for personal use and editing                   |
| Run          | Directly select a cloud phone and run the script (same process as in My Scripts) |

---

## 4. My Scripts

### 4.1 Script Card Fields

| Field        | Description                                                                                |
| ------------ | ------------------------------------------------------------------------------------------ |
| Script Name  | e.g., `tiktok_view_use`, `tiktok_bio`                                                      |
| Language Tag | `Javascript` / Shell                                                                       |
| Step Summary | Brief execution flow, e.g., "Launch → Return to Desktop → Open TikTok → Dismiss Popup → …" |
| Edit Script  | Opens the script editor                                                                    |
| Run          | Quickly select a cloud phone and execute the script                                        |
| ··· (More)   | Options such as copy or delete                                                             |

### 4.2 Creating a New Script

Click the **"+"** button at the bottom-right of the script list, then fill in the script name, type, and description to create a new script.

![](./assets/2026-03-27-18-40-44-image.png)

![](./assets/2026-03-27-18-41-06-image.png)

---

## 5. Editing a Script

Click the **"Edit Script"** button on any script card to enter the script editor.

![](./assets/2026-03-27-18-41-26-image.png)

### 5.1 Page Layout

- **Top Navigation**: Shows the current path (e.g., `Script Library / tiktok_view_use`). Click the back arrow to return to the script list.
- **Top-Right Buttons**:
  - `Model Management`: Manage AI model configurations.
  - `AI Script Generation`: Automatically generate script code using AI.
- **Code Editor**: The dark area in the center — edit your JavaScript code directly here.
- **Output Area**: The light-colored area below the editor — displays real-time logs when the script runs.
- **Right Panel**: Shows the currently bound cloud phone ID. Click "Select Cloud Phone" to bind a device.

### 5.2 Script Configuration Parameters (using tiktok_view_use as an example)

```javascript
const CONFIG = {
  packageName: "com.zhiliaoapp.musically", // TikTok package name
  minWatchMs: 2000,         // Min watch time per video (ms)
  maxWatchMs: 5000,         // Max watch time per video (ms)
  minProfileStayMs: 1000,   // Min time on profile page (ms)
  maxProfileStayMs: 3000,   // Max time on profile page (ms)
  enterProfileChance: 0.88, // Probability of visiting a profile (0~1)
  maxLoop: 9,               // Maximum number of loops
  swipeDurationMin: 350,    // Min swipe duration (ms)
  swipeDurationMax: 700,    // Max swipe duration (ms)
  debug: true               // Enable debug mode
};
```

Modify these parameters as needed to control the script's behavior flexibly.

### 5.3 Bottom Action Buttons

| Button      | Function                                       |
| ----------- | ---------------------------------------------- |
| Save        | Save the current script changes                |
| Clear Logs  | Clear the content in the output area           |
| Run         | Execute the script on the selected cloud phone |
| Stop Script | Terminate the currently running script         |

![](./assets/2026-03-27-18-41-59-image.png)

---

## 6. Selecting a Cloud Phone and Running a Script

Whether in the **Script Store** or **My Scripts**, the process for running a script is the same.

### Method 1: Quick Run from Script Card

1. Click the **"Run"** button on the script card.
   
   ![](./assets/2026-03-27-18-42-45-image.png)
2. A "Select Cloud Phone" dialog will appear, listing all cloud phone devices under your account:
   
   ![](./assets/2026-03-27-18-43-23-image.png)

| Field          | Description                                      |
| -------------- | ------------------------------------------------ |
| No.            | Device number                                    |
| Cloud Phone ID | Unique device identifier                         |
| Device Status  | e.g., "Running" (green)                          |
| Bee Status     | e.g., "Installed / Running / Online" (green dot) |
| Notes          | User-defined device notes                        |

3. Check the target device and click **"Run"** — the script will be dispatched and executed immediately.

### Method 2: Run from the Editor

1. In the script editor, click the **"Select Cloud Phone"** button on the right panel.
2. In the dialog, click the radio button on the left of the target device row to select it (a blue dot indicates selection).
3. Click **"Confirm"** to bind the device — the cloud phone ID will appear in the right panel.
4. Click **"Run"** at the bottom to execute the script. Logs will appear in real time in the Output area.
   
   ![](./assets/2026-03-27-18-43-59-image.png)

> **Note**: Please ensure the selected cloud phone's Bee status shows "Installed / Running / Online" before running a script, otherwise execution may fail.

---

## 7. Task Center

After a script is run, the system automatically generates a task record in the **Task Center**, allowing you to track the execution status of every script run.

![](./assets/2026-03-27-18-44-28-image.png)

### 7.1 Accessing the Task Center

Click **"Task Center"** in the left navigation bar to view all run logs.

### 7.2 Filtering and Searching

The top of the page provides the following filters, which can be combined to quickly locate tasks:

| Filter         | Description                                              |
| -------------- | -------------------------------------------------------- |
| Cloud Phone ID | Filter by a specific cloud phone ID                      |
| Task Type      | Choose "All" or a specific type (e.g., Script Execution) |
| Run Status     | Choose "All", Success, Failed, Cancelled, etc.           |
| Execution Time | Select a date range                                      |

Click the **"Refresh"** button in the top-right corner to manually refresh the task list.

### 7.3 Task List Fields

| Field          | Description                                                        |
| -------------- | ------------------------------------------------------------------ |
| Task ID        | Unique system-generated task number, e.g., `T40177459306224588365` |
| Cloud Phone ID | The device that executed the task                                  |
| Task Type      | Currently all "Script Execution"                                   |
| Execution Time | When the task started, e.g., `2026-03-27 14:31`                    |
| Run Status     | See status descriptions below                                      |
| Actions        | Available operations for the task                                  |

### 7.4 Run Status Descriptions

| Status    | Color        | Meaning                                              |
| --------- | ------------ | ---------------------------------------------------- |
| Success   | Green        | Script completed successfully                        |
| Failed    | Red / Orange | An error occurred during execution                   |
| Cancelled | Gray         | Task was manually stopped or cancelled by the system |

### 7.5 Action Button Descriptions

Available action buttons vary depending on the run status:

| Button           | Description                                                  |
| ---------------- | ------------------------------------------------------------ |
| Re-run           | Run the task again with the same parameters                  |
| Execution Report | View detailed logs and error reports for the task            |
| Delete           | Remove this task record                                      |
| Step Execution   | Run the script step by step for debugging                    |
| Stop             | Terminate a currently running task (only shown when running) |

### 7.6 Viewing Task Execution Details

Click the **"Execution Report"** button to open the "Task Execution Details" dialog, which has two sections:

**① Print Output** (Left Side)

Displays real-time logs generated during script execution, for example:

```
14:31:03.980/V: Running [$files/tmp_script.js [cache]].
14:31:03.985/D: Script started
14:31:12.204/D: ---------- Round 1 ----------
14:31:18.189/D: Video watch duration: 4129ms
14:31:18.950/D: Random like triggered
14:31:20.956/E: TypeError: Cannot call method "click" of null.
14:31:20.960/V: finished in 16.978 seconds.
```

Log level guide: `V` = System info, `D` = Debug info, `E` = Error.

**② Execution Report** (Right Side)

When a script fails, the right side shows the specific error message and call stack to help pinpoint the issue, for example:

```
TypeError: Cannot call method "click" of null.
  at likeAndReturn (tmp_script.js:134:0)
  at main (tmp_script.js:164:0)
  at /data/user/0/...tmp_script.js:171:0
```

> **Tip**: If a task shows "Failed", check the Execution Report for the error details, then adjust your script code accordingly and re-run.

---

## 8. Important Notes

1. **Compliant Use**: Please follow the terms of service of each platform (TikTok, YouTube, etc.) to avoid account restrictions due to excessive automation.
2. **Parameter Tuning**: Set loop counts and timing parameters reasonably to simulate natural user behavior.
3. **Device Status**: Before running a script, confirm the cloud phone is in "Running" status and the Bee plugin is installed and online.
4. **Log Monitoring**: Monitor execution logs in real time via the Output area or Task Center to catch issues early.
5. **Stop When Needed**: Click "Stop Script" to terminate a running script promptly and avoid unnecessary resource consumption.
6. **Copy Before Editing**: When modifying a Store script, copy it to My Scripts first — changes to your copy will not affect the original Store version.

---

*For further assistance, click "Contact Us" in the bottom-right corner of the page.*
