Last active
June 23, 2017 23:22
-
-
Save suissa/9d8bffff4173007fdc17fab63681ebbb to your computer and use it in GitHub Desktop.
WhatsColour is a background coloring for Whatsapp Web
This file contains 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
( () => { | |
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