Skip to content

Instantly share code, notes, and snippets.

@kururu-abdo
Forked from igeligel/get-medium-stats.js
Created December 1, 2022 13:02
Show Gist options
  • Select an option

  • Save kururu-abdo/aa4d603a8db1d741b6d7bd7ab4e69dbc to your computer and use it in GitHub Desktop.

Select an option

Save kururu-abdo/aa4d603a8db1d741b6d7bd7ab4e69dbc to your computer and use it in GitHub Desktop.

Revisions

  1. @igeligel igeligel revised this gist Nov 4, 2018. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions get-medium-stats.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    const totalTypes = {
    VIEWS: 2,
    READS: 3
    READS: 3,
    FANS: 5
    };

    const getTotal = tableColumn =>
    @@ -14,5 +15,6 @@ const getTotal = tableColumn =>

    console.log({
    totalViews: getTotal(totalTypes.VIEWS),
    totalReads: getTotal(totalTypes.READS)
    totalReads: getTotal(totalTypes.READS),
    totalFans: getTotal(totalTypes.FANS)
    });
  2. @igeligel igeligel revised this gist Nov 4, 2018. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions get-medium-stats.js
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,12 @@ const totalTypes = {
    READS: 3
    };

    const getTotal = (tableColumn) =>
    [...document.querySelectorAll(`td:nth-child(${tableColumn}) > span.sortableTable-number`)]
    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);

  3. @igeligel igeligel created this gist Nov 4, 2018.
    14 changes: 14 additions & 0 deletions get-medium-stats.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    const totalTypes = {
    VIEWS: 2,
    READS: 3
    };

    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)
    });