// ==UserScript==
// @name 哔哩哔哩(b站)显示UID和注册时间
// @namespace http://tampermonkey.net/
// @version 0.2
// @description 首页、直播、会员购、订单中心、漫画均可显示UID和注册时间
// @author AN drew
// @match https://*.bilibili.com/*
// @match https://member.bilibili.com/*
// @require https://code.jquery.com/jquery-3.1.1.min.js
// @require http://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
var uid = $.cookie("DedeUserID")
if($.cookie('registration_id')==undefined)
$.cookie('registration_id', uid, { expires: 365, path: "/", domain: "bilibili.com" });
if(window.location.href.indexOf("member.bilibili.com") > -1)
{
var timer = setInterval(function(){
if($(".tips-calendar_wrap").length>0)
{
var s =$(".tips-calendar_wrap").wrap("<div />").parent().html()
console.log(s)
if(s.indexOf("第")>-1)
{
var start = s.indexOf("第")+1;
var end = s.indexOf("天")
var registration_days= s.substring(start,end)
console.log(registration_days)
var today = new Date()
var d=today.getDate()
d=d-registration_days
var theday=new Date(today.getFullYear(),today.getMonth(),d);
var ly = parseInt(theday.getFullYear());
var lm = parseInt(1+theday.getMonth());
var ld = parseInt(theday.getDate());
clearInterval(timer)
if($.cookie('registration_days')==undefined || $.cookie('registration_id')!=uid)
{
$.cookie('registration_days', ly+"-"+lm+"-"+ld, { expires: 365, path: "/", domain: "bilibili.com" });
$.cookie('registration_id', uid, { expires: 365, path: "/", domain: "bilibili.com" });
}
}
}
},100)
}
var u ='<span><span id="uid"> UID: </span><span id="id">xxx </span></span>'
var $uid =$(u)
$uid.css({"background":"#7CD4F2",
"color":"white",
"font-size":"10px",
"margin-right":"30px",
"padding":"1px 1px 1px 1px",
"width": "28px",
"height": "14px"})
var t ='<span><span id="registration-time"><a href="https://member.bilibili.com/v2#/home" target="_blank" style="color:#00A1D6;text-decoration: underline">查看注册天数</a></span><span id="time"></span></span>'
var $time=$(t)
$time.css({"font-size":"10px",
"margin-left":"20px",
"padding":"1px 1px 1px 1px",
"width": "56px",
"height": "14px"})
var t2 ='<span><span id="registration-time"> 注册时间: </span><span id="time">xxxx-xx-xx</span></span>'
var $time2=$(t2)
$time2.css({"background":"#6DC781",
"color":"white",
"font-size":"10px",
"margin-left":"20px",
"padding":"1px 1px 1px 1px",
"width": "56px",
"height": "14px"})
setInterval(function(){
if(window.location.href.indexOf("show.bilibili.com/orderlist") > -1) //订单中心
{
if($(".avatar").length>0)
{
$(".avatar").hover(function(){
if($(".myinfo").length==0)
{
var $div = $(".level").clone(true)
$div.empty()
$div.attr("class","myinfo")
$div.css({"vertical-align":"top"})
$uid.css({"margin-left":"15px"})
$uid.css({"margin-right":"0px"})
$div.append($uid)
if($.cookie("registration_days")!=null && $.cookie('registration_id')==uid)
{
$time2.css({"margin-left":"8px"})
$div.append($time2)
$(".level").before($div)
$("#time").text($.cookie("registration_days")+'\u00a0')
}
else
{
$time.css({"margin-left":"8px"})
$div.append($time)
$(".level").before($div)
}
if(uid!=undefined)
$("#id").text(uid+" ")
}
$(".detail").css({"padding-top": "20px","height":"180px"})
$(".title").css({"height":"52px"})
})
}
}
else if(window.location.href.indexOf("show.bilibili.com") > -1) //会员购
{
if($(".myinfo").length==0 && $(".user-panel").length>0)
{
$(".user-uname").css({"padding-bottom":"5px"})
$(".panel-list").css({"height":"55px"})
var $div = $("<div></div>")
$div.attr("class","myinfo")
$div.css({"vertical-align":"top","margin-top":"5px","display":"block"})
$uid.css({"margin-right":"0px"})
$div.append($uid)
if($.cookie("registration_days")!=null && $.cookie('registration_id')==uid)
{
$time2.css({"margin-left":"10px"})
$div.append($time2)
$(".user-uname").append($div)
$("#time").text($.cookie("registration_days")+'\u00a0')
}
else
{
$time.css({"margin-left":"10px"})
$div.append($time)
$(".user-uname").append($div)
}
if(uid!=undefined)
$("#id").text(uid+" ")
}
}
else if(window.location.href.indexOf("live.bilibili.com") > -1) //直播
{
if($(".user-panel.dp-table").length>0)
{
$(".user-panel.dp-table").hover(function(){
if($(".myinfo").length==0)
{
var $div = $("<div></div>")
$div.attr("class","myinfo")
$div.css({"vertical-align":"top","margin-top":"5px","display":"block"})
$uid.css({"margin-right":"0px"})
$div.append($uid)
if($.cookie("registration_days")!=null && $.cookie('registration_id')==uid)
{
$time2.css({"margin-left":"40px"})
$div.append($time2)
$(".content-ctnr.border-box.p-relative.over-hidden").prepend($div)
$("#time").text($.cookie("registration_days")+'\u00a0')
}
else
{
$time.css({"margin-left":"40px"})
$div.append($time)
$(".content-ctnr.border-box.p-relative.over-hidden").prepend($div)
}
if(uid!=undefined)
$("#id").text(uid+" ")
}
})
}
}
else if(window.location.href.indexOf("manga.bilibili.com") > -1) //漫画
{
if($(".user-panel.p-relative").length>0)
{
$(".user-panel.p-relative").hover(function(){
if($(".myinfo").length==0)
{
var $div = $("<div></div>")
$div.attr("class","myinfo")
$div.css({"vertical-align":"top","margin-top":"5px","display":"block"})
$uid.css({"margin-right":"0px"})
$uid.attr("id","uuu")
$div.append($uid)
if($.cookie("registration_days")!=null && $.cookie('registration_id')==uid)
{
$time2.css({"margin-left":"0px"})
$time2.attr("id","ttt")
$div.append($time2)
$(".user-name.t-center").after($div)
$("#time").text($.cookie("registration_days")+'\u00a0')
}
else
{
$time.css({"margin-left":"0px"})
$time.attr("id","ttt")
$div.append($time)
$(".user-name.t-center").after($div)
}
if(uid!=undefined)
$("#id").text(uid+" ")
$("#uuu").wrap("<div></div>")
$("#ttt").wrap("<div></div>")
$("#ttt").parent().css({"margin-top":"5px"})
}
})
}
}
else
{
if($(".mini-avatar").length>0) //主站
{
$(".mini-avatar").hover(function(){
if($(".myinfo").length==0)
{
var $div = $(".coins").clone(true)
$div.empty()
$div.attr("class","myinfo")
$div.css({"vertical-align":"top","margin-top":"5px"})
$div.append($uid)
if($.cookie("registration_days")!=null && $.cookie('registration_id')==uid)
{
$div.append($time2)
$(".level-content").before($div)
$("#time").text($.cookie("registration_days")+'\u00a0')
}
else
{
$div.append($time)
$(".level-content").before($div)
}
if(uid!=undefined)
$("#id").text(uid+" ")
}
})
}
}
},10)
// Your code here...
})();