Created
March 30, 2023 10:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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}`); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run this script: