-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
116 lines (96 loc) · 2.69 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Microlink Query Language</title>
<link rel="shortcut icon" href="https://cdn.microlink.io/logo/favicon.ico" type="image/x-icon" />
<style>
body {
zoom: 120%;
margin: 1rem;
background-color: #f8f9fa;
}
code {
font-size: 16px;
white-space: pre-wrap;
}
samp {
color: #868e96;
}
output {
color: #15141A;
}
div {
margin-top: 12px;
margin-bottom: 12px;
border-bottom: 1px solid #dee2e6;
}
</style>
</head>
<body>
<pre><code id="devtools"></code></pre>
<script>
const log = console.log
const devTools = document.getElementById("devtools")
const writeLog = el => str => {
const node = document.createElement(el)
const line = document.createElement("div")
node.appendChild(document.createTextNode(str))
devTools.appendChild(node).appendChild(line)
log(str)
}
window.console = {
log: function (str) {
const node = document.createElement("output")
const line = document.createElement("div")
node.appendChild(document.createTextNode(str))
devTools.appendChild(node).appendChild(line)
log(str)
}
}
window.console = {
log: writeLog('output'),
debug: writeLog('samp')
}
</script>
<script type="module">
import mql from './lightweight/index.js'
function getBrowser() {
var ua = navigator.userAgent,
tem, M = ua.match(
/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if (/trident/i.test(M[1])) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return {
name: 'IE',
version: (tem[1] || '')
};
}
if (M[1] === 'Chrome') {
tem = ua.match(/\bOPR|Edge\/(\d+)/)
if (tem != null) {
return {
name: 'Opera',
version: tem[1]
};
}
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+)/i)) != null) {
M.splice(1, 1, tem[1]);
}
return `${M[0]} v${M[1]}`
}
const query = Object.fromEntries(new URL(document.location).searchParams)
console.log(`MQL v${mql.version} at ${getBrowser()}`)
const stderr = (payload) => console.debug(JSON.stringify(payload, null, 2))
const { url = 'https://example.com' } = query
mql(url).then(({
response,
...payload
}) => stderr(payload)).catch(stderr)
</script>
</body>
</html>