aboutsummaryrefslogtreecommitdiffstats
path: root/src/fullscreen_credits.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/fullscreen_credits.ts')
-rw-r--r--src/fullscreen_credits.ts51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/fullscreen_credits.ts b/src/fullscreen_credits.ts
index f558221..e436ed5 100644
--- a/src/fullscreen_credits.ts
+++ b/src/fullscreen_credits.ts
@@ -1,4 +1,4 @@
-// Copyright (c) 2020 Teddy Wing
+// Copyright (c) 2020–2021 Teddy Wing
//
// This file is part of Immersive.
//
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with Immersive. If not, see <https://www.gnu.org/licenses/>.
-import controls from './controls';
+import logger from './logger';
import wait_element from './wait_element';
@@ -25,19 +25,52 @@ function init_mutation_observer (player) {
for (var i = 0; i < mutation_list.length; i++) {
const mutation = mutation_list[i];
const player = mutation.target as HTMLElement;
+ const video = player.querySelector('video') as HTMLElement;
// The `postplay` class minimises the movie. Remove it if it gets
// added to remain in full frame.
- if (player.classList.contains('postplay')) {
- player.classList.remove('postplay');
+ if (player.classList.contains('watch-video--player-view-minimized')) {
+ logger.debug('fullscreen_credits', 'init_mutation_observer()', 'Maximising');
- // Playback controls are removed when postplay is activated.
- // Re-enable them.
- player.click();
+ player.classList.remove('watch-video--player-view-minimized');
+
+ // Resize the video to full frame. Otherwise it will shrink for
+ // a second until the click event kicks in.
+ video.style.height = null;
+ video.style.width = 'inherit';
// Activating playback controls makes them visible. Keep them
// hidden.
- controls.hide();
+ const style_el = document.createElement('style');
+ document.head.appendChild(style_el);
+
+ const stylesheet = style_el.sheet as CSSStyleSheet;
+
+ stylesheet.insertRule(`
+ .watch-video--back-container {
+ visibility: hidden !important;
+ }
+
+ .watch-video--bottom-controls-container {
+ display: none !important;
+ }`,
+ stylesheet.cssRules.length
+ );
+
+ // Playback controls are removed when postplay is activated.
+ // Re-enable them.
+ const click_area = player.children[0] as HTMLElement;
+ click_area.click();
+
+ // Once the player controls auto-hide themselves, remove our
+ // forced hiding so that the controls become user-accessible
+ // again.
+ setTimeout(
+ function() {
+ document.head.removeChild(style_el);
+ },
+ 4000
+ );
return;
}
@@ -54,7 +87,7 @@ function init_mutation_observer (player) {
// Initialise the mutation observer when the video player becomes available.
export default function init () {
- wait_element('.NFPlayer.nf-player-container')
+ wait_element('.watch-video--player-view')
.then(function(player) {
init_mutation_observer(player);
});