Skip to content

Instantly share code, notes, and snippets.

@Rene-Sackers
Last active March 18, 2022 15:44
Show Gist options
  • Save Rene-Sackers/b7ab177704d1c3a43bf70f836e88d20e to your computer and use it in GitHub Desktop.
Save Rene-Sackers/b7ab177704d1c3a43bf70f836e88d20e to your computer and use it in GitHub Desktop.
F1TV theatre mode
// ==UserScript==
// @name F1 theatre mode
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Make F1TV videos theatre mode
// @author René Sackers
// @match https://f1tv.formula1.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
var playerIsPopped = false;
var normalParent = null;
function buttonClicked() {
var player = document.getElementsByClassName("embedded-player-container")[0];
if (!player)
{
alert("#main-embeddedPlayer not found");
return;
}
var app = document.getElementById("app");
if (!app)
{
alert("#app not found");
return;
}
if (!playerIsPopped)
{
normalParent = player.parentElement;
document.body.appendChild(player);
app.style.display = "none";
}
else
{
app.style.display = "block";
normalParent.appendChild(player);
}
playerIsPopped = !playerIsPopped;
}
function checkButtonExists() {
if (document.getElementsByClassName("embedded-player-container").length == 0)
return;
if (document.getElementById("theatre-button"))
return;
var theatreButton = document.createElement("button");
theatreButton.classList.add("bmpui-ui-fullscreentogglebutton", "bmpui-off");
theatreButton.setAttribute("id", "theatre-button");
theatreButton.setAttribute("type", "button");
theatreButton.addEventListener("click", buttonClicked);
document.getElementsByClassName("bmpui-controlbar-bottom")[0].firstChild.appendChild(theatreButton);
}
(function() {
'use strict';
setInterval(checkButtonExists, 1000);
})();
@Rene-Sackers
Copy link
Author

Adds a 2nd "fullscreen" button to the bottom player bar that toggles the player between theatre mode, hiding the rest of the site.
image
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment