Site owners: public widget API and advanced masking
Use window.OmnifoxCobrowse.mask() and the data-rrweb-mask attribute to hide bespoke sensitive fields during co-browse.
Watch this step in the video · What the customer types stays hidden
What it is and when you need it
Omnifox co-browse masks passwords and card data by default before the agent sees anything. But if your site has bespoke sensitive fields (a custom payment component, an ID input built from a <div contenteditable>, a non-standard widget), the automatic detector may not recognize them. For those cases the widget exposes a public API on window.OmnifoxCobrowse, aimed at site owners.
Important: masking runs in the customer's browser, before the DOM is sent. A masked field never reaches the agent.
Requirements
- The Co-browse add-on active on your organization (Billing → Co-browse).
- The Webchat widget installed on your site (the
cobrowse.jsbundle loads on demand when a session starts).
The public API
While a session is active, window.OmnifoxCobrowse offers:
OmnifoxCobrowse.mask(selectorOrElement)— marks an element (or every match of a CSS selector) as masked. Returns how many elements it tagged.OmnifoxCobrowse.getState()— returns the current state (idle,awaiting_consent,connecting,streaming,ended). Handy for debugging.OmnifoxCobrowse.start(params)/OmnifoxCobrowse.end(reason?)— used internally by the widget; you normally don't call these.
Steps to mask your own fields
- Find the CSS selector of your sensitive field (e.g.
#custom-cardor.cvv-input). - Call the API once the field exists in the DOM:
if (window.OmnifoxCobrowse) {
window.OmnifoxCobrowse.mask('#custom-card');
window.OmnifoxCobrowse.mask('.cvv-input');
}
- If your app is a SPA and the field appears later, call
mask()again after it renders. The call is idempotent — masking twice is harmless.
No-code alternative: the data-rrweb-mask attribute
If you'd rather not touch JavaScript, add data-rrweb-mask="true" straight to the element's HTML. It hides both the typed value and the rendered text (ideal for a <span> showing an already-loaded card number). The widget honors that attribute, and the automatic detector tags fields with the very same one.
Verification
- Start a test session from the Inbox (the Start co-browsing button).
- In the agent view, type into your custom fields: they should appear as a redacted block, not the real content.
- In the customer's browser console,
window.OmnifoxCobrowse.getState()should returnstreaming.
If it doesn't work
window.OmnifoxCobrowseisundefined: the bundle hasn't loaded yet. It only exists during a session — wrap your calls inif (window.OmnifoxCobrowse).- The field is still visible: check that the selector matches (test with
document.querySelectorAll('#your-selector')). If the element is recreated, re-applymask(). - You want to hide a whole container: mask the container; masking applies to the rendered subtree.
Tips
- Third-party payment forms embedded in an
<iframe>are not transmitted at all, so they're already protected. - Combine the API with keywords: naming inputs with terms like
cardorcvvlets the detector hide them on its own.
Related articles
Related articles
-
What Co-browse is and how to enable it
Co-browse lets you see the customer's screen in real time to guide them better. Learn how to enable it.
-
Co-browse complete guide
Co-browse in depth, in 32 chapters: radar, identified visitors, consent, remote control, masking, marks, voice call, page changes and how a session ends, all real.
-
Co-browse: add-on tiers and pricing
Co-browse is bought separately on any plan: Standard 50 USD/mo (3 concurrent sessions), Pro 90 (6), Business 150 (10) and custom Enterprise.
-
How to start a Co-browse session with a customer
Step by step to invite the customer to share their screen and guide them in real time.
-
Prerequisites for using Co-browse
Before you start your first Co-browse session, check the add-on, your permissions and the Webchat channel conditions.