Skip to content

Instantly share code, notes, and snippets.

@praveen-me
Created September 20, 2018 20:24
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 praveen-me/3bb7b84874f00acfe51da51b6c70a814 to your computer and use it in GitHub Desktop.
Save praveen-me/3bb7b84874f00acfe51da51b6c70a814 to your computer and use it in GitHub Desktop.
Chrome Extension Blog
// function for set Greet
function setGreet() {
let userName = localStorage.getItem('userNameKey');
let now = new Date();
let hours = now.getHours();
//set greet msg according to hours
if(hours >= 4 && hours <= 12) {
greet_msg.innerHTML = 'Good Morning';
} else if(hours >= 13 && hours <= 16) {
greet_msg.innerHTML = 'Good AfterNoon';
} else if(hours >= 17 && hours <= 20) {
greet_msg.innerHTML = 'Good Evening';
} else if(hours >= 21 && hours <= 23){
greet_msg.innerHTML = 'Good Night';
} else if(hours >= 0 && hours <= 3) {
greet_msg.innerHTML = 'Good Night';
}
userNameElm.innerHTML = userName;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment