Created
April 26, 2018 14:28
-
-
Save BKeanu1989/642c6d2697e556f7339093e26bf51d80 to your computer and use it in GitHub Desktop.
qwertee show all prices nerdy script
This file contains 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
function showPrices() { | |
let prices = Array.from(document.querySelectorAll('.index-tee-list-item span.product-price')); | |
prices.forEach(function(price) { | |
price.style.display = "block"; | |
}) | |
} | |
function throttle(func, wait, options) { | |
var context, args, result; | |
var timeout = null; | |
var previous = 0; | |
if (!options) options = {}; | |
var later = function() { | |
previous = options.leading === false ? 0 : Date.now(); | |
timeout = null; | |
result = func.apply(context, args); | |
if (!timeout) context = args = null; | |
}; | |
return function() { | |
var now = Date.now(); | |
if (!previous && options.leading === false) previous = now; | |
var remaining = wait - (now - previous); | |
context = this; | |
args = arguments; | |
if (remaining <= 0 || remaining > wait) { | |
if (timeout) { | |
clearTimeout(timeout); | |
timeout = null; | |
} | |
previous = now; | |
result = func.apply(context, args); | |
if (!timeout) context = args = null; | |
} else if (!timeout && options.trailing !== false) { | |
timeout = setTimeout(later, remaining); | |
} | |
return result; | |
}; | |
}; | |
window.addEventListener('scroll', throttle(showPrices, 3000)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment