Skip to content

Commit

Permalink
feat: Refill form in mode2 when captcha is incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Nov 15, 2023
1 parent ac3482a commit 4adde2f
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions extension-src/firefox/js/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ browser.runtime.sendMessage({
textBox = document.getElementById('myframe').contentDocument.querySelectorAll('textarea');
radioButton = document.getElementById('myframe').contentDocument.querySelectorAll('input[type="radio"]');
prof = document.getElementById('myframe').contentDocument.querySelectorAll('input[name="check"]');
captchaText = document.getElementById('myframe').contentDocument.getElementById('passline');
submitButton = document.getElementById('myframe').contentDocument.getElementById('sub');

if (textBox.length == 5) {
switch (preference.feedback) {
Expand Down Expand Up @@ -38,29 +40,28 @@ browser.runtime.sendMessage({
break;
}
}

submitButton.setAttribute("onclick", "document.form1.method = 'POST'; document.form1.action = 'rev_feed_submit.jsp'; document.form1.submit();")
submitButton.addEventListener("click", async () => {
await sleep(3000);
processSubmission();
});
// captchaText.addEventListener("keydown", async (event) => {
// if (event.key === "Enter") {
// await sleep(3000);
// processSubmission();
// }
// });
};

const handleProf = () => {
submitButton = document.getElementById('myframe').contentDocument.getElementById('sub');
prof = document.getElementById('myframe').contentDocument.querySelectorAll('input[name="check"]');
console.log("Handling Prof", profCounter)
prof[profCounter].click(); profCounter++;

submitButton = document.getElementById('myframe').contentDocument.getElementById('sub');
if (submitButton != null){
fill_form();

submitButton.setAttribute("onclick", "document.form1.method = 'POST'; document.form1.action = 'rev_feed_submit.jsp'; document.form1.submit();")
submitButton.addEventListener("click", async () => {
await sleep(3000);
processSubmission();
});

captchaText = document.getElementById('myframe').contentDocument.getElementById('passline');
captchaText.addEventListener("keydown", async (event) => {
if (event.key === "Enter") {
await sleep(3000);
processSubmission();
}
});
} else {
if (profCounter < prof.length) handleProf();
else handleCourse();
Expand All @@ -70,30 +71,38 @@ browser.runtime.sendMessage({
const processSubmission = () => {
submitButton = document.getElementById('myframe').contentDocument.getElementById('sub');
if (submitButton != null) {
profCounter--;
handleProf();
if (preference.all){
profCounter--; handleProf();
} else {
fill_form()
}
} else {
prof = document.getElementById('myframe').contentDocument.querySelectorAll('input[name="check"]');
if (profCounter < prof.length) handleProf();
else handleCourse();
if (preference.all){
prof = document.getElementById('myframe').contentDocument.querySelectorAll('input[name="check"]');
if (profCounter < prof.length) handleProf();
else handleCourse();
}
}
};

const handleCourse = () => {
course = document.getElementById('myframe').contentDocument.querySelectorAll('a[href="javascript:void(0)"]');
if (courseCounter == course.length) return;
console.log("Handling Course", courseCounter)
course[courseCounter].click(); courseCounter++;

profCounter = 0; handleProf();
};

try {
if (!preference.all)
fill_form();
else
if (courseCounter == 0) handleCourse();
if (preference.all && courseCounter == 0) {
handleCourse();
}
else if (!preference.all) {
fill_form();
}
} catch (err) {
console.error(err);
console.error(err);
}
});

Expand Down Expand Up @@ -268,4 +277,4 @@ function negative_lab_feedback() {
for (i = prof.length + 48; i < prof.length + 54; i += 5)
if (Math.floor(Math.random() * 2)) radioButton[i].click();
else radioButton[i + 1].click();
}
}

0 comments on commit 4adde2f

Please sign in to comment.