misskey/src/web/app/client/script.js

27 lines
927 B
JavaScript
Raw Normal View History

2016-12-28 23:49:51 +01:00
const head = document.getElementsByTagName('head')[0];
const ua = navigator.userAgent.toLowerCase();
const isMobile = /mobile|iphone|ipad|android/.test(ua);
2017-02-19 04:31:23 +01:00
isMobile ? mountMobile() : mountDesktop();
2016-12-28 23:49:51 +01:00
function mountDesktop() {
const script = document.createElement('script');
script.setAttribute('src', '/_/resources/desktop/script.js');
script.setAttribute('async', 'true');
script.setAttribute('defer', 'true');
head.appendChild(script);
}
function mountMobile() {
const meta = document.createElement('meta');
meta.setAttribute('name', 'viewport');
meta.setAttribute('content', 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no');
head.appendChild(meta);
const script = document.createElement('script');
script.setAttribute('src', '/_/resources/mobile/script.js');
script.setAttribute('async', 'true');
script.setAttribute('defer', 'true');
head.appendChild(script);
}