您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add VIB Rank, stars, VIB_score decimal, and rating count to anime list based on API data
当前为
// ==UserScript== // @name VIBDataListInsertion // @namespace https://jirehlov.com // @version 0.1.1 // @description Add VIB Rank, stars, VIB_score decimal, and rating count to anime list based on API data // @include /^https?://(bangumi\.tv|bgm\.tv|chii\.in)/(.+?/list|.+?/tag|.+?/browser|subject_search|index)(/|\?).+$/ // @author Jirehlov // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; const processedElements = new Set(); async function addVIBRankAndInfoToElement(rateInfoElement) { if (processedElements.has(rateInfoElement)) { return; } const existingRankElement = rateInfoElement.nextElementSibling; if (existingRankElement && existingRankElement.classList.contains('rank')) { processedElements.add(rateInfoElement); return; } const h3Element = rateInfoElement.parentElement.querySelector('h3'); if (!h3Element) { return; } const match = h3Element.querySelector('a').getAttribute('href').match(/\/(\d+)$/); if (!match) { return; } const id = match[1]; const apiUrl = `https://api.jirehlov.com/vib/${id}`; const response = await fetch(apiUrl, { redirect: 'manual' }); if (response.status === 301) { return; } if (response.ok) { const data = await response.json(); const vibRank = data.VIB_rank; const newRankElement = document.createElement('span'); newRankElement.classList.add('rank'); newRankElement.innerHTML = `<small>VIB Rank </small>${vibRank}`; newRankElement.style.right = '85px'; rateInfoElement.insertAdjacentElement('afterend', newRankElement); processedElements.add(rateInfoElement); const vibScore = data.VIB_score; if (!isNaN(vibScore)) { const starsElement = document.createElement('span'); starsElement.classList.add('starstop-s'); const starCount = Math.round(vibScore); starsElement.innerHTML = `<span class="starlight stars${starCount}"></span>`; const newRateInfoElement = document.createElement('p'); newRateInfoElement.classList.add('rateInfo'); newRateInfoElement.appendChild(starsElement); const vibScoreDecimal = parseFloat(vibScore).toFixed(1); const vibEnum = data.VIB_enum; newRateInfoElement.innerHTML += `<small class="fade"> ${vibScoreDecimal}</small> <span class="tip_j">(${vibEnum}人VIB评分)</span>`; rateInfoElement.insertAdjacentElement('afterend', newRateInfoElement); } } } const observer = new MutationObserver((mutationsList, observer) => { mutationsList.forEach((mutation) => { if (mutation.type === 'childList') { mutation.addedNodes.forEach((node) => { if (node.nodeType === Node.ELEMENT_NODE && node.querySelector('p.rateInfo')) { const rateInfoElements = node.querySelectorAll('p.rateInfo'); rateInfoElements.forEach(addVIBRankAndInfoToElement); } }); } }); }); const initialRateInfoElements = document.querySelectorAll('p.rateInfo'); initialRateInfoElements.forEach(addVIBRankAndInfoToElement); const browserItemList = document.getElementById('browserItemList'); if (browserItemList) { observer.observe(browserItemList, { childList: true, subtree: true }); } })();