Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. /*
  2. * WhatsColour is a background coloring for Whatsapp Web
  3. * Author: WesleyCSJ 2017
  4. * E-mail: wesleyj10@gmail.com
  5. * It is just 1.0 version, keep calm.(i'm not promising future versions).
  6. */
  7.  
  8. (function(){
  9. var colorList = [];
  10. var WhatsColour = {
  11. getChatTitle: getChatTitle,
  12. setColor: setColor,
  13. colorList: colorList
  14. };
  15. window.WhatsColour = WhatsColour;
  16.  
  17. function getChatTitle(){
  18. return document.querySelector('h2.chat-title > span').innerText;
  19. }
  20. function setColor(colorName){
  21. var person = {
  22. name: getChatTitle(),
  23. color: colorName
  24. };
  25. colorList.push(person);
  26. colour();
  27. }
  28. function colour(){
  29. var contains = -1;
  30. var chat_title = getChatTitle();
  31. for(element in colorList){
  32. if(chat_title === colorList[element].name){
  33. contains = element;
  34. break;
  35. }
  36. }
  37. if(contains){
  38. document.querySelector('div#main').style.backgroundColor = colorList[contains].color;
  39. document.querySelector('div.app-wrapper::after').style.backgroundColor = colorList[contains].color;
  40. }
  41. }
  42. document.querySelector('div.chatlist.infinite-list').addEventListener('click', colour);
  43. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement