aboutsummaryrefslogtreecommitdiffstats
path: root/src/watch_credits.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/watch_credits.ts')
-rw-r--r--src/watch_credits.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/watch_credits.ts b/src/watch_credits.ts
new file mode 100644
index 0000000..3aba520
--- /dev/null
+++ b/src/watch_credits.ts
@@ -0,0 +1,49 @@
+import controls from './controls';
+import logger from './logger';
+import wait_element from './wait_element';
+
+
+// const watch_credits_button = document.querySelector('[data-uia="watch-credits-seamless-button"]');
+
+
+
+function init_mutation_observer (controls) {
+ var observer = new MutationObserver(function(mutation_list) {
+ for (var i = 0; i < mutation_list.length; i++) {
+ var mutation = mutation_list[i];
+ var element = mutation.target as HTMLElement;
+
+ var watch_credits_button: HTMLButtonElement = element.querySelector(
+ '[data-uia="watch-credits-seamless-button"]'
+ );
+
+ if (watch_credits_button) {
+ logger.debug('found Watch Credits button', watch_credits_button);
+
+ var pointer_event = new PointerEvent('pointerdown', { bubbles: true });
+ watch_credits_button.dispatchEvent(pointer_event);
+
+ controls.hide();
+
+ return;
+ }
+ }
+ });
+
+ observer.observe(
+ controls,
+ {
+ childList: true,
+ subtree: true
+ }
+ );
+}
+
+export default function init () {
+ wait_element('.PlayerControlsNeo__all-controls')
+ .then(function(controls) {
+ logger.debug('Controls element:', controls);
+
+ init_mutation_observer(controls);
+ });
+}