Skip to content

Instantly share code, notes, and snippets.

@nkmathew
Last active January 26, 2018 10:28
Show Gist options
  • Save nkmathew/c93a9c70ab7ed5f257434de51cb22d48 to your computer and use it in GitHub Desktop.
Save nkmathew/c93a9c70ab7ed5f257434de51cb22d48 to your computer and use it in GitHub Desktop.
Userscript that changes the upload time of a Youtube video to a relative format
// ==UserScript==
// @name Youtube Relative Time
// @namespace http://nkmathew.net
// @author nkmathew
// @description Changes the upload time of a Youtube video to a relative format
// @icon http://www.youtube.com/favicon.ico
// @icon64 http://www.youtube.com/favicon.ico
// @version 0.1.0
// @include /^https?:\/\/(.+\.)?youtube\.com\/watch?.*$/
// @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
var timeNode = document.getElementsByClassName('watch-time-text')[0];
var uploadDate = timeNode.innerText;
var date = /\w\w\w \d\d, \d\d\d\d/.exec(uploadDate);
if (date) {
date = moment(date[0], 'MMM DD, YYYY').fromNow();
timeNode.innerText = `${uploadDate} ≈≈ ${date}`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment