Facebook Chat Restored

Miss being able to turn off/on your chat for a select few? Miss it no more, as with this script, it's returned!

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 or Violentmonkey 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.

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

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 Restored
// @namespace    https://theimperium.org/
// @namespace    https://github.com/imperious1
// @version      1.0.1.0
// @description  Miss being able to turn off/on your chat for a select few? Miss it no more, as with this script, it's returned!
// @author       Imperious1
// @match        *://www.facebook.com/*
// @grant        none
// ==/UserScript==

/**
 * Listens for Focus out events (i.e when the advanced
 * settings pop up comes up) and then runs this code
 *
 * Changes the class names to their defaults except
 * it removes "hidden_elem", which makes the options
 * visible again.
 */
var runNecessary = true;
//var firstRun = true;

/*
function setListeners() {
    document.getElementsByClassName('_42fu')[0].onclick = function () {
        runNecessary = true;
    };
    document.getElementsByClassName('_42fu')[1].onclick = function () {
        runNecessary = true;
    };
}*/

document.addEventListener('focusout', function () {
    var whitelist = document.getElementsByClassName('whitelistSection');
    var blacklist = document.getElementsByClassName('blacklistSection');

    if (whitelist.length > 0 && runNecessary) {
        whitelist[0].className = 'pbm whitelistSection unselected';
        document.getElementsByClassName('tokenizerArea')[0].className = 'tokenizerArea';

        whitelist[0].onclick = function () {
            blacklist[0].className = 'pbm blacklistSection unselected';
            whitelist[0].className = 'pbm whitelistSection selected';
        };
        blacklist[0].onclick = function () {
            whitelist[0].className = 'pbm whitelistSection unselected';
            blacklist[0].className = 'pbm blacklistSection selected';
        };
        runNecessary = false;
        /*if (firstRun)
            setListeners();

        firstRun = false;*/
    }
});