Webm Toggle Loop

Creates a button which toggles looping on or off

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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();
})();