-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacepunch-twitch-drops.user.js
119 lines (102 loc) · 3.28 KB
/
facepunch-twitch-drops.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
// ==UserScript==
// @name Facepunch Twitch Drops
// @namespace http://tampermonkey.net/
// @version 0.2
// @author Horodep
// @namespace https://github.com/Horodep/Custom-UserScripts/
// @updateURL https://raw.githubusercontent.com/Horodep/Custom-UserScripts/main/facepunch-twitch-drops.user.js
// @supportURL https://github.com/Horodep/Custom-UserScripts/
// @match https://twitch.facepunch.com/
// @icon https://twitch.facepunch.com/favicon.png
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
var drops = $('.drops-container > .drop-box');
Array.from(drops).forEach(function callback(val) {
try{
var video = $(val).find('.drop-box-body > video > source');
if ($(video).length == 0) return;
var uri = $(video)[0].src;
var id = uri.replace("https://files.facepunch.com/", '').replace(".mp4", '');
console.log(id);
var value = GM_getValue(id) ?? false;
if (value) $(val).css ( { opacity: "0.1" } );
var wrapper = $('<div>', { class: "customcheck" });
$(val).append(wrapper);
var round = $('<div>', { class: "round" });
$(wrapper).append(round);
$(round).append($('<input>', { type: "checkbox", id: id, checked: value, click: onClick }));
$(round).append($('<label>', { for: id }));
}catch(e){
console.log(e);
console.log($(val));
}
});
function onClick(event) {
var target = event.target;
GM_setValue(target.id, target.checked);
var box = $(target)[0].parentElement.parentElement.parentElement;
$(box).css ( { opacity: target.checked ? "0.1" : "1" } );
}
GM_addStyle ( `
@media screen and (min-width: 1204px) {
.container {
max-width: 100%;
}
}
@media screen and (min-width: 1024px) {
.container {
max-width: 100%;
}
}
.container {
max-width: 100%;
}
.section.drops .drops-container.is-row-3 .drop-box {
flex: 0 0 calc(20% - 50px);
}
.customcheck .round {
position: absolute;
right: 10px;
bottom: 10px;
}
.customcheck .round label {
background-color: #fff;
border: 1px solid #ccc;
border-radius: 50%;
cursor: pointer;
height: 56px;
width: 56px;
display: block;
}
.customcheck .round label:after {
border: 4px solid #fff;
border-top: none;
border-right: none;
content: "";
height: 12px;
left: 16px;
opacity: 0;
position: absolute;
top: 19px;
transform: rotate(-45deg);
width: 24px;
}
.customcheck .round input[type="checkbox"] {
visibility: hidden;
display: none;
opacity: 0;
}
.customcheck .round input[type="checkbox"]:checked + label {
background-color: #66bb6a;
border-color: #66bb6a;
}
.customcheck .round input[type="checkbox"]:checked + label:after {
opacity: 1;
}
` );
})();