-
-
Notifications
You must be signed in to change notification settings - Fork 94
/
tipjar.html
204 lines (189 loc) · 7.29 KB
/
tipjar.html
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Enhanced Tip Jar Overlay - Social Stream Ninja</title>
<link rel="icon" href="./icons/favicon.ico" />
<link rel="preload" href="./thirdparty/NotoColorEmoji.ttf" as="font" type="font/ttf" crossorigin="anonymous">
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap');
body {
font-family: 'Montserrat', Arial, sans-serif;
background-color: #0000;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
overflow: hidden;
}
#tip-jar {
width: 200px;
height: 300px;
background-color: rgba(255, 255, 255, 0.5);
border: 4px solid #8B4513;
border-radius: 20px 20px 100px 100px;
position: relative;
overflow: hidden;
box-shadow: 0 0 20px rgba(0,0,0,0.2);
}
#tip-fill {
width: 100%;
background-color: rgba(255, 215, 0, 0.6);
position: absolute;
bottom: 0;
transition: height 0.5s ease-in-out;
}
#tip-text {
position: absolute;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
font-weight: bold;
color: #000;
text-shadow: 1px 1px 2px white;
z-index: 10;
}
.coin {
width: 30px;
height: 30px;
background-color: gold;
border: 2px solid #B8860B;
border-radius: 50%;
position: absolute;
animation: fall 2s ease-in;
z-index: 5;
}
.bill {
width: 50px;
height: 20px;
background-color: #90EE90;
border: 1px solid #006400;
position: absolute;
animation: fall 2.5s ease-in;
z-index: 5;
}
@keyframes fall {
0% { transform: translateY(-100vh) rotate(0deg); }
70% { transform: translateY(calc(100% - 50px)) rotate(180deg); }
85% { transform: translateY(calc(100% - 25px)) rotate(360deg); }
100% { transform: translateY(100%) rotate(360deg); }
}
#notification {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
background-color: rgba(0, 0, 0, 0.7);
color: white;
padding: 10px 20px;
border-radius: 5px;
display: none;
}
</style>
</head>
<body>
<div id="tip-jar">
<div id="tip-fill"></div>
<div id="tip-text">$0 / $250</div>
</div>
<div id="notification"></div>
<script>
const urlParams = new URLSearchParams(window.location.search);
let totalTips = 0;
const maxTips = 250;
const tipJar = document.getElementById('tip-jar');
const tipFill = document.getElementById('tip-fill');
const tipText = document.getElementById('tip-text');
const notification = document.getElementById('notification');
function updateTipJar() {
const fillPercentage = (totalTips / maxTips) * 100;
tipFill.style.height = `${Math.min(fillPercentage, 100)}%`;
tipText.textContent = `$${totalTips.toFixed(2)} / $${maxTips}`;
}
function showNotification(message) {
notification.textContent = message;
notification.style.display = 'block';
setTimeout(() => {
notification.style.display = 'none';
}, 3000);
}
function addCoin() {
const coin = document.createElement('div');
coin.className = 'coin';
coin.style.left = `${Math.random() * 170}px`;
tipJar.appendChild(coin);
setTimeout(() => {
tipJar.removeChild(coin);
}, 2000);
}
function addBill() {
const bill = document.createElement('div');
bill.className = 'bill';
bill.style.left = `${Math.random() * 150}px`;
bill.style.transform = `rotate(${Math.random() * 360}deg)`;
tipJar.appendChild(bill);
setTimeout(() => {
tipJar.removeChild(bill);
}, 2500);
}
function processTip(amount, currency, donator) {
let tipValue = 0;
if (['bits','bit','cheer','gold',"rose","roses"].includes(currency.toLowerCase())) {
tipValue = amount / 100;
} else if (currency.toLowerCase() === 'usd') {
tipValue = amount;
} else {
// For simplicity, treat all other currencies as 1:1 with USD
tipValue = amount;
}
totalTips += tipValue;
updateTipJar();
showNotification(`${donator} tipped ${amount} ${currency}!`);
// Add coins and bills based on the tip value
const coinCount = Math.floor(tipValue);
const billCount = Math.floor(tipValue / 5);
for (let i = 0; i < coinCount; i++) {
setTimeout(addCoin, i * 300);
}
for (let i = 0; i < billCount; i++) {
setTimeout(addBill, i * 400 + 200);
}
}
function processData(data) {
console.log(data);
if (data.content) {
data = data.content;
}
if (data.donation || data.hasDonation) {
const donationString = data.donation || data.hasDonation;
const [amount, currency] = donationString.split(' ');
processTip(parseFloat(amount), currency, data.chatname);
}
}
// IFRAME setup for Social Stream Ninja
const iframe = document.createElement("iframe");
const filename = "dock";
iframe.src = "https://vdo.socialstream.ninja/?ln&salt=vdo.ninja¬mobile¬mobile&password=false&solo&view=" + urlParams.get('session') + "&novideo&noaudio&label="+filename+"&cleanoutput&room=" + urlParams.get('session');
iframe.style.width = "0px";
iframe.style.height = "0px";
iframe.style.position = "fixed";
iframe.style.left = "-100px";
iframe.style.top = "-100px";
iframe.id = "frame1";
document.body.appendChild(iframe);
const eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
const eventer = window[eventMethod];
const messageEvent = eventMethod === "attachEvent" ? "onmessage" : "message";
eventer(messageEvent, function (e) {
if (e.source != iframe.contentWindow) return;
if ("dataReceived" in e.data) {
if ("overlayNinja" in e.data.dataReceived) {
processData(e.data.dataReceived.overlayNinja);
}
}
});
</script>
</body>
</html>