Skip to content

Commit

Permalink
Upgrade standalone scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kevglass committed Dec 11, 2024
1 parent 8668d2c commit c7b3d84
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
15 changes: 14 additions & 1 deletion standalone/build-single-player.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,17 @@ perl -pe 's/<\/head>/<script src="hosting\.js"><\/script><\/head>/' ./dist/index
cp ./dist/temp.html ./dist/index.html
rm ./dist/temp.html

cp standalone/hosting.js dist
perl -pe 's/<\/body>/<div id="loading" style="position: absolute; width: 100%; height: 100%; background: black; z-index: 1000"><\/div><\/body>/' ./dist/index.html > ./dist/temp.html
cp ./dist/temp.html ./dist/index.html
rm ./dist/temp.html

perl -pe 's/https:\/\/cdn.jsdelivr.net\/npm\/rune-sdk.*\/multiplayer-dev.js/multiplayer-dev.js/' ./dist/index.html > ./dist/temp.html
cp ./dist/temp.html ./dist/index.html
rm ./dist/temp.html

cp standalone/hosting.js dist
cp node_modules/rune-sdk/multiplayer-dev.js dist

perl -pe 's/calc\(100vh/calc\(0vh/g' ./dist/multiplayer-dev.js > ./dist/temp.js
cp ./dist/temp.js ./dist/multiplayer-dev.js
rm ./dist/temp.js
36 changes: 30 additions & 6 deletions standalone/hosting.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
// prevent accidental multiple includsions


if (!window.parentDoc) {
window.parentDoc = window.parent.document

// set the background to white
// // set the background to white
window.parentDoc.body.style.background = "#FFF"
// remove the top bar
window.parentDoc
.getElementById("root")
.childNodes[0].childNodes[1].childNodes[0].remove()
// remove the user name
window.parentDoc
.getElementById("root")
.childNodes[0].childNodes[1].childNodes[0].childNodes[0].childNodes[1].remove()
if (
window.parentDoc.getElementById("root").childNodes[0].childNodes[1]
.childNodes[0]
) {
window.parentDoc
.getElementById("root")
.childNodes[0].childNodes[1].childNodes[0].childNodes[0].childNodes[1].remove()
}
setTimeout(() => {
const iframe = window.parentDoc.getElementsByTagName("iframe")[0]
if (iframe.parentNode !== window.parentDoc.body) {
iframe.style.position = "absolute"
iframe.style.top = "0"
iframe.style.left = "0"

iframe.parentNode.removeChild(iframe)
window.parentDoc.body.appendChild(iframe)
}
}, 1)
}

setTimeout(() => {
const overlay = document.getElementById("loading")
if (overlay) {
overlay.parentNode.removeChild(overlay)
}
}, 1000)

0 comments on commit c7b3d84

Please sign in to comment.