Advertisement
Guest User

Pxls Chat Purged Message Viewer

a guest
Jan 12th, 2021
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Pxls Chat Purged Message Viewer
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1.01
  5. // @description  try to take over the world!
  6. // @author       You
  7. // @match        https://pxls.space/
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.     var chatNodeHistory = new Map();
  15.     function timer() {
  16.         let chatBody = document.getElementById('chat-body');
  17.         let oldSize = chatNodeHistory.size;
  18.         for (let node of chatBody.childNodes) {
  19.             let id = node.dataset.id;
  20.             if (id) {
  21.                 chatNodeHistory.set(id, node);
  22.             }
  23.         }
  24.         let newCount = chatNodeHistory.size - oldSize;
  25.         if (newCount) console.log(`Saved ${newCount} nodes.`)
  26.         let lastId = null;
  27.         let purgedCount = 0;
  28.         for (let [id, node] of chatNodeHistory) {
  29.             let visibleNode = chatBody.querySelector(`[data-id="${id}"]`);
  30.             if (!visibleNode) {
  31.                 node.querySelector(`span`).style.color = 'red';
  32.                 let lastNode = chatBody.querySelector(`[data-id="${lastId}"]`);
  33.                 if (lastNode) lastNode.after(node);
  34.                 purgedCount++;
  35.             }
  36.             lastId = id;
  37.         }
  38.         if (purgedCount) console.log(`Detected ${purgedCount} purged nodes.`)
  39.     }
  40.     var timerVar = setInterval(timer, 5000);
  41. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement