GITHUBの日付の表示が...4days ago
みたいな相対表示なのを、
絶対表示で確認するために設定などを探していた時に見つけたブックマークレット(https://qiita.com/kobake@github/items/06dcc5b6135fd38adeb7)が古くて動かなくなっていたため、新しく作りました。
javascript:var%20times%3Ddocument.querySelectorAll('relative-time')%3Bfor(var%20i%3D0%3Bi%20%3C%20times.length%3Bi%2B%2B)%7Bvar%20date%3Dnew%20Date(times%5Bi%5D.getAttribute('datetime'))%3Bvar%20dateString%3D''%3BdateString%20%2B%3Ddate.getFullYear()%2B%20'%2F'%3BdateString%20%2B%3D('0'%20%2B(date.getMonth()%2B%201)).slice(-2)%2B%20'%2F'%3BdateString%20%2B%3D('0'%20%2B%20date.getDate()).slice(-2)%2B%20'%20'%3BdateString%20%2B%3D('0'%20%2B%20date.getHours()).slice(-2)%2B%20'%3A'%3BdateString%20%2B%3D('0'%20%2B%20date.getMinutes()).slice(-2)%2B%20'%3A'%3BdateString%20%2B%3D('0'%20%2B%20date.getSeconds()).slice(-2)%3Btimes%5Bi%5D.innerText%3DdateString%3B%7Dvoid(0);
元のスクリプト
var times = document.querySelectorAll("relative-time");
for (var i = 0; i < times.length; i++) {
var date = new Date(times[i].getAttribute("datetime"));
var dateString = "";
dateString += date.getFullYear() + "/";
dateString += ("0" + (date.getMonth() + 1)).slice(-2) + "/";
dateString += ("0" + date.getDate()).slice(-2) + " ";
dateString += ("0" + date.getHours()).slice(-2) + ":";
dateString += ("0" + date.getMinutes()).slice(-2) + ":";
dateString += ("0" + date.getSeconds()).slice(-2);
times[i].innerText = dateString;
}