Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Degen-dev
GitHub Repository: Degen-dev/Degeneracy
Path: blob/master/public/scripts/index.js
3950 views
1
const form = document.querySelector('form');
2
const input = document.querySelector('input');
3
4
form.addEventListener('submit', async event => {
5
event.preventDefault();
6
window.navigator.serviceWorker.register('./sw.js', {
7
scope: __uv$config.prefix
8
}).then(() => {
9
let url = input.value.trim();
10
if (!isUrl(url)) url = 'https://searx.degenerate.info/search?q=' + url;
11
else if (!(url.startsWith('https://') || url.startsWith('http://'))) url = 'http://' + url;
12
13
14
window.location.href = __uv$config.prefix + __uv$config.encodeUrl(url);
15
});
16
});
17
18
function isUrl(val = ''){
19
if (/^http(s?):\/\//.test(val) || val.includes('.') && val.substr(0, 1) !== ' ') return true;
20
return false;
21
};
22