kqtobserver / VolumeOhOne

// ==UserScript==
// @name        VolumeOhOne
// @match       *://kpop.re/*/*
// @version     1.0
// @author      kqtobserver
// @license     MIT
// @description Sets video volume to 0.1 on kchan.
// ==/UserScript==

function volumeohone() {
  var obs = new MutationObserver(function (mutations) {
    for (var i = 0; i < mutations.length; ++i) {
      for (var j = 0; j < mutations[i].addedNodes.length; ++j) {
        if (mutations[i].addedNodes[j].className.indexOf("popup_video") !== -1) {
          var video =
            mutations[i].addedNodes[j].querySelector(".popup-video-item")
          if (video) {
            video.volume = 0.1
          }
        }
      }
    }
  })
  
  obs.observe(document.querySelector(".popup-container-inner"), {
    childList: true,
  })
}

window.addEventListener('site_fully_loaded', function() {
  volumeohone()
})