Browser extension to hide view-reducing screen junk from websites.
Browse Source

Remove unnecessary delay logic

tags/v1.1.0
Gerben 6 years ago
parent
commit
9e4da16460
1 changed files with 5 additions and 18 deletions
  1. +5
    -18
      src/content_script.js

+ 5
- 18
src/content_script.js View File

@@ -49,27 +49,14 @@ function hideBanners() {




function main() { function main() {
let state = 'off'
let revertSteps = [] let revertSteps = []


function onScroll(event) { 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 = []
} }
} }




Loading…
Cancel
Save