forked from caracal-js/Incognito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload.html
36 lines (33 loc) · 1.09 KB
/
load.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
<!DOCTYPE html>
<html>
<head>
<script src="./uv/uv.bundle.js"></script>
<script src="./uv/uv.config.js"></script>
</head>
<body>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./uv.sw-handler.js', {
scope: __uv$config.prefix
}).then(() => {
let url = atob(
decodeURIComponent(window.location.hash.slice(1))
);
if (!isUrl(url)) url = 'https://www.google.com/search?q=' + url;
else if (!(url.startsWith('https://') || url.startsWith('http://'))) {
url = 'http://' + url;
};
window.location.href = __uv$config.prefix + __uv$config.encodeUrl(
url
);
});
} else {
parent.postMessage('sw-no-register');
};
function isUrl(val = ''){
if (/^http(s?):\/\//.test(val) || val.includes('.') && val.substr(0, 1) !== ' ') return true;
return false;
};
</script>
</body>
</html>