Skip to content

Instantly share code, notes, and snippets.

@aleister1102
Last active February 28, 2024 20:22
Show Gist options
  • Save aleister1102/7fc412b096e205224842762ef3723793 to your computer and use it in GitHub Desktop.
Save aleister1102/7fc412b096e205224842762ef3723793 to your computer and use it in GitHub Desktop.
Script camp đăng ký học phần sử dụng Tampermonkey
var expectedCourses = {CSC11002: "20_4",CSC15002: "20_22"}
var interval = 10
function register() {
const courses = document.querySelectorAll("table:not(#tbDSDaDK) tbody tr")
const submit = document.querySelectorAll("input[type='submit']")[1]
function selectExpectedCourses() {
let found = false
courses.forEach((course) => {
const id = course.querySelector("td:nth-of-type(1)").textContent.trim()
const classId = course.querySelector("td:nth-of-type(3)")?.textContent.trim()
const checkbox = course.querySelector("td:last-of-type").querySelector("input[type='checkbox']")
if (id in expectedCourses && classId === expectedCourses[id] && checkbox) checkbox.checked = found = true
})
return found
}
if (selectExpectedCourses()) submit.click()
}
register()
setTimeout(() => window.location.reload(), interval * 1000)
@aleister1102
Copy link
Author

aleister1102 commented Feb 6, 2023

Lưu ý 2: mỗi lần đăng ký thì web sẽ tự động hỏi "Bạn có muốn đăng ký không", bạn cần phải bấm cái này bằng tay vì trình duyệt không cho phép tool làm dùm 🥹

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment