Loop video files

Sets the loop attribute when viewing video files in their own window/tab.

  1. // ==UserScript==
  2. // @name Loop video files
  3. // @description Sets the loop attribute when viewing video files in their own window/tab.
  4. // @namespace var512
  5. // @author var512
  6. // @version 1.1.0
  7. // @supportURL https://gitlab.com/var512
  8. // @supportURL https://github.com/var512
  9. // @include /\.(m4v|mp4|ogv|webm)$/
  10. // @include /^data:video\//
  11. // @license MIT
  12. // @noframes
  13. // @grant none
  14. // @run-at document-start
  15. // ==/UserScript==
  16.  
  17. (() => {
  18. 'use strict';
  19.  
  20. const elements = document.getElementsByTagName('video');
  21.  
  22. if (typeof elements[0] !== 'undefined') {
  23. elements[0].setAttribute('loop', 'true');
  24. }
  25. })();