-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMediasCollector.js
49 lines (46 loc) · 1.31 KB
/
MediasCollector.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
// Run this script in the browser on https://www.iana.org/assignments/media-types/media-types.xhtml#application
const validTypes = [
"application",
"audio",
"font",
"image",
"message",
"model",
"multipart",
"text",
"video",
];
JSON.stringify(validTypes
.map(type => [type, `table-${type}`])
.map(([type, id]) => [type, document.getElementById(id)])
.map(([type, table]) => [type, table.querySelector('tbody')])
.map(([type, tbody]) => [
type,
Array
.from(tbody.rows)
.map(row => row.cells[0].textContent.trim())
.map(subtype => subtype.split(" ")[0])
])
.reduce((accumulator, [type, subtypes]) => ({
...accumulator,
[type]: (accumulator.type || []).concat(subtypes)
}), {
application: [],
audio: [],
font: [],
image: [],
message: [],
model: [],
multipart: [],
text: [],
video: []
})
)
// Run this script in the browser on https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xml
JSON.stringify(
Array.from(document.querySelectorAll('td'))
.filter(td => /^\+/.test(td.textContent))
.map(td => td.textContent)
.filter(s => !s.includes(' '))
.map(s => s.trim())
)