Skip to content

Instantly share code, notes, and snippets.

@ntnyq
Last active March 5, 2023 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ntnyq/319b02f82e14479a59c593089a9aaa8d to your computer and use it in GitHub Desktop.
Save ntnyq/319b02f82e14479a59c593089a9aaa8d to your computer and use it in GitHub Desktop.
get-bilibili-follow-time
;(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