Adding Background Music & Persistent Logo
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
<script>
const bgm = document.createElement("audio");
const btn = document.createElement("button");
bgm.setAttribute("id", "bgm");
bgm.setAttribute(
"src",
"https://www.chosic.com/wp-content/uploads/2020/07/Art-Of-Silence_V2.mp3"
);
function play() {
bgm.volume = 0.4;
bgm.play();
bgm.loop = true;
}
function muteUnmuteAudio() {
if (bgm.muted == false) {
bgm.muted = true;
btn.setAttribute(
"style",
"background: url(https://s.vrgmetri.com/gb-web/teaxrweb/stw/mute_white.png); width: 64px; height: 64px; transform: scale(0.7); border: none;"
);
btn.style.position = "absolute";
btn.style.bottom = "0";
btn.style.right = "0";
} else {
bgm.muted = false;
btn.setAttribute(
"style",
"background: url(https://s.vrgmetri.com/gb-web/teaxrweb/stw/unmute_white.png); width: 64px; height: 64px; transform: scale(0.7); border: none;"
);
btn.style.position = "absolute";
btn.style.bottom = "0";
btn.style.right = "0";
}
}
function attachAudioControls() {
btn.setAttribute(
"style",
"background: url(https://s.vrgmetri.com/gb-web/teaxrweb/stw/unmute_white.png); width: 64px; height: 64px; transform: scale(0.7); border: none;"
);
btn.style.position = "absolute";
btn.style.bottom = "0";
btn.style.right = "0";
btn.onclick = muteUnmuteAudio;
document.getElementById("user-script").appendChild(btn);
}
let checker = setInterval(play, 1000);
attachAudioControls();
</script><script>
const logo =
"https://avatars.githubusercontent.com/u/60691540?s=200&v=4";
function createHeader() {
const header = document.createElement("span");
header.style.position = "fixed";
header.style.top = "16px";
header.style.left = "16px";
document.getElementById("user-script").appendChild(header);
const img = document.createElement("img");
img.style.width = "120px";
img.style.height = "auto";
img.src = logo;
header.appendChild(img);
}
createHeader()
</script>