-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmessage.sh
executable file
·78 lines (73 loc) · 2 KB
/
message.sh
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
#!/bin/bash
IFS='' read -r -d '' page <<"EOF"
<DOCTYPE html>
<html>
<head>
<style>
BODY {
color: #FFF;
margin: 0;
padding: 0;
background-color: #000000;
font-family: 'Noto Sans';
font-size: 14px;
height: 100%;
width: 100%;
text-align: center;
overflow: hidden;
}
.wrapper {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
justify-content: space-between;
}
input[type=button] {
height: 40px;
font-size: 20px;
}
#btn_blue {
background-color: blue;
}
#btn_red {
background-color: red;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', () => {
document
.getElementById('btn_blue')
.addEventListener('click', () => {
window.parent.postMessage({
command: 'write-stdin',
text: 'b',
});
});
document
.getElementById('btn_red')
.addEventListener('click', () => {
window.parent.postMessage({
command: 'write-stdin',
text: 'r',
});
});
});
</script>
</head>
<body>
<div class="wrapper">
<input value="blue pill" type="button" id="btn_blue" />
<input value="red pill" type="button" id="btn_red" />
</div>
</body>
</html>
EOF
echo -e "\x1B]21337;web-terminal;write-srcdoc?height=80;${page}\x1B\\"
# BUG: text renders under iframe without sleep
read -rsn 11 val
action=${val:8:1}
[ "$action" == "b" ] && echo "The Matrix has you..."
[ "$action" == "r" ] && echo "Follow the white rabbit."
echo "Received: $action"
echo -e "\x1B]21337;web-terminal;detach-all\x1B\\"