A kit reads the site's data
Runs the macro when a page of a Site Kit's site answers one of its own requests, with the data the answer carries, before the page shows it.
The site answers pattern
Details #
For a macro in a Site Kit. The kit lists the response paths it may read in permissions.responses in its kit.json; this trigger names one of them in pattern (like /graphql or /*/pull/*/checks*). When the page makes a matching fetch or XHR request, the macro runs with the answer.
The run starts with url, status, method and body (JSON is already parsed). The data arrives before the page draws it, so the macro can act on what the site is about to show. Responses are observed, never changed or delayed: the page always gets the original.
kit is the kit's id (kit.github-plus). Leave it out and it is the kit this macro is in.
Switchboard asks the browser for a pattern only while a macro is listening for it, so answers nobody wants never leave the page. Bodies over 2 MB are skipped.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
kit | text | Which kit. Default: the kit this macro is in. | ||
pattern | text | The response path to read. It must be listed in the kit's permissions.responses. |
Every trigger also takes Limits: a cooldown, the first time each day, every nth time, twice within seconds, a chance, only while you are at the Mac, on one Mac, or in a State. See Limits on any trigger.
Examples #
- The site answers “/graphql”
- Save “graphql” to “last”
Gotchas #
The kit needs
"mainWorld": trueunderpermissions, and in Chrome Allow User Scripts, because the page's ownfetchis watched from inside the page.Only a kit's own site is watched; a macro outside a Site Kit has to name the kit with
kit.