Skip to content

Instantly share code, notes, and snippets.

@gzagatti
Created July 21, 2018 17:13
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 gzagatti/820e241edfb2aa6ab0f4a0ce19323797 to your computer and use it in GitHub Desktop.
Save gzagatti/820e241edfb2aa6ab0f4a0ce19323797 to your computer and use it in GitHub Desktop.
Performs basic analysis on a random table found in a webpage using basic JS
// Before proceeding add an ID `target` to the table you want to perform the analysis on
// Google Chrome intercepts $ as a shortcut for document.querySelector() and
// $$() as a shortcut for document.querySelectorAll()
items = []
$$('#target tr').forEach(
(row) => items.push(
parseFloat(
$$('td p font', row)[3].innerHTML.replace(/,/g, '.'))
)
)
// remove header
items = items.slice(1)
// average it out
items.reduce((a, b) => a + b) / items.length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment