-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.html
26 lines (26 loc) · 1.02 KB
/
index.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
<div style="font-family: sans-serif">
<button id="gotoYouTubeBtn">Open Youtube.com</button>
Volume: <input type="range" min="0" max="100" value="100" id="range">
<p>Current website: <span id="currentSite"></p>
</div>
<div id="cloudComputerDiv" style="height:720px;width:1280px"></div>
<script type="module">
import Hyperbeam from "https://unpkg.com/@hyperbeam/web@latest/dist/index.js"
const resp = await fetch("/computer")
const data = await resp.json()
const hb = await Hyperbeam(cloudComputerDiv, data.embed_url)
// Programmatically navigate to websites
gotoYouTubeBtn.addEventListener("click", () => {
hb.tabs.update({ url: "https://youtube.com" })
})
// Control the user's local volume
range.addEventListener("change", (e) => {
hb.volume = e.target.value / 100
})
// Listen to tab changes
// (e.g. get the tab's new title when the user visits a different site)
hb.tabs.onUpdated.addListener((tabId, changeInfo) => {
if (changeInfo.title)
currentSite.innerText = changeInfo.title
})
</script>