哔哩哔哩注册时间查询

查询B站账号注册时间(只能查询登录账号的注册时间)

// ==UserScript==
// @name         哔哩哔哩注册时间查询
// @namespace    undefined
// @version      0.1.8
// @description  查询B站账号注册时间(只能查询登录账号的注册时间)
// @author       coldrainf
// @match        *://space.bilibili.com/*
// @grant        unsafeWindow
// @require      http://code.jquery.com/jquery-3.2.1.js
// @icon 		 https://www.bilibili.com/favicon.ico
// ==/UserScript==
(function () {
	'use strict';
	//初始化
	$(function () {
		if (DedeUserID == mid) pageInit();
	});
	function pageInit() {
		setTimeout(function () {
			if ($(".info-personal").length > 0) {
				if ($(".info-personal").find(".info-jointime").length == 0) {
					$(".info-personal").append(
						'<div data-v-31d5659a="" class="info-jointime"><span data-v-31d5659a="" class="info-command">注册</span><span data-v-31d5659a="" class="info-value">正在查询...</span></div>'
					);
				}
				getJointime()
			} else {
				pageInit();
			}
		}, 1000);
	}

	function getJointime() {
		$.ajax({
			url: "//member.bilibili.com/x2/creative/h5/calendar/event?ts=0",
			type: "GET",
			xhrFields: {
				withCredentials: true
			},
			dataType: "json",
			success: function (data) {
				if (!data.data) return $(".info-jointime .info-value").text("查询失败")
				if (!data.data.pfs) return $(".info-jointime .info-value").html('请先<a href="//passport.bilibili.com/login">登录</a>');
				let time = new Date(data.data.pfs.profile.jointime * 1000);
				let year = time.getFullYear();
				let month = time.getMonth() + 1;
				let date = time.getDate();
				let hours = time.getHours().toString().padStart(2, '0');
				let minutes = time.getMinutes().toString().padStart(2, '0');
				let seconds = time.getSeconds().toString().padStart(2, '0');
				$(".info-jointime .info-value").text(`${year}-${month}-${date} ${hours}:${minutes}:${seconds}`);
				//$(".info-jointime .info-value").text(`${year}-${month}-${date}`);
			},
			error: function () {
				$(".info-jointime .info-value").text("网络错误")
			}
		});
		$(".wrapper").click(function () {
			if ($(".info-personal").find(".info-jointime").length == 0) {
				pageInit();
			}
		});
	}
})();