您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
隐藏已收藏条目,并按日期区间筛选作品。
当前为
// ==UserScript== // @name Bangumi 排行榜增强:隐藏已收藏并按日期区间筛选 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 隐藏已收藏条目,并按日期区间筛选作品。 // @author KunimiSaya // @match https://bgm.tv/*/browser* // @match https://bangumi.tv/*/browser* // @match https://chii.in/*/browser* // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; let isHidingEnabled = true; let startDate = null; let endDate = null; function extractDate(infoText) { const datePatterns = [ /(\d{4})年(\d{1,2})月/, /(\d{4})-(\d{2})-(\d{2})/, /(\d{4})-(\d{2})/, /(\d{4})/, ]; for (const pattern of datePatterns) { const match = infoText.match(pattern); if (match) { const year = parseInt(match[1], 10); const month = match[2] ? parseInt(match[2], 10) : 1; return new Date(year, month - 1); } } return null; } function filterByDate(items) { items.forEach(item => { const info = item.querySelector('.info'); if (info) { const date = extractDate(info.textContent); const isOutOfDateRange = (startDate && date < startDate) || (endDate && date > endDate); if (isOutOfDateRange) { item.style.display = 'none'; } } }); } function filterCollectedItems(items) { items.forEach(item => { const isCollected = item.querySelector('.collectModify'); if (isHidingEnabled && isCollected) { item.style.display = 'none'; } else if (!isHidingEnabled || !isCollected) { item.style.display = ''; } }); } function applyFilters() { const items = document.querySelectorAll('.item'); items.forEach(item => (item.style.display = '')); filterCollectedItems(items); filterByDate(items); } function addControls() { const sideInner = document.querySelector('.sideInner'); if (!sideInner || document.getElementById('filterControls')) return; const controls = document.createElement('div'); controls.id = 'filterControls'; controls.style.marginTop = '20px'; const title = document.createElement('h2'); title.className = 'subtitle'; title.textContent = '筛选工具'; controls.appendChild(title); const toggleButton = document.createElement('a'); toggleButton.className = 'chiiBtn'; toggleButton.href = 'javascript:void(0);'; toggleButton.textContent = '显示/隐藏已收藏条目'; toggleButton.onclick = () => { isHidingEnabled = !isHidingEnabled; applyFilters(); }; controls.appendChild(toggleButton); const dateControls = document.createElement('div'); dateControls.style.marginTop = '10px'; dateControls.style.display = 'flex'; dateControls.style.flexWrap = 'wrap'; dateControls.style.gap = '5px'; const startDateInput = document.createElement('input'); startDateInput.type = 'month'; startDateInput.placeholder = '起始日期'; startDateInput.style.width = '120px'; const endDateInput = document.createElement('input'); endDateInput.type = 'month'; endDateInput.placeholder = '结束日期'; endDateInput.style.width = '120px'; const filterButton = document.createElement('a'); filterButton.className = 'chiiBtn'; filterButton.href = 'javascript:void(0);'; filterButton.textContent = '按时间区间筛选'; filterButton.onclick = () => { startDate = startDateInput.value ? new Date(startDateInput.value) : null; endDate = endDateInput.value ? new Date(endDateInput.value) : null; applyFilters(); }; dateControls.appendChild(startDateInput); dateControls.appendChild(endDateInput); dateControls.appendChild(filterButton); controls.appendChild(dateControls); sideInner.appendChild(controls); } function observePageChanges() { const observer = new MutationObserver(() => { applyFilters(); }); observer.observe(document.body, { childList: true, subtree: true }); } function init() { addControls(); applyFilters(); observePageChanges(); } init(); })();