hubcap block

Block network requests matching URL patterns.

When to use

Block network requests that match one or more URL patterns, such as ads, tracking scripts, or specific resource types. Use --disable to remove all active block rules. Use intercept instead if you need to modify request or response content rather than simply blocking.

Usage

hubcap block <pattern>... [--disable]

Arguments

ArgumentTypeRequiredDescription
patternstringYesOne or more URL patterns to block. Supports * wildcards.

Flags

FlagTypeDefaultDescription
--disableboolfalseDisable URL blocking and remove all block rules

Output

FieldTypeDescription
enabledbooleanWhether blocking is active
patternsstring[]List of active block patterns (when enabled)

When rules are set:

{"enabled":true,"patterns":["*.css","*.png"]}

When disabled:

{"enabled":false}

Errors

ConditionExit codeStderr
No patterns provided and --disable not set1usage: hubcap block <pattern>... [--disable]
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Block ad and tracking requests:

hubcap block "*ads*" "*tracking*" "*analytics*"

Block all CSS and image files:

hubcap block "*.css" "*.png" "*.jpg"

Remove all block rules:

hubcap block --disable

Block third-party scripts, then take a screenshot to measure visual impact:

hubcap block "*cdn.third-party.com*" && hubcap screenshot --output page-no-thirdparty.png

See also

  • intercept - Intercept and modify requests or responses
  • throttle - Simulate slow network conditions
  • network - Monitor network traffic