Skip to content

Instantly share code, notes, and snippets.

@hogashi
Last active October 11, 2022 12:53
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/04943a035040d717d07f1b5589df4852 to your computer and use it in GitHub Desktop.
Save hogashi/04943a035040d717d07f1b5589df4852 to your computer and use it in GitHub Desktop.
asanaのlistビューで自動でスクロールして全部読み込みながらセクションを全部閉じていくブックマークレット
javascript:(() => {
const scroller = document.querySelector('.SpreadsheetGridScroller-verticalScroller');
const scrollHeightHistory = [-100];
const timer = setInterval(() => {
/* 開いてるのを閉じる */
document.querySelectorAll('.TaskGroup--withHeader .TaskGroupHeader-toggleButton:has(.DownTriangleIcon)').forEach(button => button.click());
console.log(scroller.scrollHeight);
scrollHeightHistory.push(scroller.scrollHeight);
if (
/* 1000件以上あるセクションのとき閉じられないし読み込みに時間がかかりまくるので諦める */
document.querySelector('.TaskGroupHeader-disabledToggleButton')
/* 過去10秒分でスクロールの高さに変化がないなら一番下か読み込み時間かかってるかなので諦める */
|| scrollHeightHistory.slice(-10).reduce((first, current) => first === current ? first : -1) !== -1
) {
/* 諦めたら一番上に戻しておく */
scroller.scroll(0, 0);
clearInterval(timer);
return;
}
scroller.scroll(0, scroller.scrollHeight);
}, 1000);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment