Guest User

Untitled

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