Skip to content

Instantly share code, notes, and snippets.

@suissa
Last active June 23, 2017 23:22
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 suissa/9d8bffff4173007fdc17fab63681ebbb to your computer and use it in GitHub Desktop.
Save suissa/9d8bffff4173007fdc17fab63681ebbb to your computer and use it in GitHub Desktop.
WhatsColour is a background coloring for Whatsapp Web
( () => {
const getChatTitle = () => document.querySelector('h2.chat-title > span').innerText;
const colour = ( WhatsColour ) => {
let contains = WhatsColour.colorList.findIndex( c => c.name === WhatsColour.getChatTitle() );
if(contains > -1){
document.querySelector('div#main').style.backgroundColor = WhatsColour.colorList[contains].color;
}
}
const getPerson = (color) => ( { name: getChatTitle(), color } );
const setColor = (colorName) =>
WhatsColour.colorList.push(getPerson(colorName)) | colour();
const WhatsColour = {
getChatTitle,
setColor,
colorList: []
};
window.WhatsColour = WhatsColour;
document.querySelector('div.chatlist.infinite-list')
.addEventListener('click', colour(WhatsColour));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment