LogoLogo
About GitLabAcceptable Ads
  • Getting Started
  • Browser Ad-Filtering Solution
    • Features
    • Getting Started
      • Quickstart
      • Integrate the Solution
      • Set up user counting
    • Guides
      • User counting
      • Configure Solution settings
      • Run separate instances of the filtering engine
      • Update the Solution
      • Understand the snippets library
      • Create a filter list
      • Testing
    • Advanced
      • Services and classes
      • Sitekey
      • ADRs
      • Frame hierarchy
  • Snippets
    • Snippets Overview
    • Behavioral Snippets
      • abort-current-inline-script
      • abort-on-property-read
      • abort-on-property-write
      • abort-on-iframe-property-read
      • abort-on-iframe-property-write
      • array-override
      • cookie-remover
      • freeze-element
      • json-override
      • json-prune
      • override-property-read
      • prevent-listener
      • replace-fetch-response
      • replace-xhr-response
      • simulate-mouse-event
      • skip-video
      • strip-fetch-query-parameter
    • Conditional Hiding Snippets
      • hide-if-canvas-contains
      • hide-if-contains
      • hide-if-contains-image
      • hide-if-contains-similar-text
      • hide-if-contains-visible-text
      • hide-if-contains-and-matches-style
      • hide-if-has-and-matches-style
      • hide-if-labelled-by
      • hide-if-matches-computed-xpath
      • hide-if-matches-xpath
      • hide-if-matches-xpath3
      • hide-if-shadow-contains
    • Debugging Snippets
      • debug
      • log
      • profile
      • trace
    • Performance Snippets
      • race
    • Snippets Support by Platform
    • Node Highlighting
    • Accessing shadow DOM elements
  • Working with filters
  • DATA AND PRIVACY
    • Data collection at eyeo
Powered by GitBook
On this page
  • Parameters
  • Filter examples
  • Debugging

Was this helpful?

Edit on GitLab
Export as PDF
  1. Snippets
  2. Behavioral Snippets

array-override

The array-override overrides functions under Array.prototype to change their behaviour according to the given parameters. .

Parameters

Name
Description
Mandatory
Default value

method

The Array function to override. Possible values to override the property with: push, includes.

Yes

n.a.

needle

The string or regex used to determine which function calls to trap. If the needle matches the parameter to the function call, the snippet will work, else the function will behave as normal. If the string begins and ends with a slash ( / ), the text in between is treated as a regular expression.

Yes

n.a.

returnValue

Optional parameter that is only relevant for includes. This parameter determines what to return when the parameter matches the needle. Accepts: true or false. Default is false.

No

false

Filter examples

Filter
Result

array-override push test

Will ignore array.push(“test“) while allowing other values to be added to the array. Example: const arr = []; arr.push(“1“); arr.push(“2“); arr.push(“test“) arr will only have the values “1” and “2” inside of it.

array-override push /first.*second/

Will ignore the call if the parameter to array.push starts with “first“ and ends with “second“ while allowing other values to be added to the array. Example: const arr = []; arr.push(“1“); arr.push(“2“); arr.push(“first-123-second“) arr will only have the values “1” and “2” inside of it.

array-override includes test true

array.includes(“test“) will always return true regardless of whether it’s in the array or not.

array-override includes /first.*second/ false

array.includes(“first-123-second“) will always return false regardless of whether it’s in the array or not.

Debugging

The following table contains messages you'll find useful during debugging:

Message
When the error occurs
Definition

Wrapped Array.prototype.push

After we have wrapped the Array.prototype.push API.

From this moment on push calls are intercepted by us.

Wrapped Array.prototype.includes

After we have wrapped the Array.prototype.includes API.

From this moment on includes calls are intercepted by us.

Array.push is ignored for needle: <> FILTER: array-override <>

Needle matches a call to Array.push.

The call to Array.push was ignored.

Array.includes returned <> for <> FILTER: array-override <>

Needle matches a call to Array.includes.

Array.includes returned the value given with returnValue instead of the correct value.

Last updated 2 months ago

Was this helpful?