Browse the docs

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 #

ParameterTypeRequiredValuesWhat it does
kittextWhich kit. Default: the kit this macro is in.
patterntextThe 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 #

Remember the newest check result
When
  1. The site answers “/graphql”
Do
  1. Save “graphql” to “last”
Open in Switchboard to try it

Gotchas #

  • The kit needs "mainWorld": true under permissions, and in Chrome Allow User Scripts, because the page's own fetch is 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.