-
Notifications
You must be signed in to change notification settings - Fork 0
/
youtube.user.js
53 lines (42 loc) · 1.49 KB
/
youtube.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
// ==UserScript==
// @id www.forocoches.com-desactivar_youtube@forocoches_electrosa
// @name FC - Desactivar YouTube
// @version 2.0
// @namespace forocoches_electrosa
// @author Electrosa
// @description
// @include http://www.forocoches.com/foro/showthread.php?*
// ==/UserScript==
"use strict";
// si en la página hay más vídeos que `minimo`, se eliminarán
var minimo = 0;
(function quitarVideosYoutube() {
if (window === window.top) {
var elems = document.getElementsByClassName("youtube-player");
if (elems.length < minimo) return;
//var elems = document.querySelectorAll("iframe[type='text/html']");
var iframes = [];
//var re = /http:\/\/widget\.smartycenter\.com\/webservice\/directYoutube\/\d{4}\/([^\/]+)\/640\/360/;
for (var i = elems.length - 1; i >= 0; i--) {
var elem = elems[i];
var parent = elem.parentNode;
// Quitar nuevo reproductor
/*if (elem.src.startsWith('http://widget.smartycenter.com')) {
var code = re.exec(elem.src)[1];
elem.src = "//www.youtube.com/embed/" + code;
}*/
iframes[i] = elem.outerHTML;
parent.removeChild(elem);
var button = document.createElement("button");
button.title = i;
button.innerHTML = "YouTube";
button.onclick = function (event) {
var button = event.target;
var parent = button.parentNode;
parent.removeChild(button);
parent.innerHTML = iframes[~~button.title];
};
parent.appendChild(button);
}
}
})();