-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
77 lines (63 loc) · 2.18 KB
/
content.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
// Example: Change the background color of the body to light yellow on Symplicity pages
document.body.style.backgroundColor = "lightyellow";
// You can also log some information to the console
console.log("Content script is running on Symplicity.");
// Listen for messages from popup.js
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
console.log("Message received in content.js:", request.message);
const response = {
jobTitle: getJobTitle().textContent,
jobEmployer: getJobEmployer().textContent,
datePosted: getDatePosted().textContent,
jobLocation: getJobLocation().textContent,
jobDescription: getJobDescription().textContent,
additionalDetails: getAdditionalDetails(),
};
console.log(response);
// Do something with the message and send a response
sendResponse({ message: response });
});
function getJobTitle() {
return document.querySelector("a.job-title.ng-star-inserted");
}
function getJobEmployer() {
return document.querySelector("a.text-base.font-size-base");
}
function getDatePosted() {
return document.querySelector(
"span.header-title-label.body-small.secondary-text.display-md-none.display-lg-none.display-desktop-none.ng-star-inserted"
);
}
function getJobLocation() {
return document.querySelector(
'span.body-small[ng-reflect-ng-class="body-small"]'
);
}
function getJobDescription() {
return document.querySelector(
"div.text-overflow.space-top-lg.text-gray.p-group.field-widget-tinymce"
);
}
function getAdditionalDetails() {
containers = getAdditionalDetailsContainers();
return containers.map((container) => {
return {
name: getAdditionalDetailName(container),
value: getAdditionalDetailValue(container),
};
});
}
function getAdditionalDetailsContainers() {
containers = document.querySelectorAll(".form-static-list");
return Array.from(containers);
}
function getAdditionalDetailName(container) {
return container.querySelector(
".field-label.field-label-readonly.ng-star-inserted"
).textContent;
}
function getAdditionalDetailValue(container) {
return container.querySelector(
".field-widget.widget-readonly.field-widget-text"
).textContent;
}