|
// ==UserScript== |
|
// @name openrec_add_seek_button |
|
// @namespace http://tampermonkey.net/ |
|
// @version 0.3.2 |
|
// @description OPENRECのコントロールバーにシークボタンを追加します。また、いくつかのショートカットキーも追加します。 |
|
// @author cpthgli |
|
// @match https://www.openrec.tv/live/* |
|
// @grant none |
|
// ==/UserScript== |
|
|
|
(function () { |
|
'use strict'; |
|
|
|
function add_seek(element, value) { |
|
element.setAttribute("onclick", "getElementById('openrec-video-player_Viblast_api').currentTime+=" + value.toString()); |
|
} |
|
|
|
function add_style(element) { |
|
element.setAttribute("onmouseover", "this.style.textShadow='0em 0em 1em white'"); |
|
element.setAttribute("onmouseout", "this.style.textShadow='none'"); |
|
element.style.cursor = "pointer"; |
|
} |
|
|
|
var pre1m = document.createElement("button"); |
|
var pre10s = document.createElement("button"); |
|
var pre5s = document.createElement("button"); |
|
var nxt5s = document.createElement("button"); |
|
var nxt10s = document.createElement("button"); |
|
var nxt1m = document.createElement("button"); |
|
var elements = [pre1m, pre10s, pre5s, nxt5s, nxt10s, nxt1m]; |
|
var names = ["-1m", "-10s", "-5s", "+5s", "+10s", "+1m"]; |
|
var values = [-60, -10, -5, 5, 10, 60]; |
|
var bar = document.getElementsByClassName("vjs-control-bar")[0]; |
|
var volume = document.getElementsByClassName("vjs-volume-menu-button")[0]; |
|
|
|
for (var i in elements) { |
|
elements[i].textContent = names[i]; |
|
add_seek(elements[i], values[i]); |
|
add_style(elements[i]); |
|
bar.insertBefore(elements[i], volume); |
|
} |
|
|
|
var video = document.getElementById('openrec-video-player_Viblast_api'); |
|
|
|
window.onkeydown = function (e) { |
|
if (!e) e = window.event; |
|
|
|
var key_code = e.keyCode; |
|
var shift_key = e.shiftKey; |
|
var ctrl_key = e.ctrlKey; |
|
var alt_key = e.altKey; |
|
|
|
var v; |
|
switch (key_code) { |
|
case 32: // space |
|
if (video.paused) { |
|
video.play(); |
|
} else { |
|
video.pause(); |
|
} |
|
return false; |
|
case 37: // ← |
|
if (shift_key && !ctrl_key && !alt_key) { |
|
v = values[0]; |
|
console.log(v); |
|
video.currentTime += v; |
|
} else if (!shift_key && ctrl_key && !alt_key) { |
|
v = values[parseInt(values.length / 4)]; |
|
console.log(v); |
|
video.currentTime += v; |
|
} else if (!shift_key && !ctrl_key && alt_key) { |
|
v = values[parseInt(values.length / 2 - 1)]; |
|
console.log(v); |
|
video.currentTime += v; |
|
} else { |
|
v = values[parseInt(values.length / 4)]; |
|
console.log(v); |
|
video.currentTime += v; |
|
} |
|
return false; |
|
case 39: // → |
|
if (shift_key && !ctrl_key && !alt_key) { |
|
v = values[values.length - 1]; |
|
console.log(v); |
|
video.currentTime += v; |
|
} else if (!shift_key && ctrl_key && !alt_key) { |
|
v = values[parseInt(values.length / 2 + Math.floor(values.length / 4))]; |
|
console.log(v); |
|
video.currentTime += v; |
|
} else if (!shift_key && !ctrl_key && alt_key) { |
|
v = values[parseInt(values.length / 2)]; |
|
console.log(v); |
|
video.currentTime += v; |
|
} else { |
|
v = values[parseInt(values.length / 2 + Math.floor(values.length / 4))]; |
|
console.log(v); |
|
video.currentTime += v; |
|
} |
|
return false; |
|
default: |
|
console.log(key_code); |
|
} |
|
}; |
|
})(); |