-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.user.js
140 lines (115 loc) · 3.92 KB
/
install.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// ==UserScript==
// @name JUT.SU auto play,skips opening
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Rain
// @match https://jut.su/*
// @grant none
// ==/UserScript==
(async () => {
const sleep = async msec => new Promise(r => setTimeout(r, msec));
async function waitForInit() {
while( typeof jQuery === "undefined" )
await sleep(10);
}
class Style {
constructor(text, attach = false) {
this.el = document.createElement("style");
this.add(text);
if ( attach )
this.attach();
}
add(text) {
this.el.innerHTML += "\n" + text + "\n";
}
get attached() { return document.body.contains(this.el) }
attach() { this.attached || document.body.appendChild(this.el); }
detach() { this.attached && document.body.removeChild(this.el); }
}
class ElControl {
constructor(selector) {
this.selector = selector;
}
get el() { return $(this.selector); }
get isset() { return !!this.el.length; }
get hidden() {
const el = this.el;
const bbox = el[0].getBoundingClientRect();
return el.hasClass("vjs-hidden") || !(bbox.width && bbox.height)
}
get clicked() { return this.isset && !this.hidden }
click() { this.el.click(); }
}
async function skipOpeningAndDoNext(elSkipOpening, elNext) {
while(1) {
if ( elSkipOpening.clicked ) {
elSkipOpening.click();
await sleep(3e3);
}
if ( elNext.clicked ) {
let href = getHrefNext();
if ( href ) {
if ( isFullScreen() )
href += "#fullscreen";
location.href = href;
}
return;
}
await sleep(300);
}
}
async function firstPlayStart() {
while( !elFirstPlay.clicked )
await sleep(200);
elFirstPlay.click();
}
async function firstDoFullScreen() {
styleEmuFullScreen.attach();
}
function isFullScreen() {
return document.fullscreen || styleEmuFullScreen.attached;
}
function getHrefNext() {
return $(".there_is_link_to_next_episode").attr("href");
}
const elPlayer = new ElControl("#my-player");
const elFullScreen = new ElControl(".vjs-fullscreen-control.vjs-control.vjs-button");
const elFullScreenChild = new ElControl(".vjs-fullscreen-control.vjs-control.vjs-button .vjs-icon-placeholder");
const elFirstPlay = new ElControl(".vjs-big-play-button");
const elPlay = $(".vjs-play-control.vjs-control.vjs-button.vjs-paused");
const elPauseOrPlay = $(".vjs-play-control.vjs-control.vjs-button.vjs-playing");
const elSkipOpening = new ElControl(".vjs-overlay.vjs-overlay-bottom-left.vjs-overlay-skip-intro.vjs-overlay-background")
const elNext = new ElControl(".vjs-overlay.vjs-overlay-bottom-right.vjs-overlay-skip-intro.vjs-overlay-background");
const styleEmuFullScreen = new Style(`
.main.wrapper {
z-index: auto;
}
#my-player {
position: fixed;
left: 0px;
top: 0px;
z-index: 9999;
width: 100%;
height: 100%;
padding: 0px;
margin: 0px;
}
body {
overflow: hidden;
}
`);
await waitForInit();
while(![elPlayer, elFullScreenChild].every(e => e.isset))
await sleep(100);
elFullScreenChild.el.on("click.emu, touchstart.emu", () => {
const ret = !styleEmuFullScreen.attached;
styleEmuFullScreen.detach();
elFullScreenChild.el.off("click.emu, touchstart.emu");
return ret;
});
skipOpeningAndDoNext(elSkipOpening, elNext);
firstPlayStart();
if ( /fullscreen/i.test(location.hash) )
firstDoFullScreen();
})();