forked from kmather73/CanadianTech
-
Notifications
You must be signed in to change notification settings - Fork 2
/
levelsfyi-dom-script.js
executable file
·50 lines (47 loc) · 1.58 KB
/
levelsfyi-dom-script.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
let levels = {};
const getFirstLine = (el) => el.innerText.split("\n")[0];
const DECENCY_THRESHOLD = 150; //K
const getComp = (el) => {
const [total, _, breakdown] = el.innerText.split("\n");
const [base, stock, bonus] = breakdown.split(" | ");
return { total, breakdown: { base, stock, bonus } };
};
async function getLevels() {
const allDropdowns = document.querySelectorAll("svg.fa-angle-down");
const allTableNodes = [...allDropdowns].map(
(e) => e.parentElement.parentElement.parentElement,
);
const allRows = allTableNodes.filter((e) => e.nodeName === "TR");
const allRowsWithCells = allRows.map((e) => [...e.childNodes]);
const entryTds = allRowsWithCells.map(([name, level, tenure, comp]) => ({
name: getFirstLine(name),
level: getFirstLine(level),
tenure: getFirstLine(tenure),
comp: getComp(comp),
}));
const worthwhileTds = entryTds.filter(
(e) => parseInt(e.comp.total.replaceAll(",", "").replace('$', '')) >= DECENCY_THRESHOLD,
);
return (levels = {
...levels,
...Object.fromEntries(
await Promise.all(
worthwhileTds.map(async ({ name, comp }, i) => [
name,
{
salaryStr: `${comp.total}: ${comp.breakdown.base} - ${comp.breakdown.stock} - ${comp.breakdown.bonus}`,
link: "use chat gpt to find links",
},
]),
),
),
});
}
let getLevelsStr = async () =>
Object.entries(await getLevels())
.map(
(e) =>
"| " + [`[${e[0]}](${e[1].link})`, e[1].salaryStr].join(" | ") + " |",
)
.join("\n");
getLevelsStr().then((str) => console.log(str));