Created
April 11, 2013 21:27
-
-
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
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
/*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