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

Was this helpful?

Edit on GitLab
Export as PDF
  1. Snippets
  2. Conditional Hiding Snippets

hide-if-canvas-contains

The hide-if-canvas-contains hides a canvas element, or a parent element specified by the selector parameter, if the canvas contains the specified search term in it.

We override the fillText and strokeText canvas methods. When a website uses this functions, it won’t use the native functions but instead use our overriden proxy. This allows us to know when a website writes a text we are interested in (Sponsored, Advertised etc.) to the and hide the ad.

Parameters

Name
Description
Mandatory
Default

search

String or regex pattern that will be searched in fillText and strokeText

Yes

-

selector

The selector identifies the HTML element to hide. This can be the canvas element itself or a parent of the canvas. Defaults to the element if not provided.

No

canvas

Filter examples

The following table lists examples that use the hide-if-canvas-contains snippet:

Filter
Result

hide-if-canvas-contains /sponsored/

Hides any canvas element whose text content matches sponsored and has been added with a fillText or strokeText call.

hide-if-canvas-contains /sponsored/ .canvas-parent

Hides any HTML element with a class class-parent that contains a canvas element whose text content matches sponsored and has been added with a fillText or strokeText call.

Last updated 2 months ago

Was this helpful?