Skip to content

Instantly share code, notes, and snippets.

@justincy
Last active August 26, 2016 00:38
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 justincy/2e82ce3f2c4daeaa7a03473f5a4c6355 to your computer and use it in GitHub Desktop.
Save justincy/2e82ce3f2c4daeaa7a03473f5a4c6355 to your computer and use it in GitHub Desktop.
Home Teaching Needs Analysis - Households jQuery Scraping Script
// This script generates a tab-delimeted list of households with the currently
// assigned home teachers. Copy and paste the script into the browser JS console
// (opened by hitting the F12 key on PCs) when on the Households tab of the
// Hometeaching section of Leader and Clerk Resources on lds.org.
// The output is formatted in a way that allows you to pase it into your favorite
// spreadsheet program.
// For each household...
$('.member-list-body').map(function(){
var row = $(this);
return [
// Get the household name and trim whitespace
row.find('.teachee').text().trim(),
// Get the names of both hometeachers, trim whitespace,
// and join them with a ' / ' separator. We can't just pull the
// text of their shared parent container because there's hidden
// mobile "Home Teachers" header that we don't want in the output
// so we have to extract their two names individually then join
// them together.
row.find('.teacher').map(function(){
return this.textContent.trim();
}).get().join(' / ')
// Join the household name with the home teachers, separated
// by a tab so that the spreadsheet program knows the household
// and hometeachers' names are two different cells
].join('\t');
// We separate each row with a new line
}).get().join('\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment