-
Notifications
You must be signed in to change notification settings - Fork 3
/
_generate_variables.js
63 lines (55 loc) · 1.77 KB
/
_generate_variables.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Go to /en/docs and paste this script.
function fetchResult(variable) {
console.log([...variable].join(","));
}
function consoleVariable(title, variables) {
if (variables.size > 0) {
console.log(`%c${title}:`, "color: blue");
fetchResult(variables);
}
}
function collectVariables() {
const colaspedDocs = document.getElementsByClassName("accordion-button");
for (let i = 0; i < colaspedDocs.length; i++) {
colaspedDocs[i].click();
}
const hourlyVariables = new Set();
const dailyVariables = new Set();
const currentVariables = new Set();
setTimeout(() => {
const formDocs = document.getElementsByClassName("form-check-input");
for (let i = 0; i < formDocs.length; i++) {
if (formDocs[i].getAttribute("name") === "hourly") {
hourlyVariables.add(formDocs[i].getAttribute("value"));
}
if (formDocs[i].getAttribute("name") === "daily") {
dailyVariables.add(formDocs[i].getAttribute("value"));
}
if (formDocs[i].getAttribute("name") === "current") {
currentVariables.add(formDocs[i].getAttribute("value"));
}
}
consoleVariable("Hourly", hourlyVariables);
consoleVariable("Daily", dailyVariables);
consoleVariable("Current", currentVariables);
}, 1000);
}
const docPages = [
"/en/docs",
"/en/docs/historical-weather-api",
"/en/docs/ensemble-api",
"/en/docs/climate-api",
"/en/docs/marine-weather-api",
"/en/docs/air-quality-api",
"/en/docs/flood-api"
];
for (let page = 0; page < docPages.length; page++) {
setTimeout(() => {
const button = document.querySelector(`a[href="${docPages[page]}"]`);
button.click();
console.log(`%c${button.innerText}`, "color: green; font-size: 20px");
setTimeout(() => {
collectVariables();
}, 1000);
}, 3000 * page);
}