forked from night/betterttv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
64 lines (52 loc) · 1.93 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(async (currentScript) => {
if (!String.prototype.includes || !Array.prototype.findIndex) return;
if (window.location.pathname.endsWith('.html')) return;
if (
![
'www.twitch.tv',
'canary.twitch.tv',
'release.twitch.tv',
'clips.twitch.tv',
'dashboard.twitch.tv',
'embed.twitch.tv',
'www.youtube.com',
'studio.youtube.com',
].includes(window.location.hostname) &&
!window.location.hostname.endsWith('.release.twitch.tv')
)
return;
if (window.Ember) return;
// prevent loads in source-less iframes
try {
const {frameElement} = window;
if (frameElement != null && (frameElement.src == null || frameElement.src === '')) {
return;
}
} catch (e) {}
// some people have multiple versions of BetterTTV, for whatever reason
if (window.BetterTTV || window.__betterttv) return;
window.__betterttv = true;
await import('./utils/sentry.js');
const {load: loadI18n} = await import('./i18n/index.js');
await loadI18n();
const {default: extension} = await import('./utils/extension.js');
extension.setCurrentScript(currentScript);
const {default: globalCSS} = await import('./modules/global_css/index.js');
const globalCSSLoadPromise = globalCSS.loadGlobalCSS();
const {default: debug} = await import('./utils/debug.js');
const {default: watcher} = await import('./watcher.js');
// wait until styles load to prevent flashing
await globalCSSLoadPromise;
// eslint-disable-next-line import/no-unresolved
await import('./modules/**/index.js');
watcher.setup();
debug.log(`BetterTTV v${debug.version} loaded. ${process.env.NODE_ENV} @ ${process.env.GIT_REV}`);
window.BetterTTV = {
version: debug.version,
settings: (await import('./settings.js')).default,
emoteMenu: (await import('./common/api/emote-menu.js')).default,
watcher: {
emitLoad: (name) => watcher.emit(`load.${name}`),
},
};
})(document.currentScript);