-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaddCopyJSON.js
34 lines (31 loc) · 1.12 KB
/
addCopyJSON.js
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
31
32
33
34
function loadConsoleJSONWatcher(){
let MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
let myObserver = new MutationObserver(function(mutList){
[...mutList].map(function(mut){
[...mut.addedNodes].map(function(e){
if(e.classList.contains('OEEexJSONAnalysis'))
return;
e.classList.add('OEEexJSONAnalysis')
let myObserverLocal = new MutationObserver(function(val){
val=[...val.map(e => Array.from(e.addedNodes))].flat();
let button=val.filter(o=>o.classList.contains('json-switch'))[0];
let pre=val.filter(o=>o.tagName=='PRE')[0];
if (pre && button) {
button.addEventListener('dblclick',function(el){
navigator.clipboard.writeText(pre.innerText);
})
}
myObserverLocal.disconnect();
});
let obsConfig = { childList: true};
let obj=e.querySelector('.explorer.loading');
if(obj)
myObserverLocal.observe(obj, obsConfig);
});
});
});
let obsConfig = { childList: true};
if(document.querySelector('ee-console'))
myObserver.observe(document.querySelector('ee-console'), obsConfig);
}
loadConsoleJSONWatcher();