Skip to content

Instantly share code, notes, and snippets.

@Namek
Created October 15, 2015 14:02
Show Gist options
  • Save Namek/7d1d104a7eaac7de972c to your computer and use it in GitHub Desktop.
Save Namek/7d1d104a7eaac7de972c to your computer and use it in GitHub Desktop.
Materialize website
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
var oneDayInMs = 1000*60*60*24;
var currentTimeInMs = new Date().getTime(); // UTC time
var timeInDays = Math.floor(currentTimeInMs / oneDayInMs);
var numberForToday = timeInDays % 9999;
var colors = ["673ab7","3f51b5","2196f3","03a9f4","0288d1","01579b","006064","26c6da","0091ea","4caf50","2e7d32","00695c","64ffda","00c853","8bc34a","ffc107","ffb300","ff9800","f4511e","bf360c","795548","9e9e9e","fafafa","9e9e9e","757575","6d4c41","607d8b","b0bec5","78909c","455a64","212121"]
var index = numberForToday % colors.length;
var color = '#' + colors[index];
addGlobalStyle('body{background-color:' + color + ' !important;}');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment