Отображает реальный рейтинг Аниме, Манги и Ранобэ на сайте Shikimori
当前为
// ==UserScript==
// @name RealShikiRate
// @version 0.1
// @description Отображает реальный рейтинг Аниме, Манги и Ранобэ на сайте Shikimori
// @author vuchaev2015
// @match https://shikimori.me/animes/*
// @match https://shikimori.me/ranobe/*
// @match https://shikimori.me/mangas/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=shikimori.me
// @grant none
// @namespace https://greasyfork.org/users/997663
// ==/UserScript==
const waitForRatesScoresStats = () => {
const ratesScoresStats = document.querySelector('#rates_scores_stats');
if (ratesScoresStats && ratesScoresStats.querySelector('.x_label')) {
clearInterval(interval);
let total = 0;
let count = 0;
const lines = ratesScoresStats.querySelectorAll('.line');
lines.forEach(line => {
const x_label = line.querySelector('.x_label').textContent;
const value = line.querySelector('.bar').getAttribute('title');
console.log(`x_label: ${x_label}, value: ${value}`);
total += parseInt(x_label) * parseInt(value);
count += parseInt(value);
});
const rating = total / count;
console.log(`Overall rating (out of 10): ${rating.toFixed(2)}`);
const ratingBlock = document.querySelector('.block[itemprop="aggregateRating"]');
const subheadline = ratingBlock.querySelector('.subheadline');
subheadline.textContent = 'рейтинг myanimelist';
const newBlock = ratingBlock.cloneNode(true);
newBlock.querySelector('.subheadline').textContent = 'рейтинг shikimori';
newBlock.querySelector('.score-value').textContent = rating.toFixed(2);
newBlock.querySelector('.stars.score').classList.remove(`score-${Math.round(rating)}`);
newBlock.querySelector('.stars.score').classList.add(`score-${Math.round(rating)}`);
const scoreNoticeTexts = {
'0': '',
'1': 'Хуже некуда',
'2': 'Ужасно',
'3': 'Очень плохо',
'4': 'Плохо',
'5': 'Более-менее',
'6': 'Нормально',
'7': 'Хорошо',
'8': 'Отлично',
'9': 'Великолепно',
'10': 'Эпик вин!'
};
newBlock.querySelector('.score-notice').textContent = scoreNoticeTexts[Math.floor(rating)];
ratingBlock.insertAdjacentElement('afterend', newBlock);
}
};
const interval = setInterval(waitForRatesScoresStats, 0);