-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
50 lines (45 loc) · 1.34 KB
/
script.js
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
const sb = document.getElementById('sb');
const link = document.getElementById('link');
let urlbox = document.getElementById('urlbox');
let colorValue = JSON.parse(localStorage.getItem("colorvalue"));
let usehttp = JSON.parse(localStorage.getItem("usehttp"));
if (usehttp == null){
usehttp = false;
localStorage.setItem("usehttp",JSON.stringify(false));
}
function go(){
if(urlbox.value.startsWith("http") == false){
if (usehttp){
urlbox.value = "http://"+urlbox.value;
link.href = urlbox.value;
}else{
urlbox.value = "https://"+urlbox.value;
link.href = urlbox.value;
}
}else {
link.href = urlbox.value;
}
}
urlbox.addEventListener("keypress",function (event){
if (event.key == "Enter"){
if(urlbox.value.startsWith("http") == false){
if (usehttp){
urlbox.value = "http://"+urlbox.value;
link.href = urlbox.value;
sb.click()
}else{
urlbox.value = "https://"+urlbox.value;
link.href = urlbox.value;
sb.click()
}
}else {
link.href = urlbox.value;
sb.click()
}
}
})
body.style.backgroundColor = colorValue;
if (colorValue == null){
colorValue = "#000000";
}
sb.onclick = go;