Screen-sharing mask with explicit markers
Mark sensitive text when rendering, including partial updates; this avoids recognizing money with regexes or guessing columns from translated captions. Keep headings outside the mask. The mask preserves dimensions. Use text-only spans for this minimal example.
<button id="privacy-toggle" type="button" aria-pressed="false">Hide amounts</button>
<span data-sensitive>$13 320</span>
body.prices-hidden [data-sensitive] {
color: transparent;
background: black;
border-radius: 2px;
user-select: none;
}
Load the following script after the button. Existing and future marked spans follow the body class, so no DOM-walking observer is needed. The example falls back to the current page if the browser does not allow local storage.
const privacyButton = document.getElementById('privacy-toggle');
const privacyKey = 'example.ui.hide-amounts';
function setPrivacy(hidden) {
document.body.classList.toggle('prices-hidden', hidden);
privacyButton.setAttribute('aria-pressed', String(hidden));
privacyButton.textContent = hidden ? 'Show amounts' : 'Hide amounts';
try { localStorage.setItem(privacyKey, String(hidden)); } catch { /* Page-only preference. */ }
}
let initiallyHidden = false;
try { initiallyHidden = localStorage.getItem(privacyKey) === 'true'; } catch { /* Use default. */ }
setPrivacy(initiallyHidden);
privacyButton.addEventListener('click', () => {
setPrivacy(!document.body.classList.contains('prices-hidden'));
});
This is cosmetic masking for a display, not security or export redaction. The underlying text remains available in the DOM and to assistive technology. Applications choose which values to mark; stok additionally masks selected project and purchase identifiers.