Created
May 28, 2021 18:23
-
-
Save DarkPark/6a9e54de90d4280351f24ed7089d498a to your computer and use it in GitHub Desktop.
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
Array.prototype.slice.call(document.querySelectorAll('.book-row')).forEach($book => { | |
const stats = $book.querySelector('.book-stats'); | |
if ( stats ) { | |
const views = Number(stats.firstElementChild.dataset.hint.replace('Просмотры · ', '').replace(/ /g, '')); | |
const likes = Number(stats.firstElementChild.nextElementSibling.dataset.hint.replace('Понравилось · ', '').replace(/ /g, '')); | |
const $info = document.createElement('span'); | |
const ratio = Math.floor(views/likes); | |
//console.log(ratio); | |
$info.textContent = Math.floor(views/likes); | |
$info.style.fontWeight = 'bold'; | |
if ( ratio < 50 ) { | |
$info.style.color = 'green'; | |
} | |
if ( ratio > 100 ) { | |
$book.style.display = 'none'; | |
} | |
stats.insertBefore($info, stats.firstElementChild); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment