-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayBackShortcuts.plugin.js
38 lines (32 loc) · 1.56 KB
/
PlayBackShortcuts.plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @name PlayBackShortcuts
* @description Adds hotkeys for changing playback speed. Shift+<(To decrease playback speed) and Shift+>(To increase playback speed).
* @updateUrl https://raw.githubusercontent.com/REVENGE977/PlayBackShortcuts/main/PlayBackShortcuts.plugin.js
* @version 1.0.0
* @author REVENGE977
*/
window.addEventListener('popstate', () => {
let playbackSpeedMenu = document.getElementById("playbackSpeedMenu")
if(!playbackSpeedMenu) return;
let scope = angular.element(playbackSpeedMenu).scope();
let availableRates = scope.rates;
document.addEventListener("keyup", (e) => {
if(e.shiftKey && e.key === '<') {
let currentRate = scope.currentRate;
let index = availableRates.indexOf(currentRate);
if((availableRates.length - 1) != index) {
let newPlaybackSpeed = scope.rates[index + 1];
console.log(`[ PlayBackShortcuts ] Decreasing playback speed to ${newPlaybackSpeed}`)
scope.changeSpeed(newPlaybackSpeed);
}
} else if(e.shiftKey && e.key === '>') {
let currentRate = scope.currentRate;
let index = availableRates.indexOf(currentRate);
if(availableRates[0] != currentRate) {
let newPlaybackSpeed = scope.rates[index - 1];
console.log(`[ PlayBackShortcuts ] Increasing playback speed to ${newPlaybackSpeed}`);
scope.changeSpeed(scope.rates[index - 1]);
}
}
})
});