diff --git a/processors/generics/generic-bootstrap.js b/processors/generics/generic-bootstrap.js index 8796930..608cec7 100644 --- a/processors/generics/generic-bootstrap.js +++ b/processors/generics/generic-bootstrap.js @@ -22,10 +22,17 @@ module.exports = function (processorConfig) { const imgWrap = document.elementFromPoint(300, 300); const children = imgWrap.querySelectorAll('.pswp__img'); const img = children[children.length - 1]; - console.log(img, imgWrap); // debugger; // Full image hasn't loaded yet const src = imgWrap.src.split('?')[0]// get rid of querystring + //check for a duplicated src + for(var i = 0;i < galleryUrls.length;i++) { + if(src === galleryUrls[i].url && externalCounter > 1) { + //we're using the fallback counter, reset it to 1 to trigger the exit. + externalCounter = 0; + return; + } + } return downloadSrc(src, id); } @@ -37,11 +44,16 @@ module.exports = function (processorConfig) { } function nextImage() { - document.querySelector('.pswp__button.pswp__button--arrow--right').click(); + //get the navigation button element + const navigation = document.querySelector('.pswp__button.pswp__button--arrow--right') || document.querySelector('.pswp__button.pswp__button--arrow--next') + navigation.click(); + externalCounter += 1; } - + var externalCounter = 1; function getCounterValue() { - const [position, total] = document.querySelector('.pswp__counter').textContent.split('/'); + const internalCounterElement = document.querySelector('.pswp__counter'); + if(!internalCounterElement) return externalCounter; + const [position, total] = internalCounterElement.textContent.split('/'); return parseInt(position.trim(), 10); }