Skip to content

Commit 607c59e

Browse files
authored
🔀 Merge pull request #321 from richardfrost/embedded_youtube
Embedded youtube
2 parents f06c405 + 1f1dcfe commit 607c59e

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/script/dataMigration.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ export default class DataMigration {
127127
if (cfg[propToDelete] && Array.isArray(cfg[propToDelete])) {
128128
if (cfg[propToDelete].length > 0) {
129129
cfg[propToDelete].forEach((domain) => {
130-
if (cfg.domains[domain] == undefined) { cfg.domains[domain] = {}; }
131-
cfg.domains[domain][propsToDelete[propToDelete]] = true;
130+
if (domain) {
131+
if (cfg.domains[domain] == null) { cfg.domains[domain] = {}; }
132+
cfg.domains[domain][propsToDelete[propToDelete]] = true;
133+
}
132134
});
133135
}
134136
}

src/script/webAudio.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)