Skip to content

Instantly share code, notes, and snippets.

@milanpanchal
Forked from igeligel/get-medium-stats.js
Created April 14, 2022 05:41
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 milanpanchal/3b673de41b13a3a4370abae2aa97dfb3 to your computer and use it in GitHub Desktop.
Save milanpanchal/3b673de41b13a3a4370abae2aa97dfb3 to your computer and use it in GitHub Desktop.
medium-get-totals
const totalTypes = {
VIEWS: 2,
READS: 3,
FANS: 5
};
const getTotal = tableColumn =>
[
...document.querySelectorAll(
`td:nth-child(${tableColumn}) > span.sortableTable-number`
)
]
.map(e => parseInt(e.getAttribute("title").replace(/,/g, ""), 10))
.reduce((a, b) => a + b, 0);
console.log({
totalViews: getTotal(totalTypes.VIEWS),
totalReads: getTotal(totalTypes.READS),
totalFans: getTotal(totalTypes.FANS)
});
@milanpanchal
Copy link
Author

  • Go to https://medium.com/me/stats Page
  • Open JavaScript Console by navigating View ➞ Developer ➞ JavaScript Console or use ⌥ + ⌘ + J short cut
  • Copy-Paste the above script and hit the return/enter button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment