Created
August 23, 2024 16:20
-
-
Save johnsaigle/ebacaffdfe327a7e448eebbb0b605256 to your computer and use it in GitHub Desktop.
Easily log elements that match an XPath selector
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
| // Easily log elements that match an XPath selector | |
| selector = '' | |
| // Using var in case you mess up the selector and want to run this again. | |
| // using let or const instead will create re-declaration errors. | |
| var matches = document.evaluate( | |
| selector, | |
| document, | |
| null, | |
| XPathResult.ANY_TYPE, | |
| null, | |
| ); | |
| var current= matches.iterateNext(); | |
| var results = [] | |
| while (current) { | |
| // console.log(current.textContent); | |
| results.push(current.textContent) | |
| current = matches.iterateNext(); | |
| } | |
| console.log(results); | |
| // Then do right-click > Copy Object to get something like this: | |
| // [ | |
| // "confirmTransaction", | |
| // "getConfirmedBlock", | |
| // "getConfirmedBlocks", | |
| // "getConfirmedBlocksWithLimit", | |
| // "getConfirmedSignaturesForAddress2", | |
| // "getConfirmedTransaction", | |
| // "getFeeCalculatorForBlockhash", | |
| // "getFeeRateGovernor", | |
| // "getFees", | |
| // "getRecentBlockhash", | |
| // "getSignatureConfirmation", | |
| // "getSignatureStatus", | |
| // "getSnapshotSlot", | |
| // "getStakeActivation" | |
| // ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment