-
Notifications
You must be signed in to change notification settings - Fork 0
/
external.html
46 lines (41 loc) · 1.55 KB
/
external.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
// Function to get URL parameters
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
// Function to fetch the redirect URL
async function redirectToUrl() {
const urlParam = getUrlParameter('url');
if (urlParam) {
try {
const response = await fetch('urls.json');
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
const redirectUrl = data[urlParam];
if (redirectUrl) {
window.location.href = redirectUrl; // Redirecting to the URL
} else {
console.error(`No URL found for "${urlParam}"`);
}
} catch (error) {
console.error('There was a problem fetching the data: ' + error.message);
}
}
}
// Redirect when the window loads
window.onload = redirectToUrl;
</script>
</head>
<body>
</body>
</html>