-
Notifications
You must be signed in to change notification settings - Fork 41
/
index.html
66 lines (55 loc) · 2.24 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
<!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">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<title>Google API Code Extractor</title>
</head>
<body>
<!-- Print JS scrip output here -->
<div id="input">
<h1>Google API Code Extractor</h1>
<p>Enter the URL of the Google API page you want to extract the code from.</p>
<input type="text" id="url" placeholder="Enter URL">
<button id="submit">Submit</button>
</div>
<div id="output">
<p>The Clean URL: "<span id="clean_url"></span>"</p>
<p>The Code: "<span id="code"></span>"</p>
<p>The State: "<span id="state"></span>"</p>
<p>The Scope: "<span id="scope"></span>"</p>
</div>
</body>
<script>
function parseURLParams(url) {
var queryStart = url.indexOf("?") + 1,
queryEnd = url.indexOf("#") + 1 || url.length + 1,
query = url.slice(queryStart, queryEnd - 1),
pairs = query.replace(/\+/g, " ").split("&"),
parms = {}, i, n, v, nv;
if (query === url || query === "") return;
for (i = 0; i < pairs.length; i++) {
nv = pairs[i].split("=", 2);
n = decodeURIComponent(nv[0]);
v = decodeURIComponent(nv[1]);
if (!parms.hasOwnProperty(n)) parms[n] = [];
parms[n].push(nv.length === 2 ? v : null);
}
return {'url': decodeURIComponent(url), 'parms': parms};
}
$(document).ready(function(){
$("#submit").click(function(){
var url = document.getElementById('url').value;
console.log(url);
var url = parseURLParams(url);
document.getElementById("clean_url").innerHTML = url.url;
document.getElementById("code").innerHTML = url.parms.code;
document.getElementById("state").innerHTML = url.parms.state;
document.getElementById("scope").innerHTML = url.parms.scope;
document.getElementById('url').value = "";
});
});
</script>
</html>