-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathn2csv.js
120 lines (107 loc) · 3.34 KB
/
n2csv.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
let printInReverse = false;
function showAllContactDetails() {
$(".showContactContainerBtn").click();
}
function parseApplicantList(count = 1000) {
output = ``;
tuples = $("div.tuple");
if (printInReverse) {
for (i = tuples.length - 1; i >= 0; i--) {
output += parseApplicantTuple(tuples[i]);
}
} else {
for (i = 0; i < tuples.length && i < count; i++) {
output += parseApplicantTuple(tuples[i]);
}
}
return output;
}
function parseApplicantTuple(container) {
fname = email = phone = experience = curloc = availability = salary = current = prefloc = education = skills = 'MISSING';
try {
fname = $(".candidate-name", container)[0].innerText;
fname = fname.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
overview = $(".candidate-overview", container);
experience = $("span.ore-work ~ span.info-text", overview)
.map(function () {
return this.innerText;
})
.toArray()
.join(", ");
curloc = $("span.ore-location_filled ~ span.info-text", overview)
.map(function () {
return this.innerText;
})
.toArray()
.join(", ");
availability = $("span.ore-timer ~ span.info-text", overview)
.map(function () {
return this.innerText;
})
.toArray()
.join(", ");
salary = $("span.ore-salary ~ span.info-text", overview)
.map(function () {
return this.innerText;
})
.toArray()
.join(", ");
if (salary == "") salary = "-";
if (curloc == "") curloc = "-";
if (experience == "") experience = "-";
if (availability == "") availability = "-";
availability = availability.replace("Available to join in ", "");
email = phone = "-";
email = $(".showContactContainerEmail", container)
.map(function () {
return this.innerText;
})
.toArray()
.join(", ");
phone = $(".showContactContainerPhone", container)
.map(function () {
return this.innerText;
})
.toArray()
.join(", ");
details = $(".candidate-details > .detail", container);
current = prefloc = education = skills = "-";
for (j = 0; j < details.length; j++) {
title = $("label", details[j])[0].innerText.trim();
info = $("span", details[j])[0]
.innerText.trim()
.replace(/(?:\r\n|\r|\n)/g, ",");
if (title == "Current") current = info;
if (title == "Key skills") skills = info;
if (title == "Education") education = info;
if (title == "Pref. Locations") prefloc = info;
}
if(phone.length == 12 && phone.startsWith("91")) phone = phone.substr(2);
} catch(e) {
}
line = `${fname}\t${email}\t${phone}\t${experience}\t${curloc}\t${availability}\t${salary}\t${current}\t${prefloc}\t${education}\t${skills}\n`;
return line;
}
function printApplicantList() {
// Scroll is necessary to load all data and avoid errors
steps = 20;
currentStep =
(window.scrollY * steps) /
(document.body.scrollHeight - window.innerHeight);
if (currentStep > steps - 1) {
let pathname = window.location.pathname;
if (pathname.endsWith("/rmjapplies") || pathname.endsWith("/applies")) {
showAllContactDetails();
}
output = parseApplicantList();
console.log(output);
} else {
window.scrollTo({
top: scrollY + document.body.scrollHeight / steps,
behavior: "smooth",
});
setTimeout(printApplicantList, 1000);
}
}