-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathYoutubeAudio.user.js
More file actions
77 lines (69 loc) · 2.78 KB
/
YoutubeAudio.user.js
File metadata and controls
77 lines (69 loc) · 2.78 KB
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
// ==UserScript==
// @name YoutubeAudio
// @namespace http://sandroalvares.com.br
// @version v2.06
// @description Youtube Audio without video
// @author KingRider
// @match http://*.youtube.com/watch*
// @match https://*.youtube.com/watch*
// @match http://*.youtube.com/c/*
// @match https://*.youtube.com/c/*
// @require http://code.jquery.com/jquery-1.9.1.min.js
// @updateURL https://github.com/KingRider/userscripts/raw/master/YoutubeAudio.user.js
// @downloadURL https://github.com/KingRider/userscripts/raw/master/YoutubeAudio.user.js
// ==/UserScript==
(function() {
//(window.getComputedStyle(savideo, null).getPropertyValue('visibility') == 'visible')
//-- LOOP
var removervideo = setInterval(function() { satela(); clearInterval(removervideo); }, 1000);
//-- KEY Q
$(window).bind('keypress', function(e) {
var code = e.keyCode || e.which;
var control = e.ctrlKey || e.metaKey;
if (code == 17 && control) { satela(); }
});
//-- HIDE ADS & VIDEO
function satela() {
sahide('div[class*="player-api"]'); // Hidden video
sahide('div[id*="theater-background"]'); // Hidden background from video
sahide('div[id*="sidebar-contents"]'); // Hidden Sidebar near playlist
/*
sahide('div[class^="player"]');
//sahide('#movie_player'); // not exist and before version exist
sahide('div[id*="related"]');
//sahide('div[id^="placeholder-player"]', 1);
*/
}
//-- FUNC HIDDEN
function sahide(elem, tipo = 0) {
console.log($('#watch-header').position());
var satipo = '';
var saelem = document.querySelectorAll(elem);
for (sah=0; sah < saelem.length; sah++) {
if (saelem[sah]) {
if (tipo === 0) {
if (saelem[sah].style.visibility != 'hidden') {
saelem[sah].style.visibility = 'hidden';
satipo = 'hidden [ON]';
} else {
saelem[sah].style.visibility = '';
satipo = 'hidden [OFF]';
}
} else {
if (saelem[sah].style.display != 'none') {
saelem[sah].style.display = 'none';
satipo = 'none [ON]';
} else {
saelem[sah].style.display = '';
satipo = 'none [OFF]';
}
}
console.log(elem + ' / ' + tipo + ' / ' + satipo);
} else {
console.log("Erro: " + elem);
}
}
}
// Auto-Scroll in Title
window.scrollTo(0,document.getElementById('watch-header').offsetParent.offsetTop);
})();