Created
December 13, 2015 18:33
-
-
Save benjaminwy/a4ac829238463317c9a0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Step 1: Inject jQuery | |
| var jq = document.createElement('script'); | |
| jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; | |
| document.getElementsByTagName('head')[0].appendChild(jq); | |
| // Step 2: Grab IDs. Will need to be updated when Mailchimp changes their markup. | |
| var groups = []; | |
| $('div.group-wrapper h4').each(function() { | |
| var g = { | |
| name: $(this).text(), | |
| id: ~~this.id.replace(/[^0-9]/g, ''), | |
| options: [] | |
| }; | |
| $('ul#group-list-' + g.id + ' li.subgroup').each(function() { | |
| var href = $(this).find('p.subgroup-count a').attr('href'); | |
| var parsed_href = new RegExp('[\\?&]group_id=([^&#]*)').exec(href); | |
| var o = { | |
| name: $(this).find('p.interest-name').text(), | |
| id: ~~parsed_href[1] | |
| }; | |
| g.options.push(o); | |
| }); | |
| groups.push(g); | |
| }); | |
| console.log(groups); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment