# tools for openharmony repo **Repository Path**: milkpotatoes/tools-for-openharmony-repo ## Basic Information - **Project Name**: tools for openharmony repo - **Description**: No description available - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-09-09 - **Last Updated**: 2026-04-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # OpenHarmony PR Utility Tools **Language:** [中文](README.md) | English This project provides utility tools for OpenHarmony Pull Request (PR) management, including a userscript that adds convenient quick action buttons to PR pages, enabling efficient operations such as triggering CI checks, navigating pages, and adding custom buttons. --- ## Table of Contents - [OpenHarmony PR Utility Tools](#openharmony-pr-utility-tools) - [Table of Contents](#table-of-contents) - [PR Assistant](#pr-assistant) - [Quick Installation](#quick-installation) - [Supported Shortcuts](#supported-shortcuts) - [Add Custom Buttons](#add-custom-buttons) - [Configuration Example](#configuration-example) - [Configuration Properties](#configuration-properties) - [Name `name`](#name-name) - [Display Label `label`](#display-label-label) - [Tooltip `comment`](#tooltip-comment) - [Element Type `type`](#element-type-type) - [Style `style`](#style-style) - [Button Enable Rules `enable`](#button-enable-rules-enable) - [Button Positioning `position`](#button-positioning-position) - [Button Resources `resources`](#button-resources-resources) - [Events `events`](#events-events) - [Command Syntax Rules](#command-syntax-rules) - [Available Context Parameters](#available-context-parameters) - [Command Examples](#command-examples) - [Changelog](#changelog) - [API Reference](#api-reference) --- ## PR Assistant PR Assistant is a userscript that provides quick action functionality for OpenHarmony repository Pull Request pages. ### Quick Installation - ~~[Gitee Version](https://gitee.com/milkpotatoes/tools-for-openharmony-repo/raw/master/pull-request/ci-helper.user.js)~~ - [GitCode Version](https://gitee.com/milkpotatoes/tools-for-openharmony-repo/raw/master/pull-request/ci-helper-gitcode.user.js) ### Supported Shortcuts | Feature | Description | |---------|-------------| | Trigger/Stop OpenHarmony Gatekeeper | Quickly control CI gatekeeper checks | | Trigger/Stop GGWatcher | Control Watcher for arkcompiler series repositories | | Focus comment input box | Quickly jump to the comment input area | | Jump to bottom | Quickly scroll to the bottom of the page | | Back to top | Double-click the bottom button to quickly return to the top | --- ## Add Custom Buttons The script supports adding custom buttons through configuration to implement personalized quick action features. ### Configuration Example ```json [{ "name": "open-workspace", "label": {"default": "open_in_new"}, "style": ["material-icons", "transparent"], "enable": ["arkcompiler_*", "page:COMMENTS"], "events": { "click": "open /pulls" } }] ``` ### Configuration Properties #### Name `name` The unique identifier for the button, must be unique. Some commands rely on this name for storage. #### Display Label `label` The display text of the button, can be a string or multilingual resource object. When the button has the `material-icons` style, it will be displayed as an icon. #### Tooltip `comment` The tooltip text displayed when hovering over the button, supports string or multilingual resource object. #### Element Type `type` The type of the element, optional values: - `button` (default) - `group` #### Style `style` Built-in style classes in the script: | Style Name | Description | |------------|-------------| | `red` | Red theme | | `green` | Green theme | | `transparent` | Transparent background | | `note-style` | Note style | | `material-icons` | Material Design icon | | `hover-effect` | Show highly transparent black background on hover | | `hover-darkness` | Remove default hover darkening effect | > **Tip:** You can use `css:name: value` syntax to customize CSS styles. #### Button Enable Rules `enable` Supports three matching rules that can be combined: 1. **Repository name matching** - Use `*` as a wildcard - `arkcompiler_*` matches all repositories starting with `arkcompiler_` - `arkui_napi` exactly matches the `arkui_napi` repository - > **Note:** The script only works in `OpenHarmony` series repositories 2. **Page matching** - Use `page:` syntax - `COMMENTS` - Comments page - `COMMITS` - Commits page - `FILES` - Files page - `CHECKS` - Checks page (GitCode specific) 3. **PR state matching** - Use `state:` syntax - `CLOSED` - Closed - `OPEN` - Open - `MERGED` - Merged - `CONFLICTED` - Conflicted - `DRAFT` - Draft #### Button Positioning `position` Control the position of the button in the action bar: | Position Rule | Description | |---------------|-------------| | `begin` | Place at the front (left) of the action bar | | `end` | Place at the end (right) of the action bar (default) | | `before:` | Place before the specified button | | `after:` | Place after the specified button | | `append:` | Add to the specified button group | > **Tip:** Button names and group names can be found in [`pull-request/ci-helper-buttons.js`](pull-request/ci-helper-buttons.js) #### Button Resources `resources` Resource declarations read via the `resource` command, supporting multilingual and constants: ```json5 { // Multilingual resource example "res0": { "default": "@en", // Default value, @lang means referencing other language resources "zh-CN": "中文资源", "en": "English Resource" }, // Constant resource example "res1": "Resource 1" } ``` #### Events `events` Define event behaviors for the button, supporting browser native events and special events: - **`create`** - Automatically triggered when the button is created - Other events (e.g., `click`) - Triggered on user interaction Event handling uses predefined commands with a syntax style similar to Shell or command line. ##### Command Syntax Rules - Multiple commands use **array** or `\n` newline separation - Parameters separated by **spaces** - Parameters containing spaces enclosed in **double quotes** (e.g., `"my value"`) - Use **single quotes** or **backslash** to prevent variable substitution (e.g., `'{name}'` or `\{name\}`) > **Note:** Currently does not support using the `data` field directly as a command ##### Available Context Parameters | Parameter | Description | |-----------|-------------| | `{repo}` | Repository name | | `{author}` | PR author/creator | | `{lang}` | Browser language (e.g., `zh-CN`, `en`) | | `{state}` | PR state (e.g., `open`, `closed`) | | `{page}` | Current page name | | `{id}` | PR ID | | `{data}` | Button custom data | | `{label}` | Button original text label (constant) | | `{returns}` | Execution result of the previous command | ##### Command Examples ```sh open /openharmony/{repo} log "Author: {author}" if "{state}" == "open" comment "This PR is still open." ``` --- ## Changelog View detailed version update records: [CHANGELOG_en.md](doc/CHANGELOG_en.md) --- ## API Reference Complete command and parameter list: [REFERENCE_en.md](doc/REFERENCE_en.md)