-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
107 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ public/manifest.json | |
utils/reload/*.js | ||
utils/reload/injections/*.js | ||
.turbo | ||
/docs | ||
/typesdoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## 版本 | ||
v0.1.0 | ||
|
||
## 语言概述 | ||
该语言用于定义自动化脚本,可以通过该脚本来创建浏览器的自动化操作,例如打开网页、点击、输入文字等,从而提高浏览的体验与效率。 | ||
|
||
## 语言规则 | ||
该语言由以下几个部分组成: | ||
1. 注释,支持单行以及行内注释,以 `#` 开头 | ||
2. `automation` 定义块: | ||
```ruby | ||
automation for "{url pattern}" on "{stage: immediate | load | delay}" | ||
# 这里是具体的语句 | ||
end | ||
``` | ||
3. `statement` 语句 | ||
语句写在 `automation` 块里,主要有以下三大类语句: | ||
- 赋值语句 | ||
- 格式为: `set var = {值 | 变量 | listen 表达式 | get 表达式}` | ||
|
||
- 快捷语句 | ||
- `open` 语句: `open "{url}" as "{url pattern}"`,用以打开 `url`,仅当 `url pattern` 集合中的页面已经存在时才会创建新标签页 | ||
- `active` 语句:`active`, 用于选中当前标签页 | ||
- `wait` 语句: `wait {number}`, 用以两条语句间的等待,以秒为单位 | ||
- `close` 语句: `close`, 关闭当前页面 | ||
- `emit` 语句: `emit "{eventName}" with (var1=1, var2=othervar)`,用于向浏览器发出全局事件`eventName` | ||
- `listen` 语句: `listen "{eventName}" on "CssSelector | global"`,监听来自全局或页面的事件,例如 `global` | `body` | `.cls` | ||
|
||
- 执行语句 | ||
- 格式为: `apply "{actionName}" with (var1=1, var2=othervar, var=false, ...) on "CssSelector"` | ||
- `apply` 语句可以执行所有内置的 `action`;本质上讲,快捷语句也都可以由 `apply` 语句改写。 | ||
|
||
|
||
## 例子 | ||
- 微博阅读模式 | ||
```ruby | ||
automation for "https://weibo.com/*" on "load" | ||
apply "readMode" with (excludes=".Frame_wrap_16as0") on "#homeWrap" | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## Version | ||
v0.1.0 | ||
|
||
## Language Overview | ||
This language is used to define automation scripts that can be used to perform automated operations in a web browser, such as opening a webpage, clicking, inputting text, and more, in order to improve browsing experience and efficiency. | ||
|
||
## Language Rules | ||
The language consists of the following parts: | ||
1. Comments, which support single-line and inline comments starting with `#`. | ||
2. `automation` definition blocks: | ||
```ruby | ||
automation for "{url pattern}" on "{stage: immediate | load | delay}" | ||
# Here are the specific statements | ||
end | ||
``` | ||
|
||
3. `statement` Statements | ||
Statements are written inside an `automation` block and can be divided into the following three categories: | ||
- Assignment statements | ||
- The format is: `set var = {value | variable | listen expression | get expression}` | ||
|
||
- Shortcut statements | ||
- `open` statement: `open "{url}" as "{url pattern}"`, used to open the `url`, and only creates a new tab if the page is not already present in the `url pattern` set | ||
- `active` statement: `active`, used to select the current tab | ||
- `wait` statement: `wait {number}`, used for waiting between two statements, in seconds | ||
- `close` statement: `close`, closes the current page | ||
- `emit` statement: `emit "{eventName}" with (var1=1, var2=othervar)`, used to send a global event `eventName` to the browser | ||
- `listen` statement: `listen "{eventName}" on "CssSelector | global"`, listens for events from the global or page scope, e.g., `global` | `body` | `.cls` | ||
|
||
- Execution statements | ||
- The format is: `apply "{actionName}" with (var1=1, var2=othervar, var=false, ...) on "CssSelector"` | ||
- The `apply` statement can execute all built-in `action`s, and essentially, shortcut statements can be rewritten by `apply` statements. | ||
|
||
## Example | ||
- Weibo Read-Mode | ||
```ruby | ||
automation for "https://weibo.com/*" on "load" | ||
apply "readMode" with (excludes=".Frame_wrap_16as0") on "#homeWrap" | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
"entryPoints": [ | ||
"src/builtin/*.ts", | ||
], | ||
"out": "docs" | ||
"out": "typesdoc" | ||
} |