// ==UserScript==
// @name 贵物班友会
// @namespace http://tampermonkey.net/
// @version 2.3.6
// @description 贵物班友会(bgm.tv、bangumi.tv、chii.in)
// @author 老悠
// @include https://bgm.tv/*
// @include https://bangumi.tv/*
// @match https://chii.in/*
// @grant GM_addStyle
// @grant GM_getResourceText
// @license MIT
// ==/UserScript==
(function() {
'use strict';
GM_addStyle('html[data-theme="dark"] .monster-tooltip{ background-color: black; } .dialog { width: 100%; height: 100vh; background-color: rgba(0, 0, 0, 0.5); position: absolute; top: 0; left: 0;line-height: 30px; display: none; } .dialog .container {width: 220px;height: 100px; background-color: #fff;margin: calc((100vh - 100px)/2) auto; position: relative;} .dialog .container .dialog_footer { position: absolute; bottom: 0; } .dialog .container .dialog_footer button {position: relative;left: 50px;display: inline-block;width: 50px;bottom: 10px;} .monster-tooltip {display: none;position: absolute;background-color: #f9f9f9;border: 1px solid #ccc;padding: 5px 10px;border-radius: 5px;font-size: 14px;}')
let yodbUrl="https://ly.syaro.io:380/yodb/api/";
//let yodbUrl="http://192.168.224.134:8080/yodb/";
let myBgmId;
let myBgmId2;
let protocol = window.location.protocol;
let host = window.location.host;
let baseUrl = protocol + '//' + host;
$.get(baseUrl+"/home",function(html,status){
let $html=$(html);
let $avatar=$html.find("#headerProfile .avatar:first");
let tempHtml=$avatar.html();
if(tempHtml){
let bgImgSplit=$avatar.html().split(".jpg")[0].split("/");
let split=$avatar.prop("href").split("/");
myBgmId=split[split.length-1];
myBgmId2=bgImgSplit[bgImgSplit.length-1];
}
let modalHtml='<div id="markModal" class="dialog">'
+' <div class="container">'
+' <div class="dialog_header">'
+' </div>'
+' <div class="dialog_center">'
+' 颜色:<input id="markColor" type="text" list="colors">'
+'<datalist id="colors">'
+'<option value="red">'
+'<option value="yellow">'
+'<option value="blue">'
+'<option value="green">'
+'</datalist>'
+'<br>'
+' 备注:<input id="markMark" type="text" ><br>'
+' </div>'
+' <div style="justify-content: center;display: flex;margin-top:10px;">'
+' <button class="cancel">取消</button>'
+' <button class="submit">确定</button>'
+' </div>'
+' </div>'
+' </div>';
let modalHtml2='<div id="markModal" class="dialog">'
+' <div class="container" style="height:220px">'
+' <div class="dialog_header">'
+' </div>'
+' <div class="dialog_center">'
+' bgmId:<input id="markBgmId" type="text" style="width:140px" disabled>'
+'<br>'
+' 名称:<input id="markName" type="text" style="width:150px">'
+'<br>'
+' 淳朴度:<input id="markScore" max="5" min="-5" type="number" style="width:138px">'
+'<br>'
+' 简介:<textarea id="markCont" type="text" style="width:150px;white-space:pre-wrap" rows="5"></textarea><br>'
+' </div>'
+' <div style="justify-content: center;display: flex;margin-top:10px;">'
+' <button class="cancel">取消</button>'
+' <button class="submit">确定</button>'
+' </div>'
+' </div>'
+' </div>';
$('body').append(modalHtml2);
let initModalVal=function(){
let ava=$("#headerProfile a.avatar");
if(!ava){
return;
}
let hrefVal=ava.attr("href");
if(!hrefVal){
return;
}
let newBgmId;
let oldBgmId;
if(hrefVal.indexOf("/user/")>-1){
let split=hrefVal.split("/");
newBgmId=split[split.length-1];
let imgUrl=ava.find("span").css("background-image");
if(imgUrl){
let oldSplit=imgUrl.split("/");
let oldTempSplit=oldSplit[oldSplit.length-1].split(".");
oldBgmId=oldTempSplit[0];
//没有头像无法获得原始bgmId
if(oldBgmId=='icon'){
oldBgmId=newBgmId;
}
}
}
$("#markBgmId").val(newBgmId);
$.get(yodbUrl+'anon/vulgar/monsterScore/detailByBgmId/'+newBgmId+"?newMyBgmId="+myBgmId+"&oldMyBgmId="+myBgmId2, function(res){
if(!res||!res.data){
if(newBgmId!=oldBgmId){
$.get(yodbUrl+'anon/vulgar/monsterScore/detailByBgmId/'+oldBgmId+"?newMyBgmId="+myBgmId+"&oldMyBgmId="+myBgmId2, function(res){
setModalVal(res.data);
});
}
}else{
setModalVal(res.data);
}
});
}
let setModalVal=function(modalData){
$("#markBgmId").val(modalData.monster.bgmId);
$("#markName").val(modalData.name);
$("#markScore").val(modalData.score);
$("#markCont").text(modalData.cont);
}
initModalVal();
let marksModalHtml='<div id="marksModal" class="dialog">'
+' <div class="container" style="height: 500px;width: 500px;margin: calc((100vh - 500px)/2) auto;">'
+' <div class="dialog_header">'
+' </div>'
+' <div class="dialog_center">'
+' <div style="justify-content: center;display: flex;">'
+' 全量傻逼备注JSON:<br>'
+' </div>'
+' <div style="justify-content: center;display: flex;">'
+' <textarea id="userMark" type="text" style="width:90%;height:420px;"/><br>'
+' </div>'
+' </div>'
+' <div style="justify-content: center;display: flex;margin-top:10px;">'
+' <button class="cancel">取消</button>'
+' <button class="submit">确定</button>'
+' </div>'
+' </div>'
+' </div>';
// $('body').append(marksModalHtml);
let tooltipHtml='<div class="monster-tooltip" id="monsterTooltip">无信息</div>';
$('body').append(tooltipHtml);
$(document).on("mouseenter",".monsterTipBtn",function(e){
var tooltip = $('#monsterTooltip');
let tempBgmId=$(this).attr("bgmId");
let tempMonster=monsterMap[tempBgmId].data;
let tempMyMonster=myMonsterMap[tempBgmId]?myMonsterMap[tempBgmId].data:null;
let tempHtml='';
if(tempMyMonster){
tempMyMonster.color=getColor(tempMyMonster.score);
tempHtml+= '私有标记:<br><span style="color:'+tempMyMonster.color+'">贵物:'+tempMyMonster.name+'</span>'+"<br>"
+'<span style="color:'+tempMyMonster.color+'">淳朴度:'+tempMyMonster.score+'</span><br>'
+'<span style="color:'+tempMyMonster.color+'">简介:</span><br>'
+'<span style="white-space: pre;color:'+tempMyMonster.color+'">'+(tempMyMonster.cont?tempMyMonster.cont:'无')+'</span>';
}
if(tempMonster&&tempMonster.name){
if(tempHtml.length>0){
tempHtml+='<br><br>';
}
tempHtml+= '公共标记:<br><span style="color:'+tempMonster.color+'">贵物:'+tempMonster.name+'</span>'+"<br>"
+'<span style="color:'+tempMonster.color+'">淳朴度:'+tempMonster.score+'</span><br>'
+'<span style="color:'+tempMonster.color+'">简介:</span><br>'
+'<span style="white-space: pre;color:'+tempMonster.color+'">'+(tempMonster.cont?tempMonster.cont:'无')+'</span>';
}
if(tempHtml.length>0){
$("#monsterTooltip").html(tempHtml);
}
tooltip.css({
top: e.pageY + 'px',
left: e.pageX + 'px',
display: 'block'
});
});
$(document).on("mouseenter",".cliqueTipBtn",function(e){
var tooltip = $('#monsterTooltip');
let tempCliqueId=$(this).attr("cliqueId");
let tempClique=cliqueMap[tempCliqueId];
let color=getColor(tempClique.score);
let tempHtml= '<span style="color:'+color+'">小圈子:'+tempClique.name+'</span>'+"<br>"
+'<span style="color:'+color+'">淳朴度:'+tempClique.score+'</span><br>'
+'<span>简介:</span><br>'
+'<span style="white-space: pre;">'+(tempClique.cont?tempClique.cont:'无')+'</span>';
$("#monsterTooltip").html(tempHtml);
tooltip.css({
top: e.pageY + 'px',
left: e.pageX + 'px',
display: 'block'
});
});
$(document).on("mouseleave",".monsterTipBtn,.cliqueTipBtn,.hoverText,#monsterTooltip",function(e){
if(!$(e.relatedTarget).is('#monsterTooltip')){
$('#monsterTooltip').hide();
}
});
// bgmerInfoTag的hover
$(document).on("mouseenter",".hoverText",function(e){
var tooltip = $('#monsterTooltip');
let hoverText=$(this).attr("hover-text");
$("#monsterTooltip").html(hoverText);
tooltip.css({
top: e.pageY + 'px',
left: e.pageX + 'px',
display: 'block'
});
});
//$("#headerProfile").find("div.actions").append('<a id="addMark" href="javascript:void(0)" class="chiiBtn" data-toggle="modal" data-target="#markModal"><span>添加/修改备注</span></a>'
// +'<a id="addMarks" href="javascript:void(0)" class="chiiBtn" data-toggle="modal" data-target="#marksModal"><span>批量添加/修改备注</span></a>');
$("#headerProfile").find("div.actions").append('<a id="addMark" href="javascript:void(0)" class="chiiBtn" data-toggle="modal" data-target="#markModal"><span>添加/修改备注</span></a>');
let id1=$("#headerProfile").find("div.name small.grey").text().replace("@","");
let userMark=localStorage.getItem('userMark');
if(!userMark){
userMark={};
}else{
try{
userMark=JSON.parse(userMark);
} catch(e){
userMark={};
}
}
$("#addMark").click(function(){
$('#markModal').show(1000);
});
$("#addMarks").click(function(){
$("#userMark").val(JSON.stringify(userMark));
$('#marksModal').show(1000);
});
// 确定按钮的操作
$('#markModal .submit').click(function () {
//userMark[id1]={"color":$("#markColor").val(),"mark":$("#markMark").val()};
//let json=JSON.stringify(userMark);
//localStorage.setItem('userMark', json, { expires: 999999999 });
//{"newMyBgmId":myBgmId,"oldMyBgmId":myBgmId2,"name":$("#markName").val(),"score":$("#markScore").val(),"cont":$("#markCont").text()}
//$.post(yodbUrl+'anon/vulgar/monsterScore/save/'+$("#markBgmId").val()+"?newMyBgmId="+myBgmId+"&oldMyBgmId="+myBgmId2+"&name="+$("#markName").val()+"&score="+$("#markScore").val()+"&cont="+$("#markCont").val(),
// function(res){
$.post(yodbUrl+'anon/vulgar/monsterScore/save/'+$("#markBgmId").val(),
{"newMyBgmId":myBgmId,"oldMyBgmId":myBgmId2,"name":$("#markName").val(),"score":$("#markScore").val(),"cont":$("#markCont").val()}, function(res){
if(!res.success){
alert(res.message+"\n"+"未在https://ly.syaro.io:380/注册并绑定bgmId无法使用私有标记功能");
}else{
$('#markModal').fadeToggle(1000);
location.reload();
}
});
});
// 取消按钮的操作
$('#markModal .cancel').click(function () {
$('#markModal').hide(1000)
});
// 批量模态框确定按钮的操作
$('#marksModal .submit').click(function () {
let json=$("#userMark").val();
localStorage.setItem('userMark', json, { expires: 999999999 });
$('#marksModal').fadeToggle(1000);
location.reload();
});
// 批量模态框取消按钮的操作
$('#marksModal .cancel').click(function () {
$('#marksModal').hide(1000)
});
var url = window.location.href;
var urlstr = url.split("/");
var urls = '';
if (urlstr[2]) {
urls = urlstr[0]+'//'+urlstr[2];
}
let allAva=0;
let checkAva=0;
// 外部标记初始化
let initVulgar=function(){
let len=$("a.avatar").length;
allAva=len;
for(let i=0;i<len;i++){
let ava=$("a.avatar").eq(i);
let hrefVal=ava.attr("href");
if(hrefVal.indexOf("/user/")==-1){
checkAva++;
continue;
}
let split=hrefVal.split("/");
let newIndex=split[split.length-1];
let imgUrl=ava.find("span").css("background-image");
if(!imgUrl){
checkAva++;
continue;
}
let oldSplit=imgUrl.split("/");
let oldTempSplit=oldSplit[oldSplit.length-1].split(".");
let index=oldTempSplit[0];
//没有头像无法获得原始bgmId
if(index=='icon'){
index=newIndex;
}
initMonster(index,newIndex,i==len-1);
}
}
let setMonsterHtml=function(monster,myMonster,bgmId,newBgmId,judgeInitPost){
let $user2=$("a[href='/user/"+newBgmId+"']:not(.avatar,.focus,.monster)");
let $$user2=$("a[href='"+urls+"/user/"+bgmId+"']:not(.avatar,.focus,.monster)");
if(monster){
let monsterHtml=getMonsterHtml(monster,myMonster,newBgmId);
if($user2.length> 0){
if(monster.color){
$user2.css({"color":monster.color});
}
$user2.addClass("monster");
$user2.after(monsterHtml);
}
if($$user2.length> 0){
if(monster.color){
$$user2.css({"color":monster.color});
}
$user2.addClass("monster");
$$user2.after(monsterHtml);
}
}
checkAva++;
initPost();
}
let getColor=function(score){
if(null==score){
return null;
}
let color="gray";
if(score==-4||score==-5){
color="red";
}else if(score==-3||score==-2){
color="hotPink";
}else if(score==-1){
color="lightPink";
}else if(score==0){
color="gray";
}else if(score==1){
color="lightGreen";
}else if(score==2||score==3){
color="lawnGreen";
}else if(score==4||score==5){
color="green";
}
return color;
}
let getMonsterHtml=function(monster,myMonster,newBgmId){
if(monster){
//if(!monster.score){
// monster.score=0;
//}
let nameColor=getColor(monster.score);
monster.color=nameColor;
let type="";
if(monster.type.field=="SLAVE"){
type=",主号:";
if(monster.masterId){
type+='<a href="/user/'+monster.master.bgmId+'">'+monster.master.name+'</a>';
}else{
type+="未知";
}
}
let mcs="";
if(monster.mcs&&monster.mcs.length>0){
mcs=' ';
let high='';
let middle='';
let low='';
let unknown='';
for(let i=0;i<monster.mcs.length;i++){
let mc=monster.mcs[i];
cliqueMap[mc.clique.id]=mc.clique;
let mCStatus='';
if(mc.mCStatus.field=="JOIN"){
}else if(mc.mCStatus.field=='SUS_JOIN'){
mCStatus='疑似';
}else{
continue;
}
if(mc.level.field=='HIGH'){
high+='<span style="color:red" class="cliqueTipBtn" cliqueId="'+mc.clique.id+'">'+mCStatus+'【'+mc.clique.name+'】高级成员</span>,';
}else if(mc.level.field=='MIDDLE'){
middle+='<span style="color:hotPink" class="cliqueTipBtn" cliqueId="'+mc.clique.id+'">'+mCStatus+'【'+mc.clique.name+'】中级成员</span>,';
}else if(mc.level.field=='LOW'){
low+='<span style="color:lightPink" class="cliqueTipBtn" cliqueId="'+mc.clique.id+'">'+mCStatus+'【'+mc.clique.name+'】低级成员</span>,';
}else if(mc.level.field=='UNKNOWN'){
unknown+='<span style="color:gray" class="cliqueTipBtn" cliqueId="'+mc.clique.id+'">'+mCStatus+'【'+mc.clique.name+'】成员</span>,';
}
}
mcs+=high+middle+low+unknown;
mcs=mcs.substring(0, mcs.length - 1);
}
let name=monster.name;
if(!name){
if(!myMonster||!myMonster.name){
return '';
}
name=myMonster.name+'[暂无公共标记]';
}
return '<span style="color:'+nameColor+'" class="monsterTipBtn" bgmId="'+monster.bgmId+'" score="'+monster.score+'">('+name+type+')</span>'+mcs+' ';
}else{
return "";
}
}
let monsterMap={};
let myMonsterMap={};
let cliqueMap={};
let initMonster=function(bgmId,newBgmId,judgeInitPost){
if(!bgmId||!newBgmId){
checkAva++;
return;
}
let monster=monsterMap[newBgmId];
if(!monster){
monsterMap[newBgmId]={data:null};
$.get(yodbUrl+'anon/vulgar/monster/vo/detailByBgmId/'+bgmId, function(res){
if(!res||!res.data){
if(newBgmId!=bgmId){
$.get(yodbUrl+'anon/vulgar/monster/vo/detailByBgmId/'+newBgmId, function(res){
monsterMap[newBgmId]=res;
initMyMonster(res.data,bgmId,newBgmId,judgeInitPost);
});
}else{
checkAva++;
initPost();
}
}else{
monsterMap[newBgmId]=res;
initMyMonster(res.data,bgmId,newBgmId,judgeInitPost);
}
});
}else{
checkAva++;
initPost();
}
}
let initMyMonster=function(monsterData,bgmId,newBgmId,judgeInitPost){
let myMonster=myMonsterMap[newBgmId];
if(!checkBgmIdBind){
setMonsterHtml(monsterData,null,bgmId,newBgmId,judgeInitPost);
return;
}
if(!myMonster){
myMonsterMap[newBgmId]={data:null};
$.get(yodbUrl+'anon/vulgar/monsterScore/detailByBgmId/'+bgmId+"?newMyBgmId="+myBgmId+"&oldMyBgmId="+myBgmId2, function(res){
if(!res||!res.data){
if(newBgmId!=bgmId){
$.get(yodbUrl+'anon/vulgar/monsterScore/detailByBgmId/'+newBgmId+"?newMyBgmId="+myBgmId+"&oldMyBgmId="+myBgmId2, function(res){
myMonsterMap[newBgmId]=res;
setMonsterHtml(monsterData,res.data,bgmId,newBgmId,judgeInitPost);
});
}else{
setMonsterHtml(monsterData,res.data,bgmId,newBgmId,judgeInitPost);
}
}else{
myMonsterMap[newBgmId]=res;
setMonsterHtml(monsterData,res.data,bgmId,newBgmId,judgeInitPost);
}
});
}
}
let initPost=function(){
if(checkAva!=allAva){
return;
}
let pageHeader=$("#pageHeader");
let header=$("#header");
if(pageHeader.length==1||header.length==1){
let clearits=$("#comment_list .clearit>.inner");
if(clearits.length==0){
return;
}
let allReply=0;
let goodReply=0;
let badReply=0;
let littleBadReply=0;
let zeroReply=0;
for(let i=0;i<clearits.length;i++){
allReply++;
let clearit=clearits.eq(i);
let monsterTipBtn=clearit.find("strong").eq(0).find(".monsterTipBtn");
if(monsterTipBtn.length>=1){
let score=Number(monsterTipBtn.eq(0).attr("score"));
if(score>0){
goodReply++;
}else if(score<-2){
badReply++;
}else if(score<0&&score>=-2){
littleBadReply++;
}else{
zeroReply++;
}
}else{
zeroReply++;
}
}
let degree=Math.round(badReply/allReply*100);
let html="<br><span style='color:"+(degree<=10?"green":(degree>=50?"red":"gray"))+"'>总回复数:"+allReply+" 贵物回复数:"+badReply+" 不那么贵物的回复数:"+littleBadReply+" 贵物出现率:"+degree+"%</span>";
pageHeader.find("h1").after(html);
header.find("h1").after(html);
}
}
async function executeAsyncTask() {
await initVulgar();
initBgmerInfoTag();
}
let checkBgmIdBind=false;
$.post(yodbUrl+"anon/checkBgmIdBind",
{"newBgmId":myBgmId,"oldBgmId":myBgmId2,"href":window.location.href}, function(checkBgmIdBindRes){
checkBgmIdBind=checkBgmIdBindRes.data;
if(!myBgmId&&!myBgmId2){
executeAsyncTask();
}else{
$.get(yodbUrl+'anon/vulgar/monster/vo/detailByBgmId/'+myBgmId, function(res){
if(!res||!res.data){
if(myBgmId2!=myBgmId){
$.get(yodbUrl+'anon/vulgar/monster/vo/detailByBgmId/'+myBgmId2, function(res){
judgeHome(res.data);
});
}else{
judgeHome(res.data);
}
}else{
judgeHome(res.data);
}
});
}
});
let judgeHome=function(monster){
if(!monster||!monster.score){
executeAsyncTask();
return;
}
if(monster.score<=-3){
alert("你也配用我的组件?");
}else{
executeAsyncTask();
}
}
});
let bgmerInfoTags={};
let initBgmerInfoTag=function(){
if(window.location.host.indexOf("/anime/list/")>0){
return;
}
let len=$("a.avatar").length;
for(let i=0;i<len;i++){
let ava=$("a.avatar").eq(i);
let hrefVal=ava.attr("href");
if(hrefVal.indexOf("/user/")==-1){
continue;
}
let split=hrefVal.split("/");
let newIndex=split[split.length-1];
//暂时设置250毫秒访问一次,有可能会因为网络原因产生阻塞
setTimeout(() => {
setBgmerInfoTag(newIndex);
}, i*250);
}
}
let setBgmerInfoTag=function(bgmId){
if(bgmerInfoTags[bgmId]){
return;
}
bgmerInfoTags[bgmId]=1;
let bgmerHome=baseUrl+"/user/"+bgmId;
let bgmerAnimeCollect=baseUrl+"/anime/list/"+bgmId+"/collect";
$.get(bgmerHome,function(html,status){
let $html=$(html);
let bgmerInfoTag={};
let time;
let $networks=$html.find("#user_home .network_service li span");
for(let i=0;i<$networks.length;i++){
if($networks.eq(i).text()=="Bangumi"){
time=$networks.eq(i).next().text().replace(" 加入","");
let dateParts = time.split("-");
let dateObject = new Date(dateParts[0], parseInt(dateParts[1]) - 1, dateParts[2]);
let msPerDay = 24 * 60 * 60 * 1000;
let nowDate = new Date();
let timeDiff = Math.abs(nowDate - dateObject);
let joinDay= Math.floor(timeDiff / msPerDay);
bgmerInfoTag.joinTime=time;
bgmerInfoTag.joinDay=joinDay;
if(joinDay<=30){
bgmerInfoTag.joinTag=" 极新 ";
}else if(joinDay<=100){
bgmerInfoTag.joinTag=" 新 ";
}
break;
}
}
let animeNum=0;
let $anime=$html.find("#anime li a[href='/anime/list/"+bgmId+"/collect']");
if($anime.length>0){
animeNum=$anime.eq(0).text().replace("部看过","");
}
bgmerInfoTag.animeNum=animeNum;
if(animeNum==0){
bgmerInfoTag.animeTag=" 无 ";
}else if(animeNum<=10){
bgmerInfoTag.animeTag=" 极少 ";
}else if(animeNum<=100){
bgmerInfoTag.animeTag=" 少 ";
}
bgmerInfoTags[bgmId]=bgmerInfoTag;
let $user=$("strong a[href='/user/"+bgmId+"']:not(.avatar,.focus)").parent();
let baseHtml='<span class="hoverText" hover-text="'+bgmerInfoTag.joinTime+'加入bgm" style="background-color:red;border-radius:5px;color:white;">'+(bgmerInfoTag.joinTag?bgmerInfoTag.joinTag:'')+'</span>'
+' <span class="hoverText" hover-text="看过'+bgmerInfoTag.animeNum+'部动画" style="background-color:red;border-radius:5px;color:white;">'+(bgmerInfoTag.animeTag?bgmerInfoTag.animeTag:'')+'</span>';
if(bgmerInfoTag.animeNum>0){
$.get(bgmerAnimeCollect,function(animeHtml,animeStatus){
let $animeHtml=$(animeHtml);
let $lis=$animeHtml.find("#browserItemList li");
let lastLookAnimeDay=0;
if($lis.length>0){
let $href=$lis.eq(0).find("a").eq(0).prop("href");
$.get($href,function(subjectHtml,subjectStatus){
let $subjectHtml=$(subjectHtml);
let last_li_time;
// let end_time;
// let start_time;
// $subjectHtml.find("#infobox")
// 可以先取其他形式的日期,但我懒
let $sub_subtitle_li=$subjectHtml.find("#subject_detail ul.prg_list li.subtitle");
let $sub_last_li=$subjectHtml.find("#subject_detail ul.prg_list li").last();
if($sub_subtitle_li.length>0){
$sub_last_li=$sub_subtitle_li.eq(0).prev();
}
if($sub_last_li.length>0){
let sub_last_id=$sub_last_li.eq(0).find("a").attr("rel");
$subjectHtml.find(sub_last_id+" span.tip").contents().each(function() {
if (this.nodeType === Node.TEXT_NODE) {
var text = $(this).text().trim();
if (text.startsWith('首播:')) {
var datePart = text.substring(3).trim();
if(datePart){
}
var dateMatch = datePart.match(/(\d{4}-\d{2}-\d{2})/);
if (dateMatch) {
last_li_time = new Date(dateMatch[0]);
}
}
}
});
if(!last_li_time){
last_li_time=new Date();
}
var currentDate = new Date();
if (last_li_time <= currentDate) {} else {
$user.after(baseHtml+' <span class="hoverText" hover-text="标记失信,tag大几率不准" style="background-color:red;border-radius:5px;color:white;"> 标记失信 </span>');
return;
}
}
let lastLookAnimeTime=$lis.eq(0).find("p.collectInfo span.tip_j").text();
bgmerInfoTags[bgmId].lastLookAnimeTime=lastLookAnimeTime;
let dateParts = lastLookAnimeTime.split("-");
let dateObject = new Date(dateParts[0], parseInt(dateParts[1]) - 1, dateParts[2]);
let msPerDay = 24 * 60 * 60 * 1000;
let nowDate = new Date();
let timeDiff = Math.abs(nowDate - dateObject);
bgmerInfoTags[bgmId].lastLookAnimeDay=lastLookAnimeDay;
initTag(baseHtml,bgmId,$user);
});
}else{
bgmerInfoTags[bgmId].lastLookAnimeDay=lastLookAnimeDay;
initTag(baseHtml,bgmId,$user);
}
});
}else{
// 与“无”tag重复,暂时去掉
// $user.after(baseHtml+' <span class="hoverText" hover-text="没看过动画" style="background-color:red;border-radius:5px;color:white;"> 从未入宅 </span>');
$user.after(baseHtml);
}
});
}
let initTag=function(baseHtml,bgmId,$user){
if(bgmerInfoTags[bgmId].lastLookAnimeDay>=365){
bgmerInfoTags[bgmId].lastLookAnimeTag=" 早已脱宅 ";
}else if(bgmerInfoTags[bgmId].lastLookAnimeDay>=100){
bgmerInfoTags[bgmId].lastLookAnimeTag=" 已脱宅 ";
}else if(bgmerInfoTags[bgmId].lastLookAnimeDay>=30){
bgmerInfoTags[bgmId].lastLookAnimeTag=" 近期脱宅 ";
}else if(bgmerInfoTags[bgmId].lastLookAnimeDay>=10){
bgmerInfoTags[bgmId].lastLookAnimeTag=" 久未看 ";
}
$user.after(baseHtml+' <span class="hoverText" hover-text="最后一次看过动画在'+bgmerInfoTags[bgmId].lastLookAnimeTime+'" style="background-color:red;border-radius:5px;color:white;">'+(bgmerInfoTags[bgmId].lastLookAnimeTag?bgmerInfoTags[bgmId].lastLookAnimeTag:'')+'</span>');
}
})();