diff options
author | Teddy Wing | 2020-05-09 00:32:16 +0200 |
---|---|---|
committer | Teddy Wing | 2020-05-09 00:50:19 +0200 |
commit | 9eecf1c6be59ff3c04152390d7ce556e36965fd8 (patch) | |
tree | 2d6cec9c91a0585eca48847acfc729fbca7f1fd2 | |
parent | 21afe4648732d2fc6b6fc0a92de3a0b0d7f91264 (diff) | |
download | netflix-immersive-9eecf1c6be59ff3c04152390d7ce556e36965fd8.tar.bz2 |
Add documentation comments
-rw-r--r-- | netflix-immersive.user.js | 17 | ||||
-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 |
6 files changed, 32 insertions, 2 deletions
diff --git a/netflix-immersive.user.js b/netflix-immersive.user.js index 4219d65..5941fb2 100644 --- a/netflix-immersive.user.js +++ b/netflix-immersive.user.js @@ -27,6 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var logger_1 = require("./logger"); var controls = { + // Hide playback controls. hide: function () { logger_1.default.debug('hide():', 'Hiding controls'); var controls_el = document.querySelector('.PlayerControlsNeo__layout.PlayerControlsNeo__layout--active'); @@ -43,15 +44,21 @@ exports.default = controls; Object.defineProperty(exports, "__esModule", { value: true }); var controls_1 = require("./controls"); var wait_element_1 = require("./wait_element"); +// Prevent credits from being minimised. function init_mutation_observer(player) { var observer = new MutationObserver(function (mutation_list) { for (var i = 0; i < mutation_list.length; i++) { var mutation = mutation_list[i]; var player_1 = mutation.target; + // The `postplay` class minimises the movie. Remove it if it gets + // added to remain in full frame. if (player_1.classList.contains('postplay')) { player_1.classList.remove('postplay'); - // Activate player controls. + // Playback controls are removed when postplay is activated. + // Re-enable them. player_1.click(); + // Activating playback controls makes them visible. Keep them + // hidden. controls_1.default.hide(); return; } @@ -62,6 +69,7 @@ function init_mutation_observer(player) { attributeOldValue: true }); } +// Initialise the mutation observer when the video player becomes available. function init() { wait_element_1.default('.NFPlayer.nf-player-container') .then(function (player) { @@ -103,6 +111,7 @@ exports.default = { },{}],5:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +// Adds CSS to the page to hide superfluous user interface elements. function styles() { var style = document.createElement('style'); document.head.appendChild(style); @@ -115,6 +124,8 @@ exports.default = styles; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var logger_1 = require("./logger"); +// Wait for the element corresponding to `selector` to be added to the page, +// checking every second until it appears. function wait_element(selector) { return new Promise(function (resolve) { var interval = setInterval(function () { @@ -135,6 +146,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var controls_1 = require("./controls"); var logger_1 = require("./logger"); var wait_element_1 = require("./wait_element"); +// Remove the "Watch Credits" button. function init_mutation_observer(controls_el) { var observer = new MutationObserver(function (mutation_list) { for (var i = 0; i < mutation_list.length; i++) { @@ -145,6 +157,8 @@ function init_mutation_observer(controls_el) { logger_1.default.debug('watch_credits', 'init_mutation_observer()', 'found Watch Credits button', watch_credits_button); var 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_1.default.hide(); return; } @@ -155,6 +169,7 @@ function init_mutation_observer(controls_el) { subtree: true }); } +// Initialise the mutation observer when playback controls become available. function init() { wait_element_1.default('.PlayerControlsNeo__all-controls') .then(function (controls_el) { 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) { |