diff --git a/src/content_script.js b/src/content_script.js index 0c9c85b..7d89aaa 100644 --- a/src/content_script.js +++ b/src/content_script.js @@ -49,27 +49,14 @@ function hideBanners() { function main() { - let state = 'off' let revertSteps = [] function onScroll(event) { - let action - if (window.scrollY > 20 && (state === 'off' || state === 'on')) { - state = 'starting' - action = () => { - revertSteps = hideBanners().concat(revertSteps) - state = 'on' - } - } else if (window.scrollY <= 0 && state === 'on') { - state = 'stopping' - action = () => { - revertSteps.forEach(step => step()) - revertSteps = [] - state = 'off' - } - } - if (action) { - window.requestAnimationFrame(action) + if (window.scrollY > 20) { + revertSteps = hideBanners().concat(revertSteps) + } else if (window.scrollY <= 0) { + revertSteps.forEach(step => step()) + revertSteps = [] } }