Chris Frewin
Jun 14, 2024

--

Popping in here if anyone arrives in 2024, modified the script slightly for the new format of the stats page that medium finally released:

const offset = {

VIEWS: 0,

READS: 1,

EARNINGS: 2

};

const getTotal = columnOffset =>

[

...document.querySelectorAll(

`.of.l p`

)

]

.filter((_, index) => (index - columnOffset) % 3 === 0)

.map(e => {

if (e.textContent.includes("$")) {

return parseFloat(e.textContent.replace("$", ""));

}

if (e.textContent === "-") {

return 0;

}

if (e.textContent.includes("K")) {

return parseFloat(e.textContent) * 1000;

}

return parseInt(e.textContent, 10)

})

.reduce((a, b) => a + b, 0);

console.log({

totalViews: getTotal(offset.VIEWS),

totalReads: getTotal(offset.READS),

totalEarnings: getTotal(offset.EARNINGS)

});

--

--

Chris Frewin
Chris Frewin

Written by Chris Frewin

https://wheelscreener.com https://vannacharm.com https://chrisfrew.in 👨‍💻 Software Engineer 🏠 Austria/USA 🍺 Homebrewer ⛷🏃‍ 🚴 Outdoorsman

No responses yet