-
Notifications
You must be signed in to change notification settings - Fork 1
/
DCUniverse.Skips.user.js
61 lines (61 loc) · 2.25 KB
/
DCUniverse.Skips.user.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// ==UserScript==
// @name DC Universe Skips
// @namespace https://github.com/N3Cr0Cr0W/userscripts
// @version 0.1
// @description Skips Recap and Intros. Allows Saved PlaybackRate.
// @author N3Cr0Cr0W
// @downloadURL https://raw.githubusercontent.com/N3Cr0Cr0W/userscripts/master/DCUniverse.Skips.user.js
// @license GNU AGPLv3: https://www.gnu.org/licenses/agpl-3.0.en.html
// @match https://www.dcuniverse.com/videos/watch/*
// @grant GM_log
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_registerMenuCommand
// ==/UserScript==
(function(){
'use strict';
function increasePlaybackRate(){
var playbackRate=GM_getValue('playbackRate',1);
GM_setValue('playbackRate',playbackRate+.25);
}
function decreasePlaybackRate(){
var playbackRate=GM_getValue('playbackRate',1);
GM_setValue('playbackRate',playbackRate-.25);
}
function skipsAndStuff(){
var playbackRate=GM_getValue('playbackRate',1);
var recap=document.querySelector('.vjs-overlay.vjs-overlay-bottom-right.recap.vjs-overlay-background:not(.vjs-hidden)>div#skiprecao.skiprecap');
var intro=document.querySelector('.vjs-overlay.vjs-overlay-bottom-right.intro.vjs-overlay-background:not(.vjs-hidden)>div#skipintro.skipintro');
var next=document.querySelector('div.vjs-overlay.vjs-overlay-bottom.credits.vjs-overlay-background:not(.vjs-hidden)>div.nextcontent>div.inner>div.thumbnail>div.thumbnail-image>a>div.image-overlay>div.image-button');
var video=document.evaluate('//video',document,null,9,null).singleNodeValue;
if(recap){
handleButtons(recap);
GM_log("Skipped Recap.");
}
if(intro){
handleButtons(intro);
GM_log("Skipped Intro.");
}
if(next){
handleButtons(next);
GM_log("Next Episode.");
}
if(video&&video.playbackRate!=playbackRate){
video.playbackRate=playbackRate;
GM_log("Set Playback Rate to "+playbackRate+"X.");
}
}
function handleButtons(button){
if(button&&!button.clicked){
button.clicked=2;
button.click();
}else if(button&&button.clicked){
button.clicked-=1;
}else if(button){
button.clicked=0;
}
}
var timerID=setInterval(skipsAndStuff,800);
GM_registerMenuCommand('Faster',increasePlaybackRate,'F');
GM_registerMenuCommand('Slower',decreasePlaybackRate,'S');
})();