replace-outbound-value

replace-outbound-value

The replace-outbound-value snippet overrides return values of functions or attributes according to the given parameters.

Parameters

Name

Description

Mandatory

Default

method

The method to trap (any function or attribute under window, e.g. JSON.stringify, atob).

Yes

n.a.

search

The text or regex pattern to replace.

Yes

n.a.

replacement

The replacement text.

No

empty string

decodeMethod

Decode method before replacing. Currently only "base64" supported.

No

empty string

path

Dot-separated path to the property in returned objects.

No

empty string

stack

Comma-separated list of strings to check in the stack trace.

No

empty string

Filter examples

Filter

Result

replace-outbound-value 'JSON.stringify' '"ads":true' '"ads":false'

Replaces "ads":true with "ads":false in JSON.stringify output.

replace-outbound-value 'testObj.getText' '/first.*second/' ''

Removes text matching the regex from the return value.

replace-outbound-value 'btoa' 'ads' 'content' 'base64'

Replaces 'ads' with 'content' in base64 encoded output.

replace-outbound-value 'testObj.getData' 'premium' 'basic' '' 'user.profile.name'

Replaces 'premium' with 'basic' only in user.profile.name.