Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name File dates
- // @description Adds a human readable date timestamp to file epoch timestamps
- // @namespace skitty
- // @include *://boards.4chan.org/*
- // @run-at document-start
- // @author Skitty
- // @version 1
- // ==/UserScript==
- (function () {
- "use-strict";
- let parse = function (ID, str) {
- let fileInfo = document.querySelector("#fT"+ID.match(/(\d+)/g)[0]+" > .file-info");
- let fileText = parseInt((((str||fileInfo.querySelector("a:nth-child(1)").textContent).match(/(\d{13,})/g))||[""])[0]);
- if(fileText)
- fileInfo.title = new Date(fileText).toLocaleString();
- };
- document.addEventListener("4chanXInitFinished", function() {
- document.querySelectorAll(".file-info").forEach(function(element) {
- parse(element.parentNode.id, element.childNodes[0].text);
- });
- }, false);
- document.addEventListener("ThreadUpdate", function(e) {
- for(let i in e.detail.newPosts)
- parse(e.detail.newPosts[i]);
- }, false);
- })();
Advertisement
Add Comment
Please, Sign In to add comment