Last active
October 11, 2022 12:53
-
-
Save hogashi/04943a035040d717d07f1b5589df4852 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 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