daybreakz / Twitch Diplay DELETED messages

// ==UserScript==
// @name         Twitch Diplay DELETED messages
// @namespace    https://openuserjs.org/users/daybreakz
// @version      1.0.0
// @description  Prevent chat messages from being deleted!
// @author       Daybr3akz
// @license      MIT
// @copyright    2017, daybreakz (https://openuserjs.org/users/daybreakz)
// @match        https://www.twitch.tv/*
// @require      http://code.jquery.com/jquery-3.2.1.slim.min.js
// @grant        none
// ==/UserScript==

// // ==OpenUserJS==
// @author daybreakz
// ==/OpenUserJS==

const chatObserver = new MutationObserver(mutations => {
  // console.log(mutations)
  let messageDeleted = false;
  let elementsToReattach = [];
  mutations.forEach(mutation => {
    if (mutation.type == 'childList' && mutation.target.matches('div.chat-line__message')) {
      if (mutation.addedNodes.length > 0) {
        mutation.addedNodes.forEach(n => {
          if (!n.__is_prevented && n.classList && n.classList.contains('chat-line__message--deleted')) {
            n.remove();
            n.__is_prevented = true;
            messageDeleted = true;
          }
        });
      }
      if (mutation.removedNodes.length > 0) {
        mutation.removedNodes.forEach(n => {
          if (!n.__is_prevented) {
            n.__is_prevented = true;
            elementsToReattach.push([mutation.target, n])
          }
        });
      }
    }
  })

  if (messageDeleted && elementsToReattach.length > 0) {
    elementsToReattach.forEach(([target, node]) => {
      target.appendChild(node);
    });
    elementsToReattach.forEach(([target, node]) => {
      target.style.opacity = .5
    });
  }
})

chatObserver.observe(document.documentElement, {
  childList: true,
  subtree: true
})