diff --git a/Run-JavaScript-before-change-detection.md b/Run-JavaScript-before-change-detection.md index 2e904ad..d0b45ac 100644 --- a/Run-JavaScript-before-change-detection.md +++ b/Run-JavaScript-before-change-detection.md @@ -47,7 +47,8 @@ document.getElementById('onetrust-accept-btn-handler').click(); ### Web page change alerts for BestBuy products -BestBuy will often ask for a 'local' or 'country' store, we simply click on the USA flag link from the English section of the site https://changedetection.io/share/pkhEFXeb8Cka +BestBuy will often ask for a 'local' or 'country' store, just append ```&intl=nosplash``` to the end of the url to go directly to the site and bypass the country selection. +https://changedetection.io/share/pkhEFXeb8Cka In that above shared link, we will be watching BestBuy for changes in GTX 4090 graphic card prices @@ -62,6 +63,27 @@ setInterval(function(){ ``` and "**Wait seconds before extracting text**" to around `5` +If the page contains more then 3 products, you will also need to execute JS to scroll the page if you wish for it to properly check stock. +```var notChangedStepsCount = 0; +var scrollInterval = setInterval(function() { + var element = document.querySelector("div.footer"); + if (element) { + // element found + clearInterval(scrollInterval); + element.scrollIntoView(); + } else if((document.documentElement.scrollTop + window.innerHeight) != document.documentElement.scrollHeight) { + // no element -> scrolling + notChangedStepsCount = 0; + document.documentElement.scrollTop = document.documentElement.scrollHeight; + } else if (notChangedStepsCount > 20) { + // no more space to scroll + clearInterval(scrollInterval); + } else { + // waiting for possible extension (autoload) of the page + notChangedStepsCount++; + } +}, 50);``` + "**CSS/JSON/XPATH Filter**" to `.shop-sku-list-item` (to just extract the product prices and price+description)