-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquick_commands.js
More file actions
30 lines (24 loc) · 1.02 KB
/
quick_commands.js
File metadata and controls
30 lines (24 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Finds and clicks the whatnot header
document.querySelectorAll("[data-cy=\"Sold\"]").forEach(it => it.click())
// Observes changes to the dom
// TODO CLean up
var observeDOM = (function(){
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
return function( obj, callback ){
if( !obj || obj.nodeType !== 1 ) return;
if( MutationObserver ){
// define a new observer
var mutationObserver = new MutationObserver(callback)
// have the observer observe for changes in children
mutationObserver.observe( obj, { childList:true, subtree:true })
return mutationObserver
}
// browser support fallback
else if( window.addEventListener ){
obj.addEventListener('DOMNodeInserted', callback, false)
obj.addEventListener('DOMNodeRemoved', callback, false)
}
}
})()
// After setting the chat to $0 use this to bind to it to get the chat message.
observeDOM($0, (ele) => console.log(ele[0].addedNodes[0].childNodes[1].childNodes[1].textContent))