Skip to content

Instantly share code, notes, and snippets.

@de314
Created April 16, 2015 01:59
Show Gist options
  • Save de314/ee4b82b88289016e58ca to your computer and use it in GitHub Desktop.
Save de314/ee4b82b88289016e58ca to your computer and use it in GitHub Desktop.
Get stuff for Lizz
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