diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/controls.ts | 1 | ||||
-rw-r--r-- | src/fullscreen_credits.ts | 9 | ||||
-rw-r--r-- | src/styles.ts | 1 | ||||
-rw-r--r-- | src/wait_element.ts | 2 | ||||
-rw-r--r-- | src/watch_credits.ts | 4 |
5 files changed, 16 insertions, 1 deletions
diff --git a/src/controls.ts b/src/controls.ts index b89177d..fe4a727 100644 --- a/src/controls.ts +++ b/src/controls.ts @@ -19,6 +19,7 @@ import logger from './logger'; const controls = { + // Hide playback controls. hide: function() { logger.debug('hide():', 'Hiding controls'); diff --git a/src/fullscreen_credits.ts b/src/fullscreen_credits.ts index 06cc873..d8b25b9 100644 --- a/src/fullscreen_credits.ts +++ b/src/fullscreen_credits.ts @@ -19,18 +19,24 @@ import controls from './controls'; import wait_element from './wait_element'; +// Prevent credits from being minimised. function init_mutation_observer (player) { const observer = new MutationObserver(function(mutation_list) { for (var i = 0; i < mutation_list.length; i++) { const mutation = mutation_list[i]; const player = mutation.target 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'); - // Activate player controls. + // Playback controls are removed when postplay is activated. + // Re-enable them. player.click(); + // Activating playback controls makes them visible. Keep them + // hidden. controls.hide(); return; @@ -47,6 +53,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') .then(function(player) { diff --git a/src/styles.ts b/src/styles.ts index 3e1658b..0d5235d 100644 --- a/src/styles.ts +++ b/src/styles.ts @@ -15,6 +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/>. +// Adds CSS to the page to hide superfluous user interface elements. export default function styles () { const style = document.createElement('style'); diff --git a/src/wait_element.ts b/src/wait_element.ts index 115efb1..7fd2b56 100644 --- a/src/wait_element.ts +++ b/src/wait_element.ts @@ -18,6 +18,8 @@ import logger from './logger'; +// Wait for the element corresponding to `selector` to be added to the page, +// checking every second until it appears. export default function wait_element (selector: string): Promise<Element> { return new Promise(function(resolve) { const interval = setInterval( diff --git a/src/watch_credits.ts b/src/watch_credits.ts index c6e2c7f..f41844a 100644 --- a/src/watch_credits.ts +++ b/src/watch_credits.ts @@ -20,6 +20,7 @@ import logger from './logger'; import wait_element from './wait_element'; +// Remove the "Watch Credits" button. function init_mutation_observer (controls_el) { const observer = new MutationObserver(function(mutation_list) { for (var i = 0; i < mutation_list.length; i++) { @@ -41,6 +42,8 @@ function init_mutation_observer (controls_el) { const pointer_event = new PointerEvent('pointerdown', { bubbles: true }); watch_credits_button.dispatchEvent(pointer_event); + // When playback controls return as a result of having pressed + // "Watch Credits", they become visible. Keep them hidden. controls.hide(); return; @@ -57,6 +60,7 @@ function init_mutation_observer (controls_el) { ); } +// Initialise the mutation observer when playback controls become available. export default function init () { wait_element('.PlayerControlsNeo__all-controls') .then(function(controls_el) { |