@@ -128,22 +128,26 @@ const VideoPlayer = {
128
128
/**
129
129
* Fires whenever the video player iframe <title> changes (the video doesn't have the <title> set to
130
130
* the video title until after the video has loaded...)
131
- * @param {Function } callback (title)
131
+ * @param {(title: string) => void } callback
132
132
*/
133
133
onIframeTitleChange : ( callback ) => {
134
134
const iframe = VideoPlayer . iframe ( )
135
135
136
+ if ( iframe ?. contentDocument ?. title ) {
137
+ // eslint-disable-next-line n/no-callback-literal
138
+ callback ( iframe ?. contentDocument ?. title )
139
+ }
136
140
if ( iframe ?. contentWindow && iframe ?. contentDocument ) {
137
- const title = iframe . contentDocument . querySelector ( 'title' )
141
+ const titleElem = iframe . contentDocument . querySelector ( 'title' )
138
142
139
- if ( title ) {
143
+ if ( titleElem ) {
140
144
// @ts -expect-error - typescript known about MutationObserver in this context
141
145
const observer = new iframe . contentWindow . MutationObserver ( function ( mutations ) {
142
146
mutations . forEach ( function ( mutation ) {
143
147
callback ( mutation . target . textContent )
144
148
} )
145
149
} )
146
- observer . observe ( title , { childList : true } )
150
+ observer . observe ( titleElem , { childList : true } )
147
151
} else {
148
152
// console.warn('could not access title in iframe')
149
153
}
@@ -555,7 +559,6 @@ const PlayOnYouTube = {
555
559
init : ( opts ) => {
556
560
const validVideoId = Comms . getValidVideoId ( )
557
561
const timestamp = Comms . getSanitizedTimestamp ( )
558
- console . log ( { validVideoId } )
559
562
560
563
if ( validVideoId ) {
561
564
const url = new URL ( opts . base )
0 commit comments