v0.1.0
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.
The language consists of the following parts:
#.automation definition blocks:
automation for "{url pattern}" on "{stage: immediate | load | delay}"
# Here are the specific statements
end
statement Statements
Statements are written inside an automation block and can be divided into the following three categories:
set var = {value | variable | listen expression | get expression}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 setactive statement: active, used to select the current tabwait statement: wait {number}, used for waiting between two statements, in secondsclose statement: close, closes the current pageemit statement: emit "{eventName}" with (var1=1, var2=othervar), used to send a global event eventName to the browserlisten statement: listen "{eventName}" on "CssSelector | global", listens for events from the global or page scope, e.g., global |
body |
.cls |
apply "{actionName}" with (var1=1, var2=othervar, var=false, ...) on "CssSelector"apply statement can execute all built-in actions, and essentially, shortcut statements can be rewritten by apply statements.action can be viewed in the Action documentation.automation for "https://weibo.com/*" on "load"
apply "readMode" with (excludes=".Frame_wrap_16as0") on "#homeWrap"
end
## Language Grammar
Script ::= *empty*
::= Automations
Automations ::= Automation
::= Automations
Automation::= automation AutomationHead AutomationBody end
AutomationHead ::= for URLRegString on Stage
Stage ::= '"immediate"'
::= '"load"'
::= '"delay"'
URLRegString ::= string
AutomationBody ::= Statements
Statements ::= Statement
::= Statements
Statement ::= AssignStatement
::= NativeStatement
::= ApplyStatement
AssignStatement ::= AssignExp = ValuableExp
ValuableExp ::= ValueExp
::= Identifier
::= ListenExp
::= GetValueExp
ValueExp ::= number
::= string
::= bool
ListenExp ::= listen EventNameExp on EventScopeExp
EventNameExp ::= string
EventScopeExp ::= '"global"'
::= CssSelectorExp
NativeStatement ::= OpenStatement
::= ActiveStatement
::= WaitStatement
::= CloseStatement
::= EmitStatement
::= ListenStatement
OpenStatement ::= OpenExp
OpenExp ::= open URLString as URLRegString
URLString ::= string
ActiveStatement ::= ActiveExp
ActiveExp ::= active
WaitStatement ::= WaitExp
WaitExp ::= wait number
CloseStatement ::= close
EmitStatement ::= emit EventNameExp with ArgPairs
ListenStatement ::= ListenExp
ApplyStatement ::= apply ActionNameExp with ArgPairs on CssSelectorExp
ActionNameExp ::= string
ArgPairs ::= (ArgsExp)
ArgsExp ::= empty
::= ArgExp
::= ArgExp, ArgsExp
ArgExp ::= Identifier
::= Identifier = ValueExp
::= Identifier = Identifier
CssSelectorExp ::= string