← All examples

JavaScript Developer & QA pinterest.com

Pinterest: outline data-test-id elements

Draws outlines around elements with a data-test-id attribute and shows their values to help write your own rules.

Code to copy

// Outline every element carrying a data-test-id and show its value
const STYLE_ID = 'jz-pin-outline-style';
if (!document.getElementById(STYLE_ID)) {
  const s = document.createElement('style');
  s.id = STYLE_ID;
  s.textContent =
    '[data-test-id]{outline:1px solid rgba(230,0,35,0.6)!important;position:relative!important}' +
    '[data-test-id]::after{content:attr(data-test-id);position:absolute;top:0;left:0;' +
    'background:#e60023;color:#fff;font:10px monospace;padding:1px 3px;z-index:99999}';
  document.head.appendChild(s);
}

How to use this example

  1. Copy the code with the button above.
  2. Install JustZix (2 minutes) and open the extension on the target page.
  3. Add a new rule matching that page.
  4. Paste the code into the rule's JavaScript panel and save — it runs on every page visit.

Rate this example

No ratings yet — be the first.

Does this example work?

Snippets are useless without somewhere to paste them.

JustZix takes 2 minutes to install and runs your code on every matching page. No account, no payment.

Download free See use cases