-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_page.js
55 lines (45 loc) · 2.25 KB
/
user_page.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
(function() {
setInterval(() => {
// Check if the current page URL is https://play.picoctf.org/users/*
if (window.location.href.includes('https://play.picoctf.org/users/')) {
// Define score mapping
const scoreMapping = {
'Easy': 100,
'Medium': 200,
'Hard': 500
};
let totalScore = 0;
const challengeSolvedDiv = document.querySelector('.text-nowrap.d-flex.flex-column.align-items-center.col');
if (challengeSolvedDiv) {
// Find each challenge difficulty level
const difficultySpans = challengeSolvedDiv.querySelectorAll('span');
difficultySpans.forEach(span => {
const text = span.textContent.trim();
const [count, difficulty] = text.split(' ');
const challengeCount = parseInt(count);
if (scoreMapping[difficulty]) {
totalScore += challengeCount * scoreMapping[difficulty];
}
});
// Find the body of the picoGym Progress card
const picoGymCardBody = document.querySelector('.card-body h4');
if (picoGymCardBody) {
// Create and insert a new score display element
const scoreDisplay = document.createElement('div');
scoreDisplay.classList.add('picoGym-score'); // Add class name to avoid duplication
scoreDisplay.style.textAlign = 'center';
scoreDisplay.style.marginTop = '20px';
scoreDisplay.style.fontSize = '24px';
scoreDisplay.style.fontWeight = 'bold';
scoreDisplay.style.color = '#6C63FF'; // Purple color
scoreDisplay.innerText = `picoGym Score: ${totalScore}`;
if (!document.querySelector('.picoGym-score')) {
picoGymCardBody.parentElement.appendChild(scoreDisplay);
} else {
document.querySelector('.picoGym-score').innerText = `picoGym Score: ${totalScore}`;
}
}
}
}
}, 1000);
})();