Skip to content

Commit bb139b5

Browse files
committed
Defer notify scripts ready
1 parent 7f89756 commit bb139b5

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

injected/src/features/duck-player-native.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,23 @@ export class DuckPlayerNativeFeature extends ContentFeature {
2222
current;
2323

2424
async init(args) {
25-
console.log('DUCK PLAYER NATIVE LOADING', args, window.location.href);
25+
console.log('DUCK PLAYER NATIVE LOADING', args, window.location.href); // TODO: REMOVE
2626

2727
// TODO: May depend on page type
2828
/**
2929
* This feature never operates in a frame
3030
*/
31-
if (isBeingFramed()) return;
31+
if (isBeingFramed()) {
32+
console.log('FRAMED. ABORTING.'); // TODO: REMOVE
33+
return;
34+
}
3235

3336
const selectors = this.getFeatureSetting('selectors');
34-
console.log('DUCK PLAYER NATIVE SELECTORS', selectors);
37+
console.log('DUCK PLAYER NATIVE SELECTORS', selectors); // TODO: REMOVE
3538

3639
const locale = args?.locale || args?.language || 'en';
3740
const env = new Environment({
38-
debug: this.isDebug || true, // TODO: remove
41+
debug: this.isDebug || true, // TODO: REMOVE
3942
injectName: import.meta.injectName,
4043
platform: this.platform,
4144
locale,
@@ -68,11 +71,9 @@ export class DuckPlayerNativeFeature extends ContentFeature {
6871
console.log('INITIAL SETUP', initialSetup);
6972

7073
if (initialSetup.pageType) {
71-
console.log('GOT INITIAL PAGE TYPE', initialSetup.pageType);
74+
console.log('GOT INITIAL PAGE TYPE', initialSetup.pageType); // TODO: REMOVE
7275
this.urlChangeHandler(initialSetup.pageType, selectors, env, messages);
7376
}
74-
75-
messages.notifyFeatureIsReady();
7677
}
7778

7879
/**

injected/src/features/duckplayer-native/duckplayer-native.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ export class DuckPlayerNative {
8282
if (document.readyState === 'loading') {
8383
this.sideEffects.add('setting up load event listener', () => {
8484
const loadHandler = () => {
85+
this.logger.log('Running deferred load handlers');
8586
this.onLoad(this.sideEffects, this.logger);
87+
this.messages.notifyScriptIsReady();
8688
};
8789
document.addEventListener('DOMContentLoaded', loadHandler, { once: true });
8890

@@ -93,9 +95,8 @@ export class DuckPlayerNative {
9395
} else {
9496
this.logger.log('Running load handlers immediately');
9597
this.onLoad(this.sideEffects, this.logger);
98+
this.messages.notifyScriptIsReady();
9699
}
97-
98-
this.messages.notifyScriptIsReady();
99100
}
100101
}
101102

@@ -118,6 +119,7 @@ export function setupDuckPlayerForYouTube(selectors, environment, messages) {
118119
const onInit = (sideEffects, logger) => {
119120
sideEffects.add('subscribe to media control', () => {
120121
return messages.subscribeToMediaControl(({ pause }) => {
122+
console.log('MEDIA CONTROL', pause); // TODO: Remove
121123
logger.log('Running media control handler. Pause:', pause);
122124

123125
const videoElement = selectors?.videoElement;

0 commit comments

Comments
 (0)