Last active
July 29, 2024 17:13
-
-
Save teebow1e/7da9057c911915eea77f0952bde1914f to your computer and use it in GitHub Desktop.
[HUST] Quickly pass all HUST's course feedback form in ctt.hust.edu.vn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to use | |
// Open DevTools | |
// Paste this code | |
// The website will automatically redirect, wait until page loads, paste | |
// Keep doing until there is no more feedback form | |
// TODO: Auto redirect and run until detect finish msg | |
// Script V1: Mass choosing, result can be conflict | |
function runSurvey() { | |
let firstTextElement = document.querySelector('#ctl00_ctl00_contentPane_MainPanel_MainContent_lbFirstText h4'); | |
if (firstTextElement && firstTextElement.textContent.includes("Hiện tại bạn không còn khảo sát nào. Xin hãy quay lại sau.")) { | |
console.log("all survey finished."); | |
return; | |
} | |
let spans = document.querySelectorAll('span'); | |
spans.forEach(span => { | |
let id = span.id; | |
// RB0 = rất không hài lòng | |
// RB1 = không hài lòng | |
// RB2 = tạm hài lòng | |
// RB3 = hài lòng | |
// RB4 = rất hài lòng | |
if (id && id.startsWith("ctl00_ctl00_contentPane_MainPanel_MainContent_formLayout_RBL_") && id.includes("RB4")) { | |
let element = document.querySelector('#' + id); | |
if (element) { | |
element.click(); | |
} | |
} | |
}); | |
let submitInputs = document.querySelectorAll('input[type="submit"]'); | |
submitInputs.forEach(submitInput => { | |
console.log("found submit btn, clicking.."); | |
submitInput.click(); | |
}); | |
} | |
runSurvey(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to use | |
// Open DevTools | |
// Paste this code | |
// The website will automatically redirect, wait until page loads, paste | |
// Keep doing until there is no more feedback form | |
// TODO: Auto redirect and run until detect finish msg | |
// Script V2: More personalized choice | |
const profile = { | |
"positive": { "0": "RB4", "1": "RB4", "2": "RB4", "3": "RB4", "4": "RB4", "5": "RB4", "6": "RB4", "7": "RB4", "8": "RB4", "9": "RB4", "10": "RB4", "11": "RB4", "12": "RB2", "13": "RB2", "14": "RB2" }, | |
"neutral": { "0": "RB3", "1": "RB3", "2": "RB3", "3": "RB3", "4": "RB4", "5": "RB2", "6": "RB3", "7": "RB3", "8": "RB3", "9": "RB4", "10": "RB2", "11": "RB2", "12": "RB2", "13": "RB2", "14": "RB2" }, | |
"negative": { "0": "RB1", "1": "RB1", "2": "RB1", "3": "RB3", "4": "RB3", "5": "RB3", "6": "RB3", "7": "RB3", "8": "RB3", "9": "RB3", "10": "RB3", "11": "RB3", "12": "RB4", "13": "RB2", "14": "RB2" } | |
}; | |
function runSurvey() { | |
let chosenProfile = profile.positive; // change this to profile.neutral or profile.negative | |
let firstQuestion = 0; | |
let firstTextElement = document.querySelector('#ctl00_ctl00_contentPane_MainPanel_MainContent_lbFirstText h4'); | |
if (firstTextElement && firstTextElement.textContent.includes("Hiện tại bạn không còn khảo sát nào. Xin hãy quay lại sau.")) { | |
console.log("all survey finished."); | |
return; | |
} | |
let spanAnswer = Array.from(document.querySelectorAll('span')).filter(span => { | |
return span.id && span.id.startsWith("ctl00_ctl00_contentPane_MainPanel_MainContent_formLayout_RBL_"); | |
}); | |
firstQuestion = Number(...spanAnswer[0].id.split('_').slice(-4, -3)); | |
spanAnswer.forEach(span => { | |
let id = span.id; | |
let questionNum = String(Number(...id.split('_').slice(-4, -3)) - firstQuestion); | |
if (chosenProfile[questionNum] && id.includes(chosenProfile[questionNum])) { | |
span.click(); | |
} | |
}); | |
let submitInputs = document.querySelectorAll('input[type="submit"]'); | |
submitInputs.forEach(submitInput => { | |
console.log("found submit btn, clicking.."); | |
submitInput.click(); | |
}); | |
} | |
runSurvey(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment