Last active
March 2, 2023 10:05
-
-
Save bilelz/77b7573d1842055c49141dc9b9f8020c to your computer and use it in GitHub Desktop.
Reveal items with data-testid attribute and copy list to clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script to drag and drop in the bookmark bar
Example :
