Counting score of the latest -N reviews on OZON.ru
// upd 26/10/2024
let userScores = Array.from(document.querySelectorAll('div[data-widget="webListReviews"] div'))
.map(div => Array.from(div.children).filter(child => child.tagName === 'svg' && child.style.color === 'rgb(255, 168, 0)').length)
.filter(score => score > 0)
.slice(0, 10); // Get the first 10 scores
const totalScore = Math.max(1, Math.min(userScores.reduce((acc, score) => acc + score, 0) / userScores.length, 5));
console.log(totalScore);
bookmarklet (with interactive score prompt)
javascript:var userScores = Array.from(document.querySelectorAll('div[data-widget="webListReviews"] div')).map(div => Array.from(div.children).filter(child => child.tagName === 'svg' && child.style.color === 'rgb(255, 168, 0)').length).filter(score => score > 0).slice(0, prompt(`How many recent reviews should be taken for rating calculation?`, 10));var totalScore = Math.max(1, Math.min(userScores.reduce((acc, score) => acc + score, 0) / userScores.length, 5));alert(`Score is ${totalScore}`);