-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathremoveGfy.js
69 lines (66 loc) · 3 KB
/
removeGfy.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
//new version of replacing the document body that should work
//now uses window.onload to actually wait for the gfycat js to finish before obliterating the site.
window.addEventListener ("load", gfyclean(), false)
function gfyclean() {
if (window.location.href != "https://gfycat.com/" && window.location.href != "gfycat.com"){
try {
replacegfy();
}
catch (TypeError) {
//failed the first time, so keep retrying until the site is loaded.
//used to be an elegant solution here but it wasn't working on mobile :(
let interval = 400;
setTimeout(function() {
try {
replacegfy();
}
//next just keep going for many times
catch (TypeError) {
setTimeout(function() {
try {
replacegfy();
}
catch (TypeError) {
setTimeout(function() {
try {
replacegfy();
}
catch (TypeError) {
setTimeout(function() {
try {
replacegfy();
}
catch (TypeError) {
setTimeout(function() {
try {
replacegfy();
}
catch (TypeError) {
setTimeout(function() {
try {
replacegfy();
} catch (TypeError) { //just give up lol
document.body.style.visibility = "visible";
}
}, interval);
}
}, interval);
}
}, interval);
}
}, interval);
}
}, interval);
}
}, interval);
}
} else {
document.body.style.visibility = "visible";
}
};
function replacegfy() {
var vid;
vid = document.getElementsByClassName("video media")[0];
document.body.innerHTML = "<div class=\"container\"><video controls loop muted autoplay>" + vid.innerHTML + "</video></div>";
document.body.style.visibility = "visible";
}