Skip to content

Instantly share code, notes, and snippets.

@kmb89144
Created April 11, 2013 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmb89144/5367325 to your computer and use it in GitHub Desktop.
Save kmb89144/5367325 to your computer and use it in GitHub Desktop.
Script to go through and click all the add to cart buttons in the Comixology #1 issue giveaway
/*On the page where you select the comics you want to add to your cart, open up the javascript console and then paste and run the following code*/
var sections = $('.standard_section');
var currSectionIndex = 0;
function handleSection(section) {
var body = $(section).find('.standard_section_body');
var pages = $(body).find('.adHocPager a');
var currPageIndex = 0;
function getComicsOnPage() {
if (currPageIndex === pages.length) {
return;
}
var currPage = pages[currPageIndex];
currPageIndex++;
if ($(currPage).attr('id') === undefined) {
eval($(currPage).attr('href'));
var comics = $(body).find('.buyGiftBtn a');
var currComicIndex = 0;
function getComic() {
if (currComicIndex === comics.length) {
getComicsOnPage();
}
var currComic = comics[currComicIndex];
currComicIndex++;
$(currComic).click();
setTimeout(getComic, 1000);
}
getComic();
} else {
getComicsOnPage();
}
}
getComicsOnPage();
}
for (var i = 0; i < sections.length; i++) {
handleSection(sections[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment