Last active
February 6, 2020 04:04
-
-
Save r-k-b/9e341370159e87b7f8b09200660e93ea to your computer and use it in GitHub Desktop.
Expand all the entries in an Elm Debugger window.
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
// Intended to be run from the Snippets panel in Chrome Dev Tools, targeting the Elm Debugger popout window. | |
// https://gist.github.com/r-k-b/9e341370159e87b7f8b09200660e93ea | |
(() => { | |
// these are multiple megabytes in size, too big to diff | |
const blacklist = ['lookup', 'repository', 'historyDetail', 'templateInfos']; | |
const getChevrons = () => { | |
const all = [...document.querySelectorAll('span[style*="width: 2ch"]')] | |
.map(node => ({node, label: node.nextSibling.textContent})) | |
.filter(chev => !blacklist.includes(chev.label)); | |
return ({ | |
all, | |
unopened: all.filter(chev => chev.node.textContent === "▸"), | |
}) | |
}; | |
const {unopened, all} = getChevrons(); | |
const toOpenCount = unopened.length; | |
const allChevronsCount = all.length; | |
console.info( | |
`Opening ${toOpenCount} of ${allChevronsCount - toOpenCount} items...`, | |
unopened.map(chev => chev.label) | |
); | |
unopened.forEach(chev => { | |
chev.node.click(); | |
}); | |
const postClick = getChevrons(); | |
console.info(`new chevron counts`, { | |
unopened: postClick.unopened.length, | |
all: postClick.all.length, | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment