"COLLAPSE (or re-expand) ALL SECTIONS" button needed

Hi @Max_Michaels , the bookmarklet works for me to collapse all sections.
To expand sections, we need to change DownTriangleIcon to RightTriangleIcon.

Sectionts 2

If we want to collapse and expand all sections with one bookmarklet, use conditional branching like this:

javascript:(function(){
	const firstButtonIcon = document.querySelector('.TaskGroupHeader-toggleButton .Icon');
	if (!firstButtonIcon) return;
	const firstTriangleClassName = firstButtonIcon.classList.contains('DownTriangleIcon')? 'DownTriangleIcon': 'RightTriangleIcon';
	document.querySelectorAll(`.TaskGroupHeader-toggleButton .${firstTriangleClassName}`).forEach(buttonIcon => buttonIcon.parentNode.click());
})();

Editing the bookmarklet:

Update in July 2022: I created Introduction to Asana bookmarklets to discuss more about bookmarklets and show more examples.

4 Likes