Last active
October 11, 2022 12:59
-
-
Save hogashi/05aac5212522d54bdeefe24efda83df0 to your computer and use it in GitHub Desktop.
asanaのlistビューで全部開いたり閉じたりするボタンを出すブックマークレット
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
javascript:(() => { | |
const closeAllButtonContainer = document.createElement('div'); | |
document.querySelector('.AddTaskDropdownButton').parentElement.appendChild(closeAllButtonContainer); | |
closeAllButtonContainer.classList.add('SecondarySplitDropdownMenuButton', 'AddTaskDropdownButton'); | |
const closeAllButton = document.createElement('div'); | |
closeAllButtonContainer.appendChild(closeAllButton); | |
closeAllButton.classList.add(...'ThemeableRectangularButtonPresentation--isEnabled ThemeableRectangularButtonPresentation ThemeableRectangularButtonPresentation--medium SecondarySplitDropdownMenuButton-leftButton SecondarySplitDropdownMenuButton-leftButton'.split(' ')); | |
closeAllButton.setAttribute('role', 'button'); | |
closeAllButton.textContent = 'Close/Open all sections'; | |
const makeSelector = has => `.TaskGroup--withHeader .TaskGroupHeader-toggleButton:has(${has})`; | |
closeAllButton.addEventListener('click', e => { | |
/* 1個でも開いてるなら全部閉じる (全部閉じてたら全部開く) */ | |
const selectorHas = document.querySelector(makeSelector('.DownTriangleIcon')) ? '.DownTriangleIcon' : '.RightTriangleIcon'; | |
document.querySelectorAll(makeSelector(selectorHas)).forEach(button => button.click()); | |
}); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment