-
-
Notifications
You must be signed in to change notification settings - Fork 94
/
input.html
222 lines (191 loc) · 7.05 KB
/
input.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta charset="UTF-8">
<title>Social Stream - Chat Input Bar</title>
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-family: Arial, sans-serif;
background-color: #2F3136;
width:100%;
}
#chatInput_parent {
position: fixed;
bottom: 5px;
width: 100%;
max-width: calc(100% - 20px);
padding: 5px;
display: flex;
justify-content: center;
background-color: #6f6f6f;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
border-radius: 5px;
}
#chatInput {
width: 100%;
max-width: 100%;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
transition: all 0.3s ease;
font-size: 16px;
}
#chatInput:focus {
width: 100%;
border-color: #007BFF;
}
button {
padding: 10px 15px;
margin-left: 5px;
border: none;
border-radius: 5px;
background-color: #007BFF;
color: white;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
#chatInput_parent.hidden {
display: none;
}
.electronDraggable {
-webkit-app-region: drag;
}
body > div {
-webkit-app-region: no-drag;
}
.hidden {
display:none;
opacity:hidden;
width:0;
height:0;
}
</style>
</head>
<body class="electronDraggable">
<div id="loading">Loading...</div>
<div id="chatInput_parent">
<input id="chatInput" type="text" placeholder="Send message..." />
<button id="chatInputButton">Send</button>
</div>
<script>
window.onerror = function (errorMsg, url, lineNumber) {
console.error(errorMsg, lineNumber);
return false;
};
function getById(id) {
return document.getElementById(id);
}
function sendMessage(event) {
event.preventDefault();
const input = getById("chatInput");
if (input.value) {
respondP2P(input.value);
input.value = "";
}
}
getById("chatInputButton").addEventListener("click", sendMessage);
getById("chatInput").addEventListener("keyup", function (event) {
if (event.keyCode === 13) {
sendMessage(event);
}
});
const urlParams = new URLSearchParams(window.location.search);
const roomID = urlParams.get("session") || "test";
const password = urlParams.get("password") || "false";
let iframes = [];
let connectedPeers = {};
function RecvDataWindow(room) {
const iframe = document.createElement("iframe");
iframe.src = `https://vdo.socialstream.ninja/?ln&salt=vdo.ninja&password=${password}&push¬mobile&label=chatinput&vd=0&ad=0&novideo&noaudio&autostart&cleanoutput&room=${room}`;
iframe.style.width = "0px";
iframe.style.height = "0px";
iframe.style.position = "fixed";
iframe.style.left = "-100px";
iframe.style.top = "-100px";
iframe.id = `frame_${room}`;
iframe.allow = "midi;geolocation;microphone;";
iframes.push(iframe);
document.body.appendChild(iframe);
window.addEventListener("message", function (e) {
if (e.source !== iframe.contentWindow) return;
if ("action" in e.data && e.data.UUID && "value" in e.data && !e.data.value && e.data.action === "push-connection") {
delete connectedPeers[e.data.UUID];
} else if ("action" in e.data && e.data.UUID && e.data.value && e.data.action === "push-connection-info") {
connectedPeers[e.data.UUID] = e.data.value.label;
if (connectedPeers[e.data.UUID] === "SocialStream"){
document.getElementById("loading").classList.add("hidden");
}
} else if ("action" in e.data && e.data.UUID && e.data.value && e.data.action === "view-connection-info") {
connectedPeers[e.data.UUID] = e.data.value.label;
if (connectedPeers[e.data.UUID] === "SocialStream"){
document.getElementById("loading").classList.add("hidden");
}
} else if ("action" in e.data && e.data.UUID && "value" in e.data && !e.data.value && e.data.action === "view-connection") {
delete connectedPeers[e.data.UUID];
} else if ("action" in e.data && e.data.UUID && "label" in e.data) {
connectedPeers[e.data.UUID] = e.data.label;
if (connectedPeers[e.data.UUID] === "SocialStream"){
document.getElementById("loading").classList.add("hidden");
}
}
});
}
roomID.split(",").forEach(room => {
RecvDataWindow(room.trim());
});
function send2Extension(data, uid = null) {
iframes.forEach(iframe => {
if (!uid) {
Object.keys(connectedPeers).forEach(UUID => {
if (connectedPeers[UUID] === "SocialStream") {
iframe.contentWindow.postMessage({ sendData: { overlayNinja: data }, type: "rpcs", UUID }, "*");
}
});
} else {
if (connectedPeers[uid] === "SocialStream") {
iframe.contentWindow.postMessage({ sendData: { overlayNinja: data }, type: "rpcs", UUID: uid }, "*");
}
}
});
}
const socketserverURL = urlParams.get("server");
let socketserver = null;
function connectWebSocket() {
if (socketserverURL) {
socketserver = new WebSocket(socketserverURL);
socketserver.onopen = function () {
document.getElementById("loading").classList.add("hidden");
console.log("WebSocket connected");
};
socketserver.onclose = function (e) {
console.log("WebSocket disconnected. Attempting to reconnect...");
setTimeout(connectWebSocket, 5000);
};
socketserver.onerror = function (err) {
console.error("WebSocket error:", err);
socketserver.close();
};
}
}
connectWebSocket();
function respondP2P(data) {
var msg = {};
msg.response = data.trim();
if (socketserver && socketserver.readyState === WebSocket.OPEN) {
socketserver.send(JSON.stringify(msg));
} else {
send2Extension(msg);
}
}
</script>
</body>
</html>