Tronix117

Lelombrik // Enhance vidéo

Nov 15th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name     Lelombrik
  3. // @version  0.1.0
  4. // @grant    none
  5. // @include  https://lelombrik.net/*
  6. // ==/UserScript==
  7.  
  8. (function() {
  9.   'use strict';
  10.  
  11.   function enhanceVideo(el) {
  12.     el.setAttribute('controls', '');
  13.     el.removeAttribute('loop');
  14.   }
  15.  
  16.   const videoElements = document.getElementsByTagName('video');
  17.   for (const el of videoElements) {
  18.     enhanceVideo(el);
  19.   }
  20.  
  21.   const observer = new MutationObserver(mutations => {
  22.     for (const mutation of mutations) {
  23.       for (const addedNode of mutation.addedNodes) {
  24.         if (addedNode.nodeType === 1 && addedNode.tagName === 'VIDEO') {
  25.           enhanceVideo(addedNode)
  26.         }
  27.       }
  28.     }
  29.   });
  30.  
  31.   observer.observe(document.body, { childList: true, subtree: true });
  32. })();
Add Comment
Please, Sign In to add comment