Created
March 11, 2021 22:56
-
-
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
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
(() => { | |
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