Last active
March 5, 2023 16:40
-
-
Save ntnyq/319b02f82e14479a59c593089a9aaa8d to your computer and use it in GitHub Desktop.
get-bilibili-follow-time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(async () => { | |
const getSpaceMid = () => location.pathname.split('/').at(1) | |
const spaceName = document.querySelector('#h-name').textContent | |
const style = `background: #42b883; color: #fff; font-size: 16px; padding: 10px 15px; border-radius: 4px; font-weight: 600;` | |
const mid = window._bili_space_mid ?? getSpaceMid() | |
let res = await fetch(`https://api.bilibili.com/x/space/acc/relation?mid=${mid}`, { | |
credentials: 'include', | |
}) | |
res = await res.json() | |
const mtime = res?.data?.relation?.mtime | |
if (!mtime) return console.log('获取关注时间出错') | |
const result = new Date(mtime * 1000).toLocaleString() | |
console.clear() | |
console.log(`%c你从 ${result} 起关注了 ${spaceName}。`, style) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment