Skip to content

Instantly share code, notes, and snippets.

@Committing
Last active July 31, 2019 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Committing/d9766f0a6e7201b14f563131f24155b8 to your computer and use it in GitHub Desktop.
Save Committing/d9766f0a6e7201b14f563131f24155b8 to your computer and use it in GitHub Desktop.
Youtube styled & colored dates
function setDateColors() {
$('ytd-grid-video-renderer').each(function() {
var when = $(this).find('#metadata-line span:nth-child(2)');
var when_text = when.html();
when.css({
color: 'white',
padding: '0 4px',
borderRadius: '4px',
fontSize: '10px',
lineHeight: '16px',
marginTop: '2px'
});
if (when_text.includes('year') || when_text.includes('years')) {
when.css({ backgroundColor: '#802d0d' });
} else if (when_text.includes('month') || when_text.includes('months')) {
when.css({ backgroundColor: '#632209' });
} else if (when_text.includes('week') || when_text.includes('weeks')) {
when.css({ backgroundColor: '#824902' });
} else if (when_text.includes('day') || when_text.includes('days')) {
when.css({ backgroundColor: '#887a14' });
} else if (when_text.includes('hour') || when_text.includes('hours')) {
when.css({ backgroundColor: '#236309' });
} else if (when_text.includes('minute') || when_text.includes('minutes')) {
when.css({ backgroundColor: '#70d447' });
} else if (when_text.includes('second') || when_text.includes('seconds')) {
when.css({ backgroundColor: '#70d447' });
} else {
when.css({ backgroundColor: 'purple' });
}
});
}
setDateColors();
setTimeout(function() {
setDateColors();
}, 1000);
setTimeout(function() {
setDateColors();
}, 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment