Skip to content

Instantly share code, notes, and snippets.

@bilelz
Last active March 2, 2023 10:05
Show Gist options
  • Save bilelz/77b7573d1842055c49141dc9b9f8020c to your computer and use it in GitHub Desktop.
Save bilelz/77b7573d1842055c49141dc9b9f8020c to your computer and use it in GitHub Desktop.
Reveal items with data-testid attribute and copy list to clipboard
javascript: function revealDataTestId(){ const testStyle = document.createElement("style"); testStyle.innerText = '[data-testid]{outline: rgb(255, 87, 34) dashed 5px;}'; document.head.appendChild(testStyle); var list = [...new Set([...document.querySelectorAll('[data-testid]')].map((item) => item.getAttribute('data-testid')))].join('\r\n'); document.body.focus(); navigator.clipboard.writeText(list); setTimeout(()=>{ alert(list ? 'Copied to clipboard:\r\n'+list : 'No [data-testid] element found')},100);} revealDataTestId();
@bilelz
Copy link
Author

bilelz commented Mar 1, 2023

Script to drag and drop in the bookmark bar

Example :
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment