-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
163 lines (155 loc) · 6.06 KB
/
main.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
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<html>
<body>
<style>
button {
margin: 0 auto;
display:inline-block;
width: 100px;
background-color: #cccccc;
color:#444444;
}
div {
text-align: center;
}
@media (prefers-color-scheme: dark) {
body {
color:#bbbbbb;
background-color:#121212;
}
button {
color:#bbbbbb;
background-color: #303040;
border-color: #4d256c;
}
input {
color:#bbbbbb;
background-color:303040;
border-color: #4d256c;
}
}
@media screen and (max-width: 500px) {
/* applies only if the screen is narrower than 500px */
html, body {
font-size: 8px;
min-height: 100%;
width: 100%;
weight:100%;
margin: 0;
}
input {
max-width:75%;
}
}
</style>
<script>
/* ONLY / * * / COMMENTS ALLOWED! / / COMMENTS BREAK MY REALLY BAD PYTHON PROGRAM */
function sendToRoku(suffix) {
let IP = document.getElementsByName('IP')[0].value;
if (document.getElementsByName('IPRange')[0].checked) {
let baseIP = IP.split('.').slice(0,3).join('.'); /* removes last number in IP. ex: 192.168.1.1 -> 192.168.1 */
for (let i=0; i<=255; i++) {
fetch(`http://${baseIP}.${i}:8060/${suffix}`,{method:'POST'});
}
}
else {
fetch(`http://${IP}:8060/${suffix}`,{method:'POST'});
}
}
function buttonPress(button) {
sendToRoku(`keypress/${button}`);
}
function letterPress(letter) {
sendToRoku(`keypress/lit_${letter}`);
}
function launchApp(id) {
sendToRoku(`launch/${id}`)
}
function typeText(text) {
for (let i = 0; i < text.length; i++) {
setTimeout(function(){ sendToRoku(`keypress/lit_${encodeURIComponent(text[i])}`); }, 100*i); /* makes a bunch of functions. first will run 100 ms from right now, second 200 ms from rn, etc. each one types a single letter */
}
}
</script>
<div>
<button onclick="buttonPress('Back')">Back<hr/></button>
<button onclick="buttonPress('Home')">Home<hr/></button>
</div>
<br/>
<div>
<button onclick="buttonPress('Up')">Up<hr/></button><br/>
</div>
<div>
<button onclick="buttonPress('Left')">Left<hr/></button>
<button onclick="buttonPress('Select')">Select<hr/></button>
<button onclick="buttonPress('Right')">Right<hr/></button>
</div>
<div>
<button onclick="buttonPress('Down')">Down<hr/></button>
</div>
<br/>
<div>
<button onclick="buttonPress('Rev')">Rewind<hr/></button>
<button onclick="buttonPress('Play')">Play/Pause<hr/></button>
<button onclick="buttonPress('Fwd')">FastForward<hr/></button><br/>
</div>
<br/>
<div>
<button onclick="launchApp('12')">open<br/>netflix</button>
<button onclick="launchApp('13')">open<br/>amazon</button>
</div>
<div>
<button onclick="launchApp('2285')">open<br/>hulu</button>
<button onclick="launchApp('291097')">open<br/>disney+</button>
</div>
<br/>
<hr/>
<br/>
<div>
<button onclick="launchApp('837?contentID=dQw4w9WgXcQ')">Rick Roll<hr/></button>
<button onclick="buttonPress('Info')">Info/"*"<hr/></button>
<br/>
<button onclick="buttonPress('Backspace')">Backspace<hr/></button>
<button onclick="buttonPress('Enter')">Enter<hr/></button>
</div>
<br/>
<br/>
<hr/>
<br/>
<br/>
<div>
<a>app ID: </a>
<input type="text" name="appID"/>
<button onclick="launchApp(document.getElementsByName('appID')[0].value)">open<br/>custom</button>
</div>
<br/>
<br/>
<div>
<a>text: </a>
<input type="text" name="textToType"/>
<button onclick="let textbox=document.getElementsByName('textToType')[0];typeText(textbox.value);textbox.value=''">type<br/>text</button>
</div>
<br/>
<br/>
<div>
<a>custom keypress (ex "keypress/home"): </a>
<input type="text" name="customKeypress"/>
<button onclick="sendToRoku(document.getElementsByName('customKeypress')[0].value)">press<br/>key</button>
<br/>
<a href="https://developer.roku.com/docs/developer-program/debugging/external-control-api.md#keypress-key-values">buttons you can push</a>
</div>
<br/>
<br/>
<hr/>
<br/>
<br/>
<a> IP: </a><input type="text" name="IP" value="192.168.50.152"/>
<br/>
<a> use IP range: </a><input type="checkbox" name="IPRange" value=false/><a>
<br/>
<a>(ex: will send commands to all in range 192.168.0.0-255, instead of just one IP)<a/>
<br/>
<br/>
<a href="https://developer.roku.com/docs/developer-program/debugging/external-control-api.md">official roku documention</a>
</body>
</html>