@@ -20,6 +20,7 @@ export default class WebAudio {
2020 muted : boolean ;
2121 rules : AudioRule [ ] ;
2222 sites : { [ site : string ] : AudioRule [ ] } ;
23+ siteKey : string ;
2324 supportedPage : boolean ;
2425 unmuteTimeout : number ;
2526 volume : number ;
@@ -79,7 +80,8 @@ export default class WebAudio {
7980 this . youTubeAutoSubsUnmuteDelay = 0 ;
8081
8182 // Setup rules for current site
82- this . rules = this . sites [ filter . hostname ] ;
83+ this . siteKey = this . getSiteKey ( ) ;
84+ this . rules = this . sites [ this . siteKey ] ;
8385 if ( this . rules ) {
8486 if ( ! Array . isArray ( this . rules ) ) { this . rules = [ this . rules ] ; }
8587 this . rules . forEach ( ( rule ) => { this . initRule ( rule ) ; } ) ;
@@ -237,6 +239,20 @@ export default class WebAudio {
237239 }
238240 }
239241
242+ getSiteKey ( ) : string {
243+ if ( this . sites . hasOwnProperty ( this . filter . hostname ) ) {
244+ return this . filter . hostname ;
245+ } else if (
246+ this . filter . iframe
247+ && this . filter . iframe . hostname
248+ && this . sites . hasOwnProperty ( this . filter . iframe . hostname )
249+ ) {
250+ return this . filter . iframe . hostname ;
251+ }
252+
253+ return '' ;
254+ }
255+
240256 // Priority (requires cues): [overrideKey], label, language, kind (prefer caption/subtitle), order
241257 getVideoTextTrack ( textTracks , rule , overrideKey ?: string ) : TextTrack {
242258 let bestIndex = 0 ;
@@ -439,7 +455,7 @@ export default class WebAudio {
439455 }
440456
441457 initYouTube ( ) {
442- if ( [ 'm.youtube.com' , 'tv.youtube.com' , 'www.youtube.com' ] . includes ( this . filter . hostname ) ) {
458+ if ( [ 'm.youtube.com' , 'tv.youtube.com' , 'www.youtube.com' ] . includes ( this . siteKey ) ) {
443459 this . youTube = true ;
444460 // Issue 251: YouTube is now filtering words out of auto-generated captions/subtitles
445461 const youTubeAutoCensor = '[ __ ]' ;
@@ -708,7 +724,7 @@ export default class WebAudio {
708724 throw ( `Failed to find subtitle variable: ${ rule . externalSubVar } ` ) ;
709725 }
710726 } catch ( e ) {
711- logger . error ( `[Audio] Error using external subtitles for ${ this . filter . hostname } .` , e ) ;
727+ logger . error ( `[Audio] Error using external subtitles for ${ this . siteKey } .` , e ) ;
712728 }
713729 }
714730 }
0 commit comments