Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name youtube_chat_shortener
- // @namespace http://tampermonkey.net/
- // @version 1
- // @description this script fires the indians working for google
- // @author Ina
- // @match *.youtube.com/live_chat*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- const targetNode = document.querySelector("#item-offset").querySelector("#items");
- targetNode.innerHTML = "";
- const chatOptimizer = function (mutationsList, observer) {
- for(let mutation of mutationsList) {
- if (mutation.addedNodes[0] && (mutation.addedNodes[0].nodeName=="YT-LIVE-CHAT-PAID-MESSAGE-RENDERER" || mutation.addedNodes[0].nodeName=="YT-LIVE-CHAT-TEXT-MESSAGE-RENDERER")){
- //the '17' bellow is how many posts you'll see in the chat. this doesn't include the super chats attached at the top. you can always check those
- //the next two lines are intentionally duplicate
- if (targetNode.childElementCount>17) {
- targetNode.removeChild(targetNode.firstChild);
- targetNode.removeChild(targetNode.firstChild);
- }
- }
- }
- };
- const chatObserver = new MutationObserver(chatOptimizer);
- chatObserver.observe(targetNode, { attributes: false, childList: true, subtree: true, characterData: false, characterDataOldValue: false });
- })();
Add Comment
Please, Sign In to add comment