Skip to content

Commit 20c815e

Browse files
authored
Add files via upload
more security patches
1 parent 83c0ac7 commit 20c815e

File tree

6 files changed

+383
-170
lines changed

6 files changed

+383
-170
lines changed

examples/chat.html

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<html>
2+
<head>
3+
<meta charset="utf8" />
4+
<meta name="viewport" content="width=device-width, initial-scale=1" />
5+
<title>OBSN Chat Overlay</title>
6+
<style>
7+
8+
@font-face {
9+
font-family: 'Cousine';
10+
src: url('fonts/Cousine-Bold.ttf') format('truetype');
11+
}
12+
13+
body {
14+
margin:0;
15+
padding:0 10px;
16+
height:100%;
17+
border: 0;
18+
display: flex;
19+
flex-direction: column-reverse;
20+
position:absolute;
21+
bottom:0;
22+
overflow:hidden;
23+
max-width:100%;
24+
}
25+
26+
div {
27+
margin:0;
28+
background-color: black;
29+
padding: 8px 8px 0px 8px;
30+
color: white;
31+
font-family: Cousine, monospace;
32+
font-size: 3.2em;
33+
line-height: 1.1em;
34+
letter-spacing: 0.0em;
35+
text-transform: uppercase;
36+
text-shadow: 0.05em 0.05em 0px rgba(0,0,0,1);
37+
max-width:100%;
38+
word-wrap: break-word;
39+
overflow-wrap: break-word;
40+
word-break: break-all;
41+
hyphens: auto;
42+
display:inline-block;
43+
}
44+
45+
46+
47+
a {
48+
color:white;
49+
font-size:1.2em;
50+
text-transform: none;
51+
word-wrap: break-word;
52+
overflow-wrap: break-word;
53+
word-wrap: break-word;
54+
word-break: break-all;
55+
hyphens: auto;
56+
}
57+
</style>
58+
<script>
59+
60+
61+
(function (w) {
62+
w.URLSearchParams =
63+
w.URLSearchParams ||
64+
function (searchString) {
65+
var self = this;
66+
self.searchString = searchString;
67+
self.get = function (name) {
68+
var results = new RegExp("[\?&]" + name + "=([^&#]*)").exec(
69+
self.searchString
70+
);
71+
if (results == null) {
72+
return null;
73+
} else {
74+
return decodeURI(results[1]) || 0;
75+
}
76+
};
77+
};
78+
})(window);
79+
var urlParams = new URLSearchParams(window.location.search);
80+
81+
82+
function loadIframe() {
83+
84+
var iframe = document.createElement("iframe");
85+
86+
var view= "";
87+
if (urlParams.has("view")) {
88+
view = "&view="+(urlParams.get("view") || "");
89+
}
90+
var room="";
91+
if (urlParams.has("room")) {
92+
room = "&room="+urlParams.get("room");
93+
}
94+
95+
var password="";
96+
if (urlParams.has("password")) {
97+
password = "&password="+urlParams.get("password");
98+
}
99+
100+
iframe.allow = "autoplay";
101+
var srcString = "./?novideo&noaudio&label=chatOverlay&scene"+room+view+password;
102+
103+
iframe.src = srcString;
104+
iframe.style.width="0";
105+
iframe.style.height="0";
106+
iframe.style.border="0";
107+
108+
document.body.appendChild(iframe);
109+
110+
//////////// LISTEN FOR EVENTS
111+
112+
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
113+
var eventer = window[eventMethod];
114+
var messageEvent = eventMethod === "attachEvent" ? "onmessage" : "message";
115+
116+
117+
/// If you have a routing system setup, you could have just one global listener for all iframes instead.
118+
119+
eventer(messageEvent, function (e) {
120+
if (e.source != iframe.contentWindow){return} // reject messages send from other iframes
121+
122+
console.log(e);
123+
if ("gotChat" in e.data){
124+
logData(e.data.gotChat.label,e.data.gotChat.msg);
125+
}
126+
});
127+
}
128+
129+
function printValues(obj) {
130+
var out = "";
131+
for (var key in obj) {
132+
if (typeof obj[key] === "object") {
133+
out += "<br />";
134+
out += printValues(obj[key]);
135+
} else {
136+
if (key.startsWith("_")) {
137+
} else {
138+
out += "<b>" + key + "</b>: " + obj[key] + "<br />";
139+
}
140+
}
141+
}
142+
return out;
143+
}
144+
145+
function logData(type, data) {
146+
var span = document.createElement('span');
147+
var entry = document.createElement('div');
148+
if (type){
149+
var typeElement = document.createElement('i');
150+
typeElement.textContent = type.replace(/_/g, ' ');
151+
entry.appendChild(typeElement);
152+
entry.appendChild(document.createTextNode(" "));
153+
}
154+
var message = document.createElement('span');
155+
message.textContent = data;
156+
entry.appendChild(message);
157+
span.appendChild(entry);
158+
document.body.prepend(span);
159+
}
160+
</script>
161+
</head>
162+
<body onload="loadIframe();">
163+
</body>
164+
</html>

examples/chatoverlay.html

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,21 @@ <h2>Chat Overlay Configuration</h2>
166166
window.location.href = newUrl;
167167
}
168168

169-
function logData(type, data) {
170-
var entry = document.createElement('div');
171-
if (type) {
172-
type = "<i>" + type.replace(/_/g, ' ') + "</i>";
173-
}
174-
entry.innerHTML = type + data;
175-
document.getElementById('chat-overlay').prepend(entry);
176-
}
169+
function logData(type, data) {
170+
var entry = document.createElement('div');
171+
if (type) {
172+
var typeElement = document.createElement('i');
173+
typeElement.textContent = type.replace(/_/g, ' ');
174+
entry.appendChild(typeElement);
175+
entry.appendChild(document.createTextNode(" "));
176+
}
177+
var message = document.createElement('span');
178+
message.textContent = data;
179+
entry.appendChild(message);
180+
document.getElementById('chat-overlay').prepend(entry);
181+
}
177182

178183
window.onload = loadIframe;
179184
</script>
180185
</body>
181-
</html>
186+
</html>

examples/remoteapi.html

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,39 @@
9494
var href = window.location.href;
9595
var arr = href.split('?');
9696
var newurl;
97-
if (arr.length > 1 && arr[1] !== '') {
98-
newurl = href + '&api=' + WID;
99-
} else {
100-
newurl = href + '?api=' + WID;
97+
if (arr.length > 1 && arr[1] !== '') {
98+
newurl = href + '&api=' + encodeURIComponent(WID);
99+
} else {
100+
newurl = href + '?api=' + encodeURIComponent(WID);
101101
}
102102

103103
window.history.pushState({path: newurl.toString()}, '', newurl.toString());
104104

105105
}
106106

107-
var path = "vdo.ninja"; //window.location.host+window.location.pathname.split("/").slice(0,-1).join("/");
108-
var header = document.getElementById("header");
109-
header.innerHTML += "Your Ninja Link: <a href='https://"+path+"/?api="+WID+"' target='_blank'>https://"+path+"/?api="+WID+"</a><br /><br />";
110-
header.innerHTML += "<small>You can append your own VDO.Ninja parameters to this link, treating it like a normal VDO.Ninja link.</small>";
111-
header.innerHTML += "<br /><br /><small>Code and documentation hosted at <a href='https://github.com/steveseguin/Companion-Ninja'>https://github.com/steveseguin/Companion-Ninja</a></small> <svg width='32' height='32' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z' transform='scale(64)' fill='#1B1F23'/></svg>";
107+
var path = "vdo.ninja"; //window.location.host+window.location.pathname.split("/").slice(0,-1).join("/");
108+
var header = document.getElementById("header");
109+
var linkWrapper = document.createElement("div");
110+
var linkLabel = document.createElement("span");
111+
linkLabel.textContent = "Your Ninja Link: ";
112+
var shareLink = document.createElement("a");
113+
var shareURL = "https://" + path + "/?api=" + encodeURIComponent(WID);
114+
shareLink.href = shareURL;
115+
shareLink.target = "_blank";
116+
shareLink.rel = "noopener";
117+
shareLink.textContent = shareURL;
118+
linkWrapper.appendChild(linkLabel);
119+
linkWrapper.appendChild(shareLink);
120+
header.appendChild(linkWrapper);
121+
var info = document.createElement("small");
122+
info.textContent = "You can append your own VDO.Ninja parameters to this link, treating it like a normal VDO.Ninja link.";
123+
header.appendChild(info);
124+
header.appendChild(document.createElement("br"));
125+
header.appendChild(document.createElement("br"));
126+
var repoInfo = document.createElement("small");
127+
repoInfo.innerHTML = "Code and documentation hosted at <a href='https://github.com/steveseguin/Companion-Ninja'>https://github.com/steveseguin/Companion-Ninja</a>";
128+
header.appendChild(repoInfo);
129+
header.insertAdjacentHTML("beforeend", " <svg width='32' height='32' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z' transform='scale(64)' fill='#1B1F23'/></svg>");
112130

113131
var socket = null;
114132
var connecting = false;
@@ -474,4 +492,4 @@
474492
loadGuestCommands(4);
475493
</script>
476494
</body>
477-
</html>
495+
</html>

0 commit comments

Comments
 (0)