HIDive Fullscreen & Mouse volume control

Fullscreen & Mouse volume control

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);