Skip to content

Instantly share code, notes, and snippets.

@anchnk
Last active August 6, 2018 15:04
Show Gist options
  • Save anchnk/886589c2d580d7f3519d9a19ab138295 to your computer and use it in GitHub Desktop.
Save anchnk/886589c2d580d7f3519d9a19ab138295 to your computer and use it in GitHub Desktop.
Extract manning dashboard metrics (books, videos, meaps)

Firefox Scratchpad that parse metrics from manning's dashboard:

function getElementsCount(attributeName) {
  return document.querySelectorAll(`#productTable > tbody > tr[${attributeName}=true]`).length;
}

var labelsMap = new Map([
  ['is-book', 'books'],
  ['is-meap', 'meaps'],
  ['is-video', 'videos']
]); 

var result = [...labelsMap.keys()].reduce((counters, attribute) => {
  counters[labelsMap.get(attribute)] = getElementsCount(attribute);
  return counters;
}, {
  books: 0,
  videos: 0,
  meaps: 0
});

console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment