Last active
May 29, 2020 10:33
-
-
Save nhoizey/007f74bedcecf7dc59f2906207827807 to your computer and use it in GitHub Desktop.
Compute faves/views ratio on Flickr stats pages
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
javascript:(function()%7B((document)%20%3D%3E%20%7Bdocument.querySelectorAll('.row').forEach(row%20%3D%3E%20%7Blet%20views%20%3D%20parseInt(row.querySelector('td%3Anth-child(3)').innerText.replace('%2C'%2C%20'')%2C%2010)%3Blet%20faves%20%3D%20parseInt(row.querySelector('td%3Anth-child(4)').innerText.replace('%2C'%2C%20'')%2C%2010)%3Blet%20ratio%20%3D%20Math.round(10000%20*%20faves%20%2F%20views)%20%2F%20100%3Brow.querySelector('td%3Anth-child(4)').innerText%20%3D%20row.querySelector('td%3Anth-child(4)').innerText%20%2B%20'%20('%20%2B%20ratio%20%2B%20'%20%25)'%3B%7D)%3B%7D)(window.document)%7D)() |
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
// Run this on a stats page | |
((document) => { | |
document.querySelectorAll('.row').forEach(row => { | |
let views = parseInt(row.querySelector('td:nth-child(3)').innerText.replace(',', ''), 10); | |
let faves = parseInt(row.querySelector('td:nth-child(4)').innerText.replace(',', ''), 10); | |
let ratio = Math.round(10000 * faves / views) / 100; | |
row.querySelector('td:nth-child(4)').innerText = row.querySelector('td:nth-child(4)').innerText + ' (' + ratio + ' %)';}); | |
})(window.document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment