-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3pc-public.html
69 lines (58 loc) · 1.65 KB
/
3pc-public.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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- <script src="https://drive.google.com/uc?export=download&authuser=0&id=1WaI7N7Izz_6FszuvVjZV5u8WTk-NSVhR&callback=getJsonCallback"></script> -->
</head>
<body>
<div>Check the console for messages</div>
</body>
<script>
var loadJSONP1 = (function(){
var unique = 0;
return function(url, callback, context) {
// INIT
var name = "_jsonp_" + unique++;
if (url.match(/\?/)) url += "&callback="+name;
else url += "?callback="+name;
console.log(url);
// Create script
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
// Setup handler
window[name] = function(data){
callback.call((context || window), data);
document.getElementsByTagName('head')[0].removeChild(script);
script = null;
delete window[name];
};
// Load JSON
document.getElementsByTagName('head')[0].appendChild(script);
};
})();
const fetchJSONP = (unique => url =>
new Promise(rs => {
const script = document.createElement('script');
const name = `_jsonp_${unique++}`;
if (url.match(/\?/)) {
url += `&callback=${name}`;
} else {
url += `?callback=${name}`;
}
script.src = url;
window[name] = json => {
rs(new Response(JSON.stringify(json)));
script.remove();
delete window[name];
};
document.body.appendChild(script);
})
)(0);
loadJSONP(
'https://drive.google.com/uc?export=download&authuser=0&id=1WaI7N7Izz_6FszuvVjZV5u8WTk-NSVhR&callback=getJsonCallback',
function(data) {
console.log(data);
}
);
</script>
</html>