forked from plz-graduate/KW-Graduation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentscript.js
85 lines (81 loc) · 2.58 KB
/
contentscript.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
// 버튼 생성 및 스타일 설정
var button = document.createElement("button");
button.textContent = "졸업 가능 확인";
button.style.padding = "10px";
button.style.backgroundColor = "white";
button.style.color = "#3a051f";
button.style.border = "none";
button.style.borderRadius = "10px";
button.style.marginRight = "5px";
// 버튼 클릭 이벤트 핸들러
button.addEventListener("click", function () {
fetch("https://klas.kw.ac.kr/std/cps/inqire/AtnlcScreHakjukInfo.do", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({}),
})
.then((response) => response.json())
.then((jsonData) => {
const hakgwa = jsonData.hakgwa.split(" ")[0];
const hakbun = jsonData.hakbun.toString().slice(2, 4);
switch (hakgwa) {
case "정보융합학부":
chrome.runtime.sendMessage({
action: "openNewTab",
hakgwa: "정보융합학부",
hakbun: hakbun,
});
break;
case "전자공학과":
chrome.runtime.sendMessage({
action: "openNewTab",
hakgwa: "전자공학과",
hakbun: hakbun,
});
break;
case "소프트웨어학부":
chrome.runtime.sendMessage({
action: "openNewTab",
hakgwa: "소프트웨어학부",
hakbun: hakbun,
});
break;
default:
console.log("해당 학과 정보를 찾을 수 없습니다.");
}
});
});
var button1 = document.createElement("button");
button1.textContent = "성적 계산기";
button1.style.padding = "10px";
button1.style.backgroundColor = "white";
button1.style.color = "#3a051f";
button1.style.border = "none";
button1.style.borderRadius = "10px";
button1.style.marginRight = "5px";
button1.addEventListener("click", function () {
fetch("https://klas.kw.ac.kr/std/cps/inqire/AtnlcScreHakjukInfo.do", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({}),
})
.then((response) => response.json())
.then((jsonData) => {
const hakbun = jsonData.hakbun.toString().slice(2, 4);
chrome.runtime.sendMessage({
action: "openNewTab",
hakgwa: "성적계산기",
hakbun: hakbun,
});
});
});
// 버튼을 삽입할 요소 선택
var targetElement = document.querySelector(".col-md-6.navtxt");
if (targetElement) {
targetElement.prepend(button1); // 성적 계산기 버튼 먼저 삽입
targetElement.prepend(button); // 졸업 가능 확인 버튼 다음 삽입
}