-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontent.js
More file actions
38 lines (31 loc) · 1.04 KB
/
Copy pathcontent.js
File metadata and controls
38 lines (31 loc) · 1.04 KB
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
chrome.runtime.onMessage.addListener((message) => {
if(message.type === "CHECK_PROBLEM"){
sendProblemData();
}
})
function sendProblemData(){
const titleElement = document.querySelector('div.text-title-large');
const difficultyElement = document.querySelector('div[class*="text-difficulty"]');
if(titleElement){
const problemName = titleElement.innerText.trim();
let difficulty = "Unknown";
if(difficultyElement){
const diffText = difficultyElement.innerText.trim();
if(diffText.includes("Easy")){
difficulty = "Easy";
} else if(diffText.includes("Medium")){
difficulty = "Medium";
} else if(diffText.includes("Hard")){
difficulty = "Hard";
}
}
chrome.runtime.sendMessage({
type: "PROBLEM_DATA",
name: problemName,
difficulty: difficulty
})
}
else{
setTimeout(sendProblemData, 500);
}
}