sfoca chat facebook replay

effetto sfocato sulla chat

// ==UserScript==
// @name          sfoca chat facebook replay
// @namespace     https://greasyfork.org/users/237458
// @version       0.2
// @description   effetto sfocato sulla chat
// @author        figuccio
// @match         https://*.facebook.com/*
// @grant         GM_setValue
// @grant         GM_getValue
// @grant         GM_addStyle
// @grant         GM_registerMenuCommand
// @icon          https://facebook.com/favicon.ico
// @noframes
// @license       MIT
// @require       https://code.jquery.com/jquery-1.11.0.min.js
// ==/UserScript==
function Functioncheckbox() {
document.getElementById("blurCheckbox").click();
}
GM_registerMenuCommand("sfoca/on-off",Functioncheckbox);

(function() {
    'use strict';
    const HTML = `
    <div style="position:fixed; right:50px; top:55px; z-index:9999; background-color: red; padding: 5px; border: 1px solid blue; border-radius: 5px;width:80px;">

    <input type="checkbox"  id="blurCheckbox" title="Sfoca"   value="Sfoca">

    `;
    document.body.insertAdjacentHTML('beforeend', HTML);

  GM_addStyle(`
  input[type=checkbox] {accent-color:green;}
  #blurCheckbox{cursor:pointer;}

  [type=checkbox]:after {
  content: attr(value);
  margin: -3px 15px;
  vertical-align: top;
  white-space: nowrap;
  display: inline-block;
  color:lime;
}
     `);

        function blurContacts() {
        const contactList = document.querySelector(".xwib8y2 ul");
        var checkbox = document.getElementById("blurCheckbox");
        var isChecked = GM_getValue("isChecked", false); // Ottenere lo stato salvato dal local storage, di default falso
        checkbox.checked = isChecked; // Imposta lo stato della casella di controllo in base ai dati salvati

       function toggleBlur() {
            if (checkbox.checked) {
                contactList.style.filter = "blur(7px)";
                document.getElementById("blurCheckbox").value = "Show Chat";
            } else {
                contactList.style.filter = "";
                document.getElementById("blurCheckbox").value = "Hide Chat";
            }
            GM_setValue("isChecked", checkbox.checked); // Salva lo stato della casella di controllo nel local storage
        }

         // Aggiungi il listener di eventi alla casella di controllo
        checkbox.addEventListener("change", toggleBlur);
        toggleBlur();
    }

         // Funzione per creare un MutationObserver per monitorare le modifiche nel documento
        function observeDOM() {
        const observer = new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                blurContacts(); // Chiamare blurContacts() ogni volta che viene rilevata una mutazione nel documento
            });
        });
        const config = { attributes: true, childList: true, subtree: true };
        observer.observe(document.body, config);
    }

    setTimeout(blurContacts, 300);
    setTimeout(blurContacts, 9000); // Ripetere
})();