Last active
September 25, 2021 19:09
-
-
Save ricklamers/a7141343fd1a6037aaa1a0e6a81f19ac to your computer and use it in GitHub Desktop.
Expand all folders in VS Code (run in console)
This file contains 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
function getUnexpandedListItems() { | |
return document.querySelectorAll(".monaco-list-row[aria-expanded=false]"); | |
} | |
function expandItems(items) { | |
for (let item of items) { | |
item.click(); | |
} | |
} | |
let nothingFoundFrequency = 0; | |
let interval = setInterval(() => { | |
let items = getUnexpandedListItems(); | |
if (items.length > 0) { | |
nothingFoundFrequency = 0; | |
expandItems(items); | |
} else { | |
nothingFoundFrequency += 1; | |
// Try 1000 times (>= 1 second) because perhaps | |
// the unfolding is still "settling". | |
if (nothingFoundFrequency > 1000) { | |
clearInterval(interval); | |
console.log("Done unfolding."); | |
} | |
} | |
}, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment