mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2025-01-10 23:51:01 -07:00
More readability
This commit is contained in:
parent
473f08a8c9
commit
18166d84f8
1 changed files with 9 additions and 1 deletions
|
@ -13,10 +13,16 @@
|
||||||
// Get the current url information
|
// Get the current url information
|
||||||
const Url = new URL(location.href);
|
const Url = new URL(location.href);
|
||||||
|
|
||||||
// Extarct the (sub) domain part
|
// Extarct the (sub) domain part of the current url
|
||||||
|
//
|
||||||
|
// e.g.
|
||||||
|
// misskey.alice => misskey
|
||||||
|
// misskey.strawberry.pasta => misskey
|
||||||
|
// dev.misskey.alice.tachibana => dev
|
||||||
let app = Url.host.split('.')[0];
|
let app = Url.host.split('.')[0];
|
||||||
|
|
||||||
// Detect user language
|
// Detect user language
|
||||||
|
// Note: The default language is English
|
||||||
let lang = navigator.language.split('-')[0];
|
let lang = navigator.language.split('-')[0];
|
||||||
if (!/^(en|ja)$/.test(lang)) lang = 'en';
|
if (!/^(en|ja)$/.test(lang)) lang = 'en';
|
||||||
|
|
||||||
|
@ -41,6 +47,8 @@ if (app == 'misskey') {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load app script
|
// Load app script
|
||||||
|
// Note: 'async' makes can load the script async.
|
||||||
|
// 'defer' makes can run script when the dom loaded.
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
script.setAttribute('src', `/assets/${app}.${VERSION}.${lang}.js`);
|
script.setAttribute('src', `/assets/${app}.${VERSION}.${lang}.js`);
|
||||||
script.setAttribute('async', 'true');
|
script.setAttribute('async', 'true');
|
||||||
|
|
Loading…
Reference in a new issue