I have a simple js bot that rapidly answers coding questions in a text area by filling in javascript code and clicking submit button, using a for loop for all solutions I stored in an object:
Here is part of the solutions object:
const solutions = {
'square': 'return x*x',
'getType': 'return typeof(x);',
....}
Here is the actual submission and/or for loop:
const get_submit_button = () => document.querySelector('.task-buttons > .col > .btn');
const solve = () => {
const ace_editor = ace.edit(document.querySelector('.ace_editor'))
const submission = ace_editor.getValue()
for (const key in solutions) {
if (submission.includes('box.' + key + ' ')) {
ace_editor.insert(solutions[key])
get_submit_button().click()
setTimeout(() => {
get_submit_button().click()
setTimeout(() => {
solve()
}, 400)
}, 900)
return
}
}
};
solve()
The loop is supposed to answer about 30 questions under 180 seconds. I have tried to reduce time in the setTimeout() function but it usually results in slower execution due to the code (solution being copied) multiple times in the text area.
Is there any way to improve speed of execution or the problem is related to my network speed (2Mb/s)?