Webm Toggle Loop

Creates a button which toggles looping on or off

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Webm Toggle Loop
// @namespace   com.jeddunk.webmtoggleloop
// @author      Jeddunk
// @description Creates a button which toggles looping on or off
// @match       *://*/*.webm*
// @match       *://*/*.mp4*
// @run-at      document-start
// @version     1.0.2.1
// @grant       none
// @locale      english
// ==/UserScript==
(function () {
  var toggleValue = 'ON';
  var vids = document.getElementsByTagName('video');
  for (i = 0; i < vids.length; i++) vids[i].setAttribute('style','z-index: 9999');
  if (document.body.children.length != 1) return;
  var q = document.body.children[0];
  if (q.tagName != 'VIDEO') return;
  var o = q.cloneNode();
  var vidCont = document.createElement('div');
  vidCont.className = 'btnContainer';
  q.parentNode.appendChild(vidCont);
  var bt = document.createElement('input');
  bt.className = 'btnToggle';
  bt.type = 'button';
  bt.value = 'TOGGLE';
  bt.style.width = '100px';
  bt.addEventListener('click', function (e) {
    if (toggleValue == 'ON') {
      loopOff();
    } else {
      loopOn();
    }
  }, true);
  vidCont.appendChild(bt);
  function loopOn() {
    for (i = 0; i < vids.length; i++) {
      vids[i].setAttribute('loop', '');
      vids[i].play();
    }
    toggleValue = 'ON';
    bt.value = 'LOOP: ' + toggleValue;
  }
  function loopOff() {
    for (i = 0; i < vids.length; i++) vids[i].removeAttribute('loop');
    toggleValue = 'OFF';
    bt.value = 'LOOP: ' + toggleValue;
  }
  loopOff();
})();