Skip to content

Instantly share code, notes, and snippets.

@pelotom
Created March 11, 2021 22:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pelotom/115977348d0f1438ed20db3cce040953 to your computer and use it in GitHub Desktop.
Save pelotom/115977348d0f1438ed20db3cce040953 to your computer and use it in GitHub Desktop.
Add this to the relayx market page to see what orders are being added and removed
(() => {
if (__relayXSpy) {
__relayXSpy.disconnect();
}
var __relayXSpy = new MutationObserver(records => {
records.forEach(({ addedNodes, removedNodes }) => {
for (const added of addedNodes) {
console.log('added', printNode(added));
}
for (const removed of removedNodes) {
console.log('removed', printNode(removed));
}
});
})
__relayXSpy.observe(
document.getElementsByClassName('trade-orders')[0],
{ childList: true, attributes: false, subtree: false }
);
function printNode(node) {
const price = node.getElementsByClassName('order-price')[0].children[0];
const [amount, unit] = node.getElementsByClassName('order-amount')[0].children;
return `${amount.textContent} ${unit.textContent} at ${price.textContent}`
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment