-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjetbrains.js
96 lines (94 loc) · 3.79 KB
/
jetbrains.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
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
function getProductCodes() {
const productCodes = [];
$.getJSON("https://data.services.jetbrains.com/products", {
"fields": ["name", "salesCode"].join(",")
}).then((response) => {
const products = document.getElementById("products");
const tr = document.createElement("tr");
const th1 = document.createElement("th");
th1.innerText = "Author Name";
tr.appendChild(th1);
const th2 = document.createElement("th");
th2.innerText = "Product Name";
tr.appendChild(th2);
const th3 = document.createElement("th");
th3.innerText = "Product Code";
tr.appendChild(th3);
products.appendChild(tr);
for (let i = 0; i < response.length; i++) {
if (response[i].salesCode != null) {
productCodes.push(response[i].salesCode);
const tr = document.createElement("tr");
const td1 = document.createElement("td");
td1.innerText = "JetBrains s.r.o.";
tr.appendChild(td1);
const td2 = document.createElement("td");
td2.innerText = response[i].name;
tr.appendChild(td2);
const td3 = document.createElement("td");
td3.innerText = response[i].salesCode;
tr.appendChild(td3);
products.appendChild(tr);
}
}
});
return productCodes;
}
function getPluginProductCodes() {
const productCodes = [];
$.getJSON("https://plugins.jetbrains.com/api/searchPlugins", {
"max": 10000,
"offset": 0,
"search": ""
}).then((response) => {
const products = document.getElementById("products");
const tr = document.createElement("tr");
const th1 = document.createElement("th");
th1.innerText = "Author Name";
tr.appendChild(th1);
const th2 = document.createElement("th");
th2.innerText = "Product Name";
tr.appendChild(th2);
const th3 = document.createElement("th");
th3.innerText = "Product Code";
tr.appendChild(th3);
products.appendChild(tr);
for (let i = 0; i < response.plugins.length; i++) {
if (response.plugins[i].pricingModel === "FREE") {
continue;
}
$.getJSON("https://plugins.jetbrains.com/api/plugins/" + response.plugins[i].id).then((response) => {
const authorName = response.vendor.publicName !== undefined ? response.vendor.publicName : response.vendor.name;
if (authorName === "JetBrains s.r.o.") {
productCodes.push(response.purchaseInfo.productCode);
}
const tr = document.createElement("tr");
const td1 = document.createElement("td");
td1.innerText = authorName;
tr.appendChild(td1);
const td2 = document.createElement("td");
td2.innerText = response.name;
tr.appendChild(td2);
const td3 = document.createElement("td");
td3.innerText = response.purchaseInfo.productCode;
tr.appendChild(td3);
products.appendChild(tr);
});
}
});
return productCodes;
}
window.onload = function () {
const productCodes = getProductCodes();
const pluginProductCodes = getPluginProductCodes();
setTimeout(() => {
document.getElementById("product_codes").innerText =
Array.from(productCodes).sort().map(item => '"' + item + '"').toString() +
"\n" +
productCodes.length +
"\n" +
Array.from(pluginProductCodes).sort().map(item => '"' + item + '"').toString() +
"\n" +
pluginProductCodes.length;
}, 10000);
}