Last active
July 31, 2019 11:55
-
-
Save Committing/d9766f0a6e7201b14f563131f24155b8 to your computer and use it in GitHub Desktop.
Youtube styled & colored dates
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
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