Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Youtube chat
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match https://www.youtube.com/live_chat*
- // @grant none
- // @require http://code.jquery.com/jquery-latest.js
- // ==/UserScript==
- $(function() {
- // Select the node that will be observed for mutations
- const targetNode = document.getElementById('contents');
- // Options for the observer (which mutations to observe)
- const config = { childList: true, subtree: true };
- // Callback function to execute when mutations are observed
- const callback = function(mutationsList, observer) {
- // Use traditional 'for loops' for IE 11
- for(const mutation of mutationsList) {
- if (mutation.type != 'childList')
- continue;
- // so we don't end up in an endless loop when modifying
- // the src attribute.
- if (mutation.addedNodes.length == 0)
- continue;
- for(const node of mutation.addedNodes) {
- if (node.src != null && node.src.endsWith('svg')) {
- node.src = node.src.replace(/svg$/, 'png');
- }
- }
- }
- };
- // Create an observer instance linked to the callback function
- const observer = new MutationObserver(callback);
- // Start observing the target node for configured mutations
- observer.observe(targetNode, config);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement