NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Shiki Friends Info // @author Golden Dragon, Chortowod // @description На странице аниме в блоке "Друзья" показывает текущую серию, а также добавляет возможность узнать дату просмотра // @namespace http://shikimori.me/ // @version 1.1.4 // @match *://shikimori.org/* // @match *://shikimori.one/* // @match *://shikimori.me/* // @icon https://www.google.com/s2/favicons?domain=shikimori.me // @license MIT // @require https://gist.githubusercontent.com/Chortowod/814b010c68fc97e5f900df47bf79059c/raw/chtw_settings.js?v1 // @updateURL https://openuserjs.org/meta/Chortowod/Shiki_Friends_Info.meta.js // @downloadURL https://openuserjs.org/install/Chortowod/Shiki_Friends_Info.user.js // @copyright 2023, Golden Dragon (https://shikimori.one/Golden+Dragon), Chortowod // ==/UserScript== let settings = new ChtwSettings('gldDrgFriendsInfo', '<a target="_blank" href="https://openuserjs.org/scripts/Chortowod/Shiki_Friends_Info">Инфа о друзьях</a>'); function initSettings() { settings.createOption('color', 'Цвет', 'inherit', 'color'); } function getAnimeID() { let pageUrl = location.href; return pageUrl.substring(pageUrl.lastIndexOf('/')+1, pageUrl.indexOf('-')).replace(/[^\d]/g, ''); } function getUserID(item) { let imgSrc = item.getElementsByTagName('img')[0].src; return imgSrc.substring(imgSrc.lastIndexOf('/')+1, imgSrc.indexOf('.png')); } function addInfoData(userDiv, data) { let options = { year: 'numeric', month: 'long', day: 'numeric' }; let date = new Date(data.updated_at); let text = ''; if (data.status != 'completed') { if (data.target_type == 'Manga') { if (data.chapters) text = ` (${data.chapters} гл.)`; else if (data.volumes) text = ` (${data.volumes} том)`; else text = ''; } else text = data.episodes ? ` (${data.episodes} эп.)` : ''; } if (text) { let countEpDiv = document.createElement('div'); countEpDiv.style.color = settings.getOption('color'); countEpDiv.style.float = 'right'; countEpDiv.style.fontSize = '11px'; countEpDiv.classList.add("chtwFriendsOngoingEpDiv"); userDiv.insertBefore(countEpDiv, userDiv.firstChild); countEpDiv.textContent = text; } userDiv.title = date.toLocaleDateString("ru-RU", options); userDiv.style.cursor = 'help'; } function getUsersInfo() { let activeUsers = document.getElementsByClassName('friend-rate'); if (!activeUsers.length) return; let titleType = location.pathname.match(/\/\w+\/?/g)[0].replaceAll("/","") == 'animes' ? 'Anime' : 'Manga'; let index = 1; for (let item of activeUsers) { setTimeout(function(){ let userID = getUserID(item); let animeID = getAnimeID(); $.ajax({ url: `https://shikimori.one/api/v2/user_rates?target_type=${titleType}&user_id=${userID}&target_id=${animeID}`, success: function(data) { if (data.length === 0) { console.log('Что-то пошло не так.'); } else { addInfoData(item, data[0]); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { console.log("Status: " + textStatus + " | Error: " + errorThrown); } }); }, (index)*400); index++; } } function ready(fn) { document.addEventListener('page:load', fn); document.addEventListener('turbolinks:load', fn); if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading") fn(); else document.addEventListener('DOMContentLoaded', fn); } ready(initSettings); ready(getUsersInfo);