Skip to content

Instantly share code, notes, and snippets.

@hogashi
Last active October 11, 2022 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hogashi/05aac5212522d54bdeefe24efda83df0 to your computer and use it in GitHub Desktop.
Save hogashi/05aac5212522d54bdeefe24efda83df0 to your computer and use it in GitHub Desktop.
asanaのlistビューで全部開いたり閉じたりするボタンを出すブックマークレット
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