Last active
February 5, 2024 10:42
-
-
Save PhoneDroid/88ccad17e9cc4efd7a14c7f9be2b20ab to your computer and use it in GitHub Desktop.
Queries the first JSON-LD schema and copies it when clicking on the page.
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
| const script = document.querySelector(`[ type = 'application/ld+json' ]`) | |
| const raw = script.textContent | |
| const text = JSON.stringify(JSON.parse(raw),null,4) | |
| async function log (){ | |
| document.removeEventListener('click',log) | |
| await navigator.clipboard.writeText(text) | |
| console.clear() | |
| console.debug(text) | |
| window.alert(`Copied Schema.org Data`) | |
| } | |
| document.addEventListener('click',log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment