-
Notifications
You must be signed in to change notification settings - Fork 43
/
redirect.html
180 lines (180 loc) · 9.03 KB
/
redirect.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Obtainium Redirect</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="/data/style.css" rel="stylesheet" >
<link rel="icon" href="https://raw.githubusercontent.com/ImranR98/Obtainium/main/assets/graphics/icon_small.png">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f8f9fa;
}
.btn-primary {
background-color: #007bff;
border-color: #007bff;
color: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<div class="container text-center">
<noscript>
Enable JavaScript in your browser to redirect to Obtainium
</noscript>
<div id="error" class="alert alert-danger mt-5" style="display: none;">
</div>
<div id="redirecting" class="alert alert-info mt-5 justify-content-center" style="display: none;">
<p style="font-size: 20px;">Redirecting to Obtainium…</p>
<button id="redirectBtn" class="btn btn-primary" style="padding: 10px 20px; font-size: 18px;">Click here if you are not redirected</button>
</div>
<div id="appLink" class="mt-5" style="display: none;">
Don't have Obtainium? Visit <span id="appName">the app's</span> home page <a id="appLinkHref" href="#">here</a>.
</div>
<div id="downloadLink" class="mt-5" style="display: none;">
OR, <a href="https://github.com/ImranR98/Obtainium/releases/latest">download Obtainium here</a>.
</div>
<div id="homeLink" class="mt-5" style="display: none;">
OR, <a href="/">browse the full app list here</a>.
</div>
</div>
<script>
window.onload = function() {
var urlParams = new URLSearchParams(window.location.search);
var redirectUrl = urlParams.get('r');
if (redirectUrl && (redirectUrl.startsWith('obtainium://app/') || redirectUrl.startsWith('obtainium://add/'))) {
try {
var appData = {};
if (redirectUrl.startsWith('obtainium://app/')) {
appData = JSON.parse(decodeURIComponent(redirectUrl.replace('obtainium://app/', '')));
redirectUrl = "obtainium://app/" + encodeURIComponent(JSON.stringify(appData));
} else if (redirectUrl.startsWith('obtainium://add/')) {
appData.url = decodeURIComponent(redirectUrl.replace('obtainium://add/', ''));
var urlPattern = new RegExp('^(http://|https://)');
if (!urlPattern.test(appData.url)) {
throw new Error;
}
redirectUrl = "obtainium://add/" + appData.url;
}
document.getElementById('redirecting').style.display = 'block';
window.location.href = redirectUrl;
document.getElementById('redirectBtn').onclick = function() {
window.location.href = redirectUrl;
};
document.getElementById('appLink').style.display = 'block';
document.getElementById('downloadLink').style.display = 'block';
document.getElementById('homeLink').style.display = 'block';
var appLinkHref = document.getElementById('appLinkHref');
appLinkHref.href = appData.url;
if (appData.name) {
document.getElementById('appName').textContent = appData.name + "'s";
}
} catch (e) {
document.getElementById('error').style.display = 'block';
document.getElementById('error').textContent = 'Invalid URL. Valid app URL could not be found.';
}
} else {
document.getElementById('error').style.display = 'block';
document.getElementById('error').textContent = 'Invalid URL. Redirect should be provided and start with "obtainium://add/" or "obtainium://app/".';
}
};
</script>
</body>
</html>
<!-- TODO: Implement translations as done on the main page. The below method causes problems (#47) -->
<!-- <!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weiterleitungsseite zu Obtainium</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="icon" href="https://raw.githubusercontent.com/ImranR98/Obtainium/main/assets/graphics/icon_small.png">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f8f9fa;
}
.btn-primary {
background-color: #007bff;
border-color: #007bff;
color: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<div class="container text-center">
<noscript>
Aktiviere Java-Skript in deinem Browser, um zu Obtanium weitergeleitet zu werden.
</noscript>
<div id="error" class="alert alert-danger mt-5" style="display: none;">
</div>
<div id="redirecting" class="alert alert-info mt-5 justify-content-center" style="display: none;">
<p style="font-size: 20px;">Weiterleitung zu Obtainium…</p>
<button id="redirectBtn" class="btn btn-primary" style="padding: 10px 20px; font-size: 18px;">Klicke hier, wenn du noch nicht weitergeleitet wurdest.</button>
</div>
<div id="appLink" class="mt-5" style="display: none;">
<div id="appLink" class="mt-5" style="display: none;">
Hast du noch nicht Obtainium? Besuche <span id="appName">unsere</span> <a id="appLinkHref" href="#">home page</a>,
</div>
<div id="downloadLink" class="mt-5" style="display: none;">
oder <a href="https://github.com/ImranR98/Obtainium/releases/latest">lade Obtainium hier herunter</a>,
</div>
<div id="homeLink" class="mt-5" style="display: none;">
oder <a href="/">durchsuche unsere App-Konfigurationsliste</a>.
</div>
</div>
<script>
window.onload = function() {
var urlParams = new URLSearchParams(window.location.search);
var redirectUrl = urlParams.get('r');
if (redirectUrl && (redirectUrl.startsWith('obtainium://app/') || redirectUrl.startsWith('obtainium://add/'))) {
try {
var appData = {};
if (redirectUrl.startsWith('obtainium://app/')) {
appData = JSON.parse(decodeURIComponent(redirectUrl.replace('obtainium://app/', '')));
redirectUrl = "obtainium://app/" + encodeURIComponent(JSON.stringify(appData));
} else if (redirectUrl.startsWith('obtainium://add/')) {
appData.url = decodeURIComponent(redirectUrl.replace('obtainium://add/', ''));
var urlPattern = new RegExp('^(http://|https://)');
if (!urlPattern.test(appData.url)) {
throw new Error;
}
redirectUrl = "obtainium://add/" + appData.url;
}
document.getElementById('redirecting').style.display = 'block';
window.location.href = redirectUrl;
document.getElementById('redirectBtn').onclick = function() {
window.location.href = redirectUrl;
};
document.getElementById('appLink').style.display = 'block';
document.getElementById('downloadLink').style.display = 'block';
document.getElementById('homeLink').style.display = 'block';
var appLinkHref = document.getElementById('appLinkHref');
appLinkHref.href = appData.url;
if (appData.name) {
document.getElementById('appName').textContent = appData.name + "'s";
}
} catch (e) {
document.getElementById('error').style.display = 'block';
document.getElementById('error').textContent = 'Invalide URL. Keine valide URL gefunden.';
}
} else {
document.getElementById('error').style.display = 'block';
document.getElementById('error').textContent = 'Invalide URL. Eine Umleitung sollte, startend mit "obtainium://add/" oder "obtainium://app/", eingerichtet werden.';
}
};
</script>
</body>
</html>
<!DOCTYPE html> -->