Skip to content

Commit

Permalink
0.2.5a
Browse files Browse the repository at this point in the history
Feature added: Keep the player always visible while scrolling
  • Loading branch information
ParticleCore committed Jun 12, 2017
1 parent 737f14b commit 6ebb438
Showing 1 changed file with 70 additions and 2 deletions.
72 changes: 70 additions & 2 deletions src/Userscript/Iridium.user.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ==UserScript==
// @version 0.2.4a
// @version 0.2.5a
// @name Iridium
// @namespace https://github.com/ParticleCore
// @description YouTube with more freedom
Expand Down Expand Up @@ -1095,6 +1095,74 @@

}
},
{
options: {
player_always_visible: {
id: "player_always_visible",
section: "video",
sub_section: "player",
type: "checkbox",
value: false,
i18n: {
label: "Keep the player always visible while scrolling"
}
}
},
iniFloater: function() {

var player;
var player_api;
var player_bounds;
var is_out_of_sight;
var player_container;
var is_in_theater_mode;
var is_already_floating;

if (user_settings.player_always_visible && window.location.pathname === "/watch") {

if ((player_container = document.getElementById("player-container")) && (player_bounds = player_container.getBoundingClientRect())) {

is_out_of_sight = player_bounds.bottom < ((player_bounds.height / 2) + 50);
is_already_floating = document.documentElement.classList.contains("iri-always-visible");
player_api = document.getElementById("movie_player");

if (is_out_of_sight && !is_already_floating) {

document.documentElement.classList.add("iri-always-visible");

if (player_api) {

player_api.setSizeStyle(false, true);

}

} else if (!is_out_of_sight && is_already_floating) {

document.documentElement.classList.remove("iri-always-visible");

if (player_api) {

is_in_theater_mode = document.querySelector("ytd-watch[theater]");

player_api.setSizeStyle(true, is_in_theater_mode);

}

}

}

}

},
ini: function() {

iridium_api.initializeOption.call(this);

window.addEventListener("scroll", this.iniFloater, false);

}
},
{
options: {
iridium_dark_mode: {
Expand Down Expand Up @@ -2066,7 +2134,7 @@
holder = document.createElement("link");
holder.rel = "stylesheet";
holder.type = "text/css";
holder.href = "https://particlecore.github.io/Iridium/css/Iridium.css?v=0.2.4a";
holder.href = "https://particlecore.github.io/Iridium/css/Iridium.css?v=0.2.5a";
document.documentElement.appendChild(holder);

}
Expand Down

0 comments on commit 6ebb438

Please sign in to comment.