// ==UserScript== // @name Bangumi 挖坟人探测器 // @namespace https://bgm.tv/ // @version 2024-03-26 // @description 挖坟人探测器 // @author Vick Scarlet (BGM: 神戸小鳥@vickscarlet) // @match https://bgm.tv/* // @match https://bangumi.tv/* // @match https://chii.in/* // @icon https://bgm.tv/img/favicon.ico // @license MIT // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; const column = document.querySelector('#columnInSubjectA'); if (!column) return; const nodes = column.querySelectorAll('.clearit'); if (!nodes) return; const posts = []; nodes.forEach(node=>{ const id = node.id; if(!id||!id.startsWith('post_')) return; const [f,t] = node.children[0].children[0].children[0].textContent.split(' - ') posts.push([new Date(t).getTime(),t,id,f]); }) posts.sort(([a],[b])=>a-b) const day = 24*60*60*1000; const convert = t=>{ t = t/day/30; if (t>12) return `间隔${Math.floor(t/12)}年` else return `间隔${Math.floor(t)}月` } const timing = 30*day; let l = posts.shift()[0]; const list = [] for (const [a, t, p, f] of posts) { const d = a - l; if (d > timing) list.push([p, f, t, d]) l = a } if (list.length < 1) return; document.querySelector('.columns').setAttribute('style','display: flex;'); const out = document.createElement('div'); out.setAttribute('style',` display: flex; flex-direction: column; position: sticky; top: 15px; `); const box = document.createElement('div'); box.setAttribute('style',` display: flex; flex-direction: column; `); const clB = document.querySelector('#columnInSubjectB'); out.append(clB.children[0]); out.append(box); clB.append(out); box.classList.add('borderNeue'); const tip = document.createElement('div'); tip.innerHTML = `⚠️ 本贴被挖坟${list.length}次(一个月以上算挖坟)`; tip.setAttribute('style',` background: #6fe5cc; padding: 8px; color: #444; border-radius: 4px 4px 0 0; `); box.append(tip); const ul = document.createElement('ul'); ul.setAttribute('style',` display: flex; flex-direction: column; position: relative; gap: 5px; padding: 8px; border-radius: 4px; `); box.append(ul); for (const [p,f,t,d] of list.reverse()) { const post = document.querySelector('#'+p); const li = document.createElement('li'); li.innerHTML = `${f} - ${t} ${convert(d)}`; li.setAttribute('style',` display: inline-block; color: #444; `); li.onclick = ()=>{ document.querySelector('.reply_highlight')?.classList.remove('reply_highlight') post.classList.add('reply_highlight') }; ul.append(li); } console.debug('ok') })();