NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==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 // @grant none // @locale english // @updateURL https://openuserjs.org/meta/Jeddunk/Webm_Toggle_Loop.meta.js // ==/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(); })();