|
@@ -1,4 +1,5 @@ |
|
|
import browser from 'webextension-polyfill' |
|
|
import browser from 'webextension-polyfill' |
|
|
|
|
|
import throttle from 'lodash/throttle' |
|
|
|
|
|
|
|
|
function hideBanners() { |
|
|
function hideBanners() { |
|
|
const revertSteps = [] |
|
|
const revertSteps = [] |
|
@@ -50,14 +51,10 @@ function hideBanners() { |
|
|
function main() { |
|
|
function main() { |
|
|
let state = 'off' |
|
|
let state = 'off' |
|
|
let revertSteps = [] |
|
|
let revertSteps = [] |
|
|
let lastRun |
|
|
|
|
|
|
|
|
|
|
|
function onScroll(event) { |
|
|
function onScroll(event) { |
|
|
let action |
|
|
let action |
|
|
if (window.scrollY > 20 && |
|
|
|
|
|
(state === 'off' || (state === 'on' && event.timeStamp - lastRun > 1000)) |
|
|
|
|
|
) { |
|
|
|
|
|
lastRun = event.timeStamp |
|
|
|
|
|
|
|
|
if (window.scrollY > 20 && (state === 'off' || state === 'on')) { |
|
|
state = 'starting' |
|
|
state = 'starting' |
|
|
action = () => { |
|
|
action = () => { |
|
|
revertSteps = hideBanners().concat(revertSteps) |
|
|
revertSteps = hideBanners().concat(revertSteps) |
|
@@ -76,7 +73,7 @@ function main() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
window.addEventListener('scroll', onScroll) |
|
|
|
|
|
|
|
|
window.addEventListener('scroll', throttle(onScroll, 1000)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
main() |
|
|
main() |