Skip to content

Instantly share code, notes, and snippets.

@johnsaigle
Created August 23, 2024 16:20
Show Gist options
  • Select an option

  • Save johnsaigle/ebacaffdfe327a7e448eebbb0b605256 to your computer and use it in GitHub Desktop.

Select an option

Save johnsaigle/ebacaffdfe327a7e448eebbb0b605256 to your computer and use it in GitHub Desktop.
Easily log elements that match an XPath selector
// 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