-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollapse.js
More file actions
35 lines (32 loc) · 1.13 KB
/
Copy pathcollapse.js
File metadata and controls
35 lines (32 loc) · 1.13 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
31
32
33
34
35
function waitUntilLoaded(){
return new Promise((res, reject) => {
const intervalId = window.setInterval(() => {
const fileHeaders = document.getElementsByClassName('file-header-content');
if(fileHeaders.length > 0){
res(fileHeaders);
window.clearInterval(intervalId)
}
}, 2000)
})
}
function eventFire(el, etype){
if (el.fireEvent) {
el.fireEvent('on' + etype);
} else {
const evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
}
}
(async function() {
const fileHeaders = await waitUntilLoaded();
const fileHeadersArr = [].slice.call(fileHeaders);
fileHeadersArr.forEach(header => {
const title = header.childNodes[2].innerText;
const svgClassList = header.childNodes[0].classList.value;
const isCollapsed = svgClassList.includes('ic-chevron-right');
if((title.endsWith('graphql.js') || title.endsWith('.jpg')) && !isCollapsed){
eventFire(header.childNodes[0], 'click')
}
})
})();