Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save benjaminwy/a4ac829238463317c9a0 to your computer and use it in GitHub Desktop.

Select an option

Save benjaminwy/a4ac829238463317c9a0 to your computer and use it in GitHub Desktop.
// 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