Facebook Chat Group Chat Painter

Paint the title of group chats in different color to make them easier to distinguish

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Facebook Chat Group Chat Painter
// @namespace   userscript.danielrozenberg.com
// @description Paint the title of group chats in different color to make them easier to distinguish
// @include     https://www.facebook.com/*
// @version     1.1
// @grant       none
// ==/UserScript==


// Add the CSS style to the page
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = ".focusedTab .__fcgcp_group { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVAQMAAACT2TfVAAAABlBMVEUAAAAAAAClZ7nPAAAAAnRSTlMAKEMmZcIAAAA9SURBVAjXdcmhFYAgFADA4xm0WW2uYXMtm4zGKIxA/IHHYwKunoHuEC7No/oUIadgC/bGWbkLb+bHIPVlT7UWFLs2cSVZAAAAAElFTkSuQmCC) !important; }";
document.head.appendChild(style);

// Define the repainting function and set it to run on interval
function repaintChats() {
  for (elm of document.querySelectorAll('.fbNubFlyout .titlebar:not(.__fcgcp)')) {
    elm.classList.add('__fcgcp');
    if (elm.querySelector('a.titlebarText[href*="/messages/conversation"]')) {
      elm.classList.add('__fcgcp_group');
    }
  }
}

window.setInterval(repaintChats, 100);