Contents

NetPeek for iOS

Scripts and constants

Run JavaScript in the tunnel when rewrite rules are not enough, and reuse values through constants.

Scripts execute JavaScript in the same tunnel as rewrite rules, scoped by host. Use them for branching, combined transformations, or scheduled work. Prefer rewrite rules for a single header, body, or mock change.

Create a script

  1. Open Scripts and tap +. Set a name and host scope.
  2. Choose Before Request, After Response, or a scheduled trigger.
  3. Write the logic. Helpers such as $utils provide gzip/gunzip.
  4. Save, enable the script, and turn on the global Scripts gate. Resend traffic to verify.

Constants

Store a mock JSON, token, or test URL as a constant and reference it from expert-mode rules with ${constantId}. Changing the constant updates every reference. Simple-mode Mock already assembles the response, so constants matter most when several expert rules share a value.