aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fullscreen_credits.ts16
-rw-r--r--src/player.ts16
2 files changed, 18 insertions, 14 deletions
diff --git a/src/fullscreen_credits.ts b/src/fullscreen_credits.ts
index 6d174ed..d8b68b9 100644
--- a/src/fullscreen_credits.ts
+++ b/src/fullscreen_credits.ts
@@ -1,17 +1,5 @@
-function with_player (callback) {
- var interval = setInterval(
- function() {
- var player = document.querySelector('.NFPlayer.nf-player-container');
+import with_player from './player';
- if (player) {
- clearInterval(interval);
-
- callback(player);
- }
- },
- 1000
- );
-}
function init_mutation_observer (player) {
var observer = new MutationObserver(function(mutation_list) {
@@ -60,7 +48,7 @@ function init_mutation_observer (player) {
}
export default function init () {
- with_player(function(player) {
+ with_player().then(function(player) {
init_mutation_observer(player);
});
}
diff --git a/src/player.ts b/src/player.ts
new file mode 100644
index 0000000..ea0e541
--- /dev/null
+++ b/src/player.ts
@@ -0,0 +1,16 @@
+export default function with_player (): Promise<HTMLElement> {
+ return new Promise(function(resolve) {
+ const interval = setInterval(
+ function() {
+ const player = document.querySelector('.NFPlayer.nf-player-container');
+
+ if (player) {
+ clearInterval(interval);
+
+ resolve(player);
+ }
+ },
+ 1000
+ );
+ });
+}