Background Eternal Jukebox

Keep the eternal box running, even if it is in the background.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Background Eternal Jukebox
// @namespace    https://theusaf.org
// @version      1.1.1
// @description  Keep the eternal box running, even if it is in the background.
// @author       theusaf
// @match        https://eternalbox.dev/jukebox_go.html*
// @match        https://www.eternalboxmirror.xyz/jukebox_go.html*
// @icon         https://i.imgur.com/espirtf.png
// @license      MIT
// @copyright    2023 theusaf
// @grant        none
// ==/UserScript==

const panel = document.querySelector("#button-panel");
const triggerButton = document.createElement("button");
const fakeVideo = document.createElement("video");
panel.append(triggerButton, fakeVideo);
triggerButton.className = "btn btn-small btn-default";
fakeVideo.controls = true;
fakeVideo.loop = true;
fakeVideo.src = "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAArptZGF0AAACnwYF//+b3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE2MCAtIEguMjY0L01QRUctNCBBVkMgY29kZWMgLSBDb3B5bGVmdCAyMDAzLTIwMjAgLSBodHRwOi8vd3d3LnZpZGVvbGFuLm9yZy94MjY0Lmh0bWwgLSBvcHRpb25zOiBjYWJhYz0wIHJlZj0yIGRlYmxvY2s9MTowOjAgYW5hbHlzZT0weDM6MHgxMDAgbWU9aGV4IHN1Ym1lPTYgcHN5PTEgcHN5X3JkPTEuMDA6MC4wMCBtaXhlZ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AAAAAAAAAVmlkZW9IYW5kbGVyAAAAAUptaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAEKc3RibAAAAKZzdHNkAAAAAAAAAAEAAACWYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAQABAASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAADBhdmNDAWQACv/hABdnZAAKrNlewEQAAAMABAAAAwDAPEiWWAEABmjK48siwAAAABBwYXNwAAAAAQAAAAEAAAAYc3R0cwAAAAAAAAABAAAAAQAAAgAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAFHN0c3oAAAAAAAACsgAAAAEAAAAUc3RjbwAAAAAAAAABAAAAMAAAAI11ZHRhAAAAhW1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAWGlsc3QAAAArqWRheQAAACNkYXRhAAAAAQAAAAAyMDIzLzAzLzE5IDEyOjQwOjA5AAAAJal0b28AAAAdZGF0YQAAAAEAAAAATGF2ZjU4LjI5LjEwMA==";

function hideVideo() {
  fakeVideo.style.visibility = "hidden";
  fakeVideo.style.position = "absolute";
  fakeVideo.style.pointerEvents = "none";
}
hideVideo();
function showVideo() {
  fakeVideo.style.visibility = "";
  fakeVideo.style.position = "";
  fakeVideo.style.pointerEvents = "";
  fakeVideo.style.height = "4rem";
  fakeVideo.style.width = "4rem";
  fakeVideo.style.backgroundColor = "black";
}

triggerButton.textContent = "Enable Background Run";
triggerButton.onclick = function() {
  if ('pictureInPictureEnabled' in document) {
    hideVideo();
    fakeVideo.play();
    fakeVideo.requestPictureInPicture();
  } else {
    showVideo();
    alert("The PiP API is not enabled on your browser. Try using the native button instead.");
  }
}