Advertisement
Guest User

Youtube Chat

a guest
Oct 1st, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Youtube chat
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://www.youtube.com/live_chat*
  8. // @grant none
  9. // @require http://code.jquery.com/jquery-latest.js
  10. // ==/UserScript==
  11.  
  12. $(function() {
  13.  
  14. // Select the node that will be observed for mutations
  15. const targetNode = document.getElementById('contents');
  16.  
  17. // Options for the observer (which mutations to observe)
  18. const config = { childList: true, subtree: true };
  19.  
  20. // Callback function to execute when mutations are observed
  21. const callback = function(mutationsList, observer) {
  22. // Use traditional 'for loops' for IE 11
  23. for(const mutation of mutationsList) {
  24. if (mutation.type != 'childList')
  25. continue;
  26. // so we don't end up in an endless loop when modifying
  27. // the src attribute.
  28. if (mutation.addedNodes.length == 0)
  29. continue;
  30. for(const node of mutation.addedNodes) {
  31. if (node.src != null && node.src.endsWith('svg')) {
  32. node.src = node.src.replace(/svg$/, 'png');
  33. }
  34. }
  35. }
  36. };
  37.  
  38. // Create an observer instance linked to the callback function
  39. const observer = new MutationObserver(callback);
  40.  
  41. // Start observing the target node for configured mutations
  42. observer.observe(targetNode, config);
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement