// ==UserScript==
// @name Aparecium
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Shows User's create time in V2ex.
// @author FledgeShiu
// @copyright No License
// @match *://*./t/*
// @match *:///t/*
// @icon https:///static/icon-192.png
// @grant none
// ==/UserScript==
(function() {
'use strict';
async function run() {
let comment_nodes = document.querySelectorAll("div[id^=r_].cell");
comment_nodes.forEach(async function(node){
const user = node.querySelectorAll("tr>td:last-child")[0];
const user_info_url = user.querySelectorAll("strong>a")[0].href;
const user_name = user_info_url.split('/').at(-1);
const response = await fetch(`https://${window.location.host}/api/members/show.json?username=${user_name}`);
const jsonData = await response.json();
const date = new Date(jsonData.created * 1000).toLocaleDateString()
const age_element = user.getElementsByClassName("ago")[0];
const next_element = age_element.nextSibling
const empty_text = document.createTextNode('\u00A0 \u00A0');
user.insertBefore(empty_text, next_element);
let new_element = document.createElement("span");
new_element.innerHTML = date;
new_element.classList.add("ago");
user.insertBefore(new_element, next_element);
});
}
run()
})();