Last active
January 26, 2018 10:28
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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