Skip to content

Instantly share code, notes, and snippets.

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 artturijalli/d4cd82f2a23f5321ee45cf991ba319ba to your computer and use it in GitHub Desktop.
Save artturijalli/d4cd82f2a23f5321ee45cf991ba319ba to your computer and use it in GitHub Desktop.
A script that checks the success of your posts published in publications vs the stories not published on publications
(function() {
const stories = document.querySelectorAll('tr.js-statsTableRow');
let inPublicationViews = 0;
let notInPublicationViews = 0;
let nPublication = 0;
let nNotPublication = 0;
stories.forEach(story => {
const isInPublication = story.querySelector('em') && story.querySelector('em').innerHTML === 'In ';
const viewsElement = story.querySelector('td:nth-child(2) span.sortableTable-value');
const views = viewsElement ? parseInt(viewsElement.innerHTML, 10) : 0;
if (isInPublication) {
inPublicationViews += views;
nPublication += 1;
} else {
notInPublicationViews += views;
nNotPublication += 1;
}
});
console.log(`Total views for stories published on a Publication: ${inPublicationViews}`);
console.log(`Total views for stories not published on a Publication: ${notInPublicationViews}`);
console.log(`Number of stories on a Publication: ${nPublication}`);
console.log(`Number of stories not on a Publication: ${nNotPublication}`);
console.log(`Views per story on a publication: ${inPublicationViews/nPublication}`);
console.log(`Views per story not on a publication: ${notInPublicationViews/nNotPublication}`);
})();
@artturijalli
Copy link
Author

To run this script:

  1. Open up medium.com/stats/me.
  2. Scroll the page all the way down to your very first story.
  3. Open the JavaScript console.
  4. Run the above code.
  5. Check the console output.

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