-
Notifications
You must be signed in to change notification settings - Fork 10
/
youtube4ytzong.user.js
96 lines (91 loc) · 4.22 KB
/
youtube4ytzong.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
// ==UserScript==
// @name Youtube for ytzong
// @author ytzong
// @include https://www.youtube.com/*
// @version 2024.04.07
// @grant GM_addStyle
// @require https://code.jquery.com/jquery-3.6.0.min.js
// ==/UserScript==
const intervalId = setInterval(() => {
if (location.href.includes('watch?v=')) {
if (!$('html').hasClass('playing')) {
$('html').addClass('playing')
window.setTimeout(main, 1500);
window.setTimeout(window.scrollTo(0, 0), 2000);
}
}
else {
$('html').removeClass('playing')
}
}, 1000)
GM_addStyle(`
.playing #masthead-container.ytd-app {display:none !important; position:absolute!important;top:100vh !important}
.playing #page-manager.ytd-app{margin-top:0 !important}
.playing .html5-video-player, .playing #player-wide-container,
.playing ytd-watch-flexy[full-bleed-player] #full-bleed-container.ytd-watch-flexy,
.playing body.efyt-wide-player ytd-watch-flexy[theater]:not([fullscreen]) #player-theater-container,
.playing body.efyt-wide-player ytd-watch-flexy[theater]:not([fullscreen]) #player-wide-container,
.playing body.efyt-wide-player ytd-watch-flexy[full-bleed-player]:not([fullscreen]) #full-bleed-container.ytd-watch-flexy,
.playing body.efyt-wide-player ytd-watch-flexy[full-bleed-player]:not([fullscreen]) #player-full-bleed-container.ytd-watch-flexy,
.playing body.efyt-wide-player ytd-watch-flexy[theater] #movie_player:not(.ytp-fullscreen) video.html5-main-video,
.playing body.efyt-wide-player ytd-watch-flexy[theater] #movie_player:not(.ytp-fullscreen) .ytp-iv-video-content {height: 100vh !important;max-height:none !important}
.playing video{left:50%!important;top:0!important;margin-left:-89vh!important;width:178vh!important;height:100vh!important}');
.playing ytd-watch-flexy:not([theater]):not([fullscreen]) #primary.ytd-watch-flexy, ytd-watch-flexy:not([theater]):not([fullscreen]) #secondary.ytd-watch-flexy{padding:0!important;margin:0!important}
.playing ytd-watch-flexy:not([theater]):not([fullscreen]) #player-container-inner{padding-top:100vh!important}
.playing ytd-watch-flexy:not([theater]):not([fullscreen]) .ytp-chrome-bottom,
.playing body.efyt-wide-player ytd-watch-flexy[theater] #movie_player:not(.ytp-fullscreen) video.html5-main-video,
.playing body.efyt-wide-player ytd-watch-flexy[theater] #movie_player:not(.ytp-fullscreen) .ytp-iv-video-content{width:100%!important;left:0!important}
#progress.ytd-thumbnail-overlay-resume-playback-renderer{border-top:10px yellow solid!important}
`)
function main() {
// $('video').attr('loop', 'loop');
function rotate(deg) {
var zoom = 1;
if (deg % 360 == 90 || deg % 360 == 270) {
zoom = $(window).height() / $(window).width();
}
else {
zoom = 1;
}
$('.html5-video-container').attr('style', 'transform:rotate(' + deg + 'deg) scale(' + zoom + ', ' + zoom + ') !important;transform-origin:50% 50%;width:100% !important;height: 100% !important;left:0 !important;top:0 !important;');
document.getElementById('page-container').scrollIntoView();
}
var degree = 0;
$(document).keydown(function (e) {
//R
if (e.keyCode == 82) {
degree += 90;
rotate(degree);
}
//B
if (e.keyCode == 66) {
fullscreen();
}
var video = $('video')[0];
//P
if (e.keyCode == 80) {
if (video.paused) video.play();
else video.pause();
}
var jump = 0;
//右箭头
if (e.keyCode == 39) {
if (e.metaKey) video.volume = video.volume + 0.1;
else video.currentTime = video.currentTime + jump;
}
//左箭头
if (e.keyCode == 37) {
if (e.metaKey) video.volume = 0.1;
else video.currentTime = video.currentTime - jump;
}
var longjump = 15;
//ALT + 右箭头
if (e.altKey && e.keyCode == 39) {
video.currentTime = video.currentTime + longjump;
}
//ALT + 左箭头
if (e.altKey && e.keyCode == 37) {
video.currentTime = video.currentTime - longjump;
}
});
}