forked from shreyamalogi/favicon-fetcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
260 lines (233 loc) · 5.92 KB
/
index.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Favicon Fetcher</title>
<style>
:root {
--baseColor: #606468;
}
.grid {
inline-size: 90%;
margin-inline: auto;
max-inline-size: 20rem;
display: grid;
}
.hidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.icon {
block-size: 1em;
display: inline-block;
fill: var(--iconFill);
inline-size: 1em;
vertical-align: middle;
}
:root {
--htmlFontSize: 100%;
--bodyBackgroundColor: #2c3338;
--bodyColor: var(--baseColor);
--bodyFontFamily: "Open Sans";
--bodyFontFamilyFallback: sans-serif;
--bodyFontSize: 0.875rem;
--bodyFontWeight: 400;
--bodyLineHeight: 1.5;
}
* {
box-sizing: inherit;
}
html {
box-sizing: border-box;
font-size: var(--htmlFontSize);
}
body {
background-color: #342d34;
color: white;
font-family: var(--bodyFontFamily), var(--bodyFontFamilyFallback);
font-size: var(--bodyFontSize);
font-weight: var(--bodyFontWeight);
line-height: var(--bodyLineHeight);
margin: 0;
min-block-size: 100vh;
display: grid;
place-items: center;
}
:root {
--anchorColor: #eee;
}
a {
color: var(--anchorColor);
outline: 0;
text-decoration: none;
}
a:focus,
a:hover {
text-decoration: underline;
}
:root {
--formGap: 0.875rem;
}
input {
background-image: none;
border: 0;
color: inherit;
font: inherit;
margin: 0;
outline: 0;
padding: 0;
transition: background-color 0.3s;
}
input[type="text"] {
background-image: none;
border: 0;
color: inherit;
font: inherit;
margin: 0;
outline: 0;
padding: 0;
transition: background-color 0.3s;
}
select,
option {
background-image: none;
border: 0;
color: inherit;
font: inherit;
margin: 0;
outline: 0;
padding: 0;
transition: background-color 0.3s;
}
input[type="submit"] {
cursor: pointer;
}
input[type="text"],
select,
option,
input[type="submit"] {
inline-size: 100%;
}
:root {
--loginBorderRadus: 0.25rem;
--loginColor: #eee;
--loginInputBackgroundColor: #3b4148;
--loginInputHoverBackgroundColor: #434a52;
--loginLabelBackgroundColor: #363b41;
--loginSubmitBackgroundColor: #ea4c88;
--loginSubmitColor: #eee;
--loginSubmitHoverBackgroundColor: #d44179;
}
input[type="text"],
select,
option,
input[type="submit"] {
border-radius: var(--loginBorderRadus);
padding: 1rem;
}
input[type="text"],
option,
select {
background-color: var(--loginInputBackgroundColor);
border-bottom-left-radius: 0;
border-top-left-radius: 0;
}
input[type="text"]:focus,
input[type="text"]:hover {
background-color: var(--loginInputHoverBackgroundColor);
}
input[type="submit"] {
background-color: #d75821;
color: var(--loginSubmitColor);
font-weight: 700;
text-transform: uppercase;
}
input[type="submit"]:focus,
input[type="submit"]:hover {
background-color: #d75821;
}
p {
margin-block: 1.5rem;
text-align: center;
}
img {
max-width: 100%;
max-height: 100%;
}
</style>
</head>
<body>
<script type="text/javascript">
function isValidURL(string) {
var res = string.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g);
return (res !== null)
}
function startIT() {
var myurl = document.getElementById("urltext").value;
if (myurl == "") {
alert("Please Enter URL");
}
else if (myurl !== "" && isValidURL(myurl) == true) {
grabFAV();
}
else {
alert("Please Enter Valid URL");
}
}
function grabFAV() {
var myurl = document.getElementById("urltext").value;
var myimg = document.getElementById("theimg");
var mysize = document.getElementById("size").value;
var duckapi = "https://icons.duckduckgo.com/ip3/";
var gapi = "https://s2.googleusercontent.com/s2/favicons?domain=";
if (mysize == "default") {
var h1 = "https://";
var h2 = "http://";
myurl = myurl.replace(h1, "");
myurl = myurl.replace(h2, "");
myimg.src = duckapi + myurl + ".ico";
}
else if (mysize == "16") {
myimg.src = gapi + myurl + "&sz=16";
}
else if (mysize == "32") {
myimg.src = gapi + myurl + "&sz=32";
}
else if (mysize == "48") {
myimg.src = gapi + myurl + "&sz=48";
}
else if (mysize == "64") {
myimg.src = gapi + myurl + "&sz=64";
}
else if (mysize == "128") {
myimg.src = gapi + myurl + "&sz=128";
}
}
</script>
<div class="grid">
<h2 align="center">Favicon Fetcher</h2>
<center> <img src="" id="theimg"></center><br>
<select id="size">
<option value="default">Default Size</option>
<option value="16">16x16</option>
<option value="32">32x32</option>
<option value="48">48x48</option>
<option value="64">64x64</option>
<option value="128">128x128</option>
</select><br><br>
<input type="text" placeholder="Enter URL" id="urltext">
<br><br>
<input type="submit" value="Fetch" onClick="startIT()">
<p>Developed By - <a href="">Shreya Malogi</a> | <a
href="https://www.linkedin.com/in/shreyamalogi/">LinkedIn</a></p>
</div>
</body>
</html>