HIDive Fullscreen & Mouse volume control

Fullscreen & Mouse volume control

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        HIDive Fullscreen & Mouse volume control
// @namespace    https://greasyfork.org/en/users/807108-jeremy-r
// @version      2.0
// @description  Fullscreen & Mouse volume control
// @author       JRem
// @require      https://cdn.jsdelivr.net/gh/mlcheng/js-toast@ebd3c889a1abaad615712485ce864d92aab4c7c0/toast.min.js
// @match        https://www.hidive.com/stream/*
// @grant        GM_addStyle
// @grant        GM.xmlHttpRequest
// @license MIT
// ==/UserScript==

// Fullscreen Video Code
window.onload = function(){
    setTimeout(function () {
        var css = '#rmpPlayer {width: calc(100vw) !important;height: calc(95vh) !important;}';
            css += '.container-fluid {padding: 0 0 0 0;margin: 0 0 0 0;max-width:calc(100vw) !important;}';
        GM_addStyle(css);
    }, 5000);
    iqwerty.toast.toast('Fullscreen added', options);
};


// Toast Vars
const options = {
      settings: {
        duration: 3000,
      },
      style: {
        main: {
          background: "black",
          color: "white",
          width: "auto",
          'max-width': '10%',
        }
      }
};

const volopts = {
      settings: {
        duration: 500,
      },
      style: {
        main: {
          background: "black",
          color: "white",
          width: "auto",
          'max-width': '10%',
        }
      }
};

// Volume Control via mouse scroll
// 1 Scroll = 5%
var stepAmount = 5;

function volChange(e){
  e.preventDefault()
  var video = document.querySelector('video')
  var curVol = video.volume;
  var direction = e.deltaY < 0;
  var actualChange = stepAmount / 100;
  if (direction) curVol += actualChange;
  else curVol -= actualChange;
  if (curVol > 1) curVol = 1;
  else if (curVol < 0) curVol = 0;
  video.volume = curVol;

  iqwerty.toast.toast(Math.floor(100 * video.volume) +"%", volopts);
}

document.getElementById("rmpPlayer").addEventListener("wheel", volChange);