Skip to content

Commit 4befc98

Browse files
committed
improve Script Variables section for JavaScript
1 parent eb9d9e9 commit 4befc98

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

site/dev/script-variables.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
---
22
titleTemplate: :title — PopClip Developer
33
---
4+
45
# Script variables
56

6-
When calling a script from a PopClip extension, the script receives a set of variables that describe the context in which the action was triggered. These variables are available in JavaScript, Shell Script, and AppleScript actions.
7+
When calling a script from a PopClip extension, the script receives a set of
8+
variables that describe the context in which the action was triggered. These
9+
variables are available in JavaScript, Shell Script, and AppleScript actions.
710

811
## JavaScript variables
912

10-
In JavaScript, you access variables in the `popclip` global object. See [JavaScript environment](https://www.popclip.app/dev/js-environment).
13+
In JavaScript, you access variables as properties under the `popclip` global.
14+
See:
15+
16+
- [`popclip.input`](https://pilotmoon.github.io/popclip-types/interfaces/Input.html)
17+
(e.g. `popclip.input.text`)
18+
- [`popclip.context`](https://pilotmoon.github.io/popclip-types/interfaces/Context.html)
19+
(e.g. `popclip.context.browserUrl`)
20+
- [`popclip.options`](https://pilotmoon.github.io/popclip-types/interfaces/Options.html)
21+
- [`popclip.modifiers`](https://pilotmoon.github.io/popclip-types/interfaces/Modifiers.html)
22+
23+
See also [JavaScript environment](https://www.popclip.app/dev/js-environment).
1124

1225
## Shell Script and AppleScript variables
1326

14-
All values are provided as strings. Where no value is available, it will be set to an empty string.
27+
All values are provided as strings. Where no value is available, it will be set
28+
to an empty string.
1529

16-
Within a shell script, PopClip sets script variables named like this: `POPCLIP_TEXT`,
17-
`POPCLIP_BROWSER_TITLE`, `POPCLIP_OPTION_FOO`, etc.
30+
Within a shell script, PopClip sets script variables named like this:
31+
`POPCLIP_TEXT`, `POPCLIP_BROWSER_TITLE`, `POPCLIP_OPTION_FOO`, etc.
1832

19-
Within an AppleScript, PopClip pre-processes the script to replace placeholders with strings. Placeholders look like this: `{popclip text}`,
33+
Within an AppleScript, PopClip pre-processes the script to replace placeholders
34+
with strings. Placeholders look like this: `{popclip text}`,
2035
`{popclip browser title}`, `{popclip option foo}`, etc.
2136

2237
### Available variables

0 commit comments

Comments
 (0)