Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * WhatsColour is a background coloring for Whatsapp Web
- * Author: WesleyCSJ 2017
- * E-mail: wesleyj10@gmail.com
- * It is just 1.0 version, keep calm.(i'm not promising future versions).
- */
- (function(){
- var colorList = [];
- var WhatsColour = {
- getChatTitle: getChatTitle,
- setColor: setColor,
- colorList: colorList
- };
- window.WhatsColour = WhatsColour;
- function getChatTitle(){
- return document.querySelector('h2.chat-title > span').innerText;
- }
- function setColor(colorName){
- var person = {
- name: getChatTitle(),
- color: colorName
- };
- colorList.push(person);
- colour();
- }
- function colour(){
- var contains = -1;
- var chat_title = getChatTitle();
- for(element in colorList){
- if(chat_title === colorList[element].name){
- contains = element;
- break;
- }
- }
- if(contains){
- document.querySelector('div#main').style.backgroundColor = colorList[contains].color;
- document.querySelector('div.app-wrapper::after').style.backgroundColor = colorList[contains].color;
- }
- }
- document.querySelector('div.chatlist.infinite-list').addEventListener('click', colour);
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement