Skip to content

Instantly share code, notes, and snippets.

@spacemeowx2
Created April 27, 2019 18:58
Show Gist options
  • Save spacemeowx2/6dba537464351d026c652ce3f883dcec to your computer and use it in GitHub Desktop.
Save spacemeowx2/6dba537464351d026c652ce3f883dcec to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name 显示B站弹幕发送时间
// @namespace http://imspace.cn/
// @version 0.1
// @description 显示B站弹幕发送时间
// @author Space
// @match https://live.bilibili.com/*
// @match http://live.bilibili.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function addTime(list) {
const contents = list.querySelectorAll('.danmaku-content')
for (const c of contents) {
const ts = parseInt(c.parentElement.getAttribute('data-ts'))
const txt = (new Date(ts * 1000)).toLocaleString()
c.setAttribute('title', txt)
}
}
function checkInited() {
const list = document.getElementById('chat-history-list')
if (list.children.length > 0) {
clearInterval(intervalId)
addTime(list)
}
}
let intervalId = setInterval(checkInited, 1000)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment