Created
April 16, 2015 01:59
-
-
Save de314/ee4b82b88289016e58ca to your computer and use it in GitHub Desktop.
Get stuff for Lizz
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
var $=jQuery, | |
currPaginationText, | |
rawSkus = [], | |
mapping = { | |
url: window.location.href, | |
skus: rawSkus | |
}; | |
function getSkus() { | |
var skus = $('[id^="sku"]').filter(function() { | |
return this.id.match(/^sku\d+$/) | |
}); | |
for (var i=0;i<skus.length;i++) { | |
rawSkus.push(skus[i].id) | |
} | |
nextPage(); | |
} | |
function nextPage() { | |
var nextLink = $("a.page-link.next"); | |
if (nextLink.length) { | |
currPaginationText = $('#bottomCount').text(); | |
nextLink.click(); | |
waitForPageLoad(); | |
} else { | |
console.log("DONE!!!!!!!!"); | |
console.log(mapping); | |
} | |
} | |
function waitForPageLoad() { | |
var temp = $('#bottomCount').text(); | |
if (temp == currPaginationText) { | |
setTimeout(waitForPageLoad, 500); | |
} else { | |
getSkus(); | |
} | |
} | |
getSkus(rawSkus); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment