Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic filler #5

Open
UGotTheBadEnding opened this issue Jan 21, 2024 · 3 comments
Open

Automatic filler #5

UGotTheBadEnding opened this issue Jan 21, 2024 · 3 comments

Comments

@UGotTheBadEnding
Copy link

Instead of typing the words the extension should just write it in already and all you have to do is Enter

@UGotTheBadEnding
Copy link
Author

`const classes = ["TestedWord_word_placeholder__2xuzY", "BlurredWord__word--blurred"];
const checkButtonClass = "PrimaryButtonTypes_check__cNVnz";

function autofillAnswer() {
classes.forEach(cls => {
const elems = document.getElementsByClassName(cls);
for (let i = 0; ; i++) {
const elem = elems.item(i);
if (!elem) { break; }

        const answer = elem.firstChild.textContent;
        const answerBox = elem.nextSibling.firstChild;
        
        // Trigger focus on the input box
        answerBox.focus();
        
        // Clear existing content in the input box
        answerBox.value = '';

        // Simulate typing each character with a delay
        for (let j = 0; j < answer.length; j++) {
            setTimeout(() => {
                const char = answer.charAt(j);
                // Trigger keydown and keyup events for each character
                answerBox.dispatchEvent(new KeyboardEvent('keydown', { key: char }));
                answerBox.dispatchEvent(new KeyboardEvent('keyup', { key: char }));
                // Update the input box value
                answerBox.value += char;
            }, j * 100); // Adjust the delay as needed
        }
    }
});

}`

@UGotTheBadEnding
Copy link
Author

smthn that would help ig

@Clay-6
Copy link
Owner

Clay-6 commented Jan 27, 2024

`const classes = ["TestedWord_word_placeholder__2xuzY", "BlurredWord__word--blurred"]; const checkButtonClass = "PrimaryButtonTypes_check__cNVnz";

function autofillAnswer() { classes.forEach(cls => { const elems = document.getElementsByClassName(cls); for (let i = 0; ; i++) { const elem = elems.item(i); if (!elem) { break; }

        const answer = elem.firstChild.textContent;
        const answerBox = elem.nextSibling.firstChild;
        
        // Trigger focus on the input box
        answerBox.focus();
        
        // Clear existing content in the input box
        answerBox.value = '';

        // Simulate typing each character with a delay
        for (let j = 0; j < answer.length; j++) {
            setTimeout(() => {
                const char = answer.charAt(j);
                // Trigger keydown and keyup events for each character
                answerBox.dispatchEvent(new KeyboardEvent('keydown', { key: char }));
                answerBox.dispatchEvent(new KeyboardEvent('keyup', { key: char }));
                // Update the input box value
                answerBox.value += char;
            }, j * 100); // Adjust the delay as needed
        }
    }
});

}`

This very nearly works, but the frontend doesn't properly recognise that the question has been answered for some reason. If you have ideas for that you can open a PR, but I'll into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants