-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
64 lines (64 loc) · 2.16 KB
/
index.html
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
<html>
<head>
<script type="text/javascript">
const appstore =
"https://apps.apple.com/app/apple-store/id1464614025?pt=118781877&mt=8&ct=";
// const playstore =
// "https://play.google.com/store/apps/details?id=com.myetherwallet.mewwallet&referrer=utm_source%3D";
const playstore =
"market://launch?id=com.myetherwallet.mewwallet&referrer=utm_source%3D";
const defaultUrl = "https://www.mewwallet.com/?referrer=";
const activityUrl = "https://download.mewwallet.dev/record";
const GENERIC_SHARE = "sharefriend";
const SOURCE = "source";
const getSource = () => {
const url = new URL(document.URL);
if (!url.searchParams.has(SOURCE)) return false;
else return url.searchParams.get(SOURCE);
};
const isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function () {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function () {
return navigator.userAgent.match(/IEMobile/i);
},
any: function () {
return (
isMobile.Android() ||
isMobile.BlackBerry() ||
isMobile.iOS() ||
isMobile.Opera() ||
isMobile.Windows()
);
},
};
const doTheRedirect = (url, platform, utm) => {
if (!fetch) document.location.href = `${url}${utm}`;
else
fetch(`${activityUrl}?platform=${platform}&utm=${utm}`).finally(
() => {
document.location.href = `${url}${utm}`;
}
);
};
const utm = getSource() ? getSource() : GENERIC_SHARE;
if (isMobile.Android()) {
doTheRedirect(playstore, "android", utm);
} else if (isMobile.iOS()) {
doTheRedirect(appstore, "ios", utm);
} else {
doTheRedirect(defaultUrl, "web", utm);
}
</script>
</head>
</html>