Set HTML5 video volume

Script to set the volume of <video> elements to 50%.

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        Set HTML5 video volume
// @description Script to set the volume of <video> elements to 50%.
// @namespace   JeffersonScher
// @author      Jefferson "jscher2000" Scher
// @copyright   Copyright 2015 Jefferson Scher
// @license     BSD
// @include     *
// @version     0.5
// @grant       none
// ==/UserScript==

var setvol_volumepct = 0.5; // Set volume to 50%

// == == == Detect added nodes / attach MutationObserver == == ==
if (document.body){
  // Check existing videos
  setvol_checkNode(document.body);
  // Watch for changes that could be new videos
  var setvol_MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver;
  if (setvol_MutOb){
    var setvol_chgMon = new setvol_MutOb(function(mutationSet){
      mutationSet.forEach(function(mutation){
        for (var setvol_node_count=0; setvol_node_count<mutation.addedNodes.length; setvol_node_count++){
          if (mutation.addedNodes[setvol_node_count].nodeType == 1){
            setvol_checkNode(mutation.addedNodes[setvol_node_count]);
          }
        }
      });
    });
    // attach setvol_chgMon to document.body
    var setvol_opts = {childList: true, subtree: true};
    setvol_chgMon.observe(document.body, setvol_opts);
  }
}

function setvol_checkNode(el){
  if (el.nodeName == "video") var vids = [el];
  else var vids = el.querySelectorAll('video');
  if (vids.length > 0){
    for (var j=0; j<vids.length; j++){
      vids[j].volume = setvol_volumepct;
    }
  }
}