Youtube Video Controls Manager

Manages the video controls overlay on a youtube video, to prevent it blocking 30-40 pixels on the bottom of the video

当前为 2015-03-29 提交的版本,查看 最新版本

// ==UserScript==
// @name         Youtube Video Controls Manager
// @namespace    http://your.homepage/
// @version      0.01
// @description  Manages the video controls overlay on a youtube video, to prevent it blocking 30-40 pixels on the bottom of the video
// @include      http*://www.youtube.com/watch?v=*
// @author       D.Slee
// @match        https://www.youtube.com/watch?v=rXj3hUB7BH8
// @grant        none

// ==/UserScript==
var body = document.getElementById("body");
var playerAPI = document.getElementById("player-api")
var progBar = document.getElementsByClassName("html5-video-controls")[0];  //Progress Bar
var scrubBn = document.getElementsByClassName("html5-scrubber-button")[0]; //Circle Button (on progress bar)
var vidCont = document.getElementsByClassName("html5-player-chrome")[0];   //Video controls
var elements = [scrubBn, vidCont];
var fadeState = true;
var fadeOutInterval = setTimeout(fadeOut, 0);                              //Interval used to fade out when inactive

//Feel free to edit these parameters
var progBarHide = false;
var timeOut = 1000;

//progBar handling
progBar.style.setProperty("opacity", 1, "important")
if (progBarHide == true){
    elements.push(progBar)
}

//Initiate
fadeOut()
mainProgram()

function mainProgram(){
    playerAPI.addEventListener("mousemove", handleMouseOver, false)
    playerAPI.addEventListener("mouseout", handleMouseOut, false)
    body.addEventListener("keydown", handleKeyDown, false)
}

function handleMouseOver(){
    fadeIn()
}

function handleMouseOut(){
    fadeOut()
}

function handleKeyDown(e){
    if (e.keyCode == 87 && fadeState == false){
        fadeIn();
        setTimeout(fadeOut, timeOut)
    }    
}

function fadeIn(){
    playerAPI.style.cursor = "default"
    progBar.style.bottom = "0px"
    clearTimeout(fadeOutInterval)
    fadeOutInterval = setTimeout(fadeOut, timeOut)
    fadeState = true
    for (i = 0; i<elements.length; i++){
        elements[i].style.display = "block"
    }
}

function fadeOut(){
    playerAPI.style.cursor = "none"
    progBar.style.bottom = "-5px"
    for (i = 0; i<elements.length; i++){
        elements[i].style.display = "none"
    }
    fadeState = false
}
长期地址
遇到问题?请前往 GitHub 提 Issues。