/**
                     * sort Used to order an array of integers in ascending order (O(n)).
                     * @param {Array} arr
                     * @return {Promise}
                     */
                    
                    function sort (arr) {
                        return new Promise(resolve => {
                            const sorted = [];
                            
                            for (const item of arr) {
                                setTimeout(item => sorted.push(item), item, item);
                            }
                            
                            setTimeout(() => resolve(sorted), arr.reduce((a, b) => a + b, 0) + 1);
                        });
                    }
                
                
                    «Nullam elementum blandit molestie.
                    Aenean condimentum lectus ut felis.
                    Phasellus fringilla nisl tincidunt dolor.»
                    
                    «Nam quis ante sed neque rhoncus.
                    Proin porta, turpis quis iaculis.
                    Maecenas tristique vulputate magna, vel laoreet.»
                    
                    «Nullam lobortis turpis a tempor molestie.
                    Maecenas fringilla nisl at malesuada porta.»
                
            
06/12/2020, Vasile Pește

+10.000$ with 300 lines of JavaScript code

At the beginning of this school year I was thinking that as a student it would be nice to be more valued for the time I spend every day on studying Information Technology, I got my first job as a Developer at sixteen and I couldn’t be luckier than that, but it’s been a long time since and I felt the need for something new. Therefore after a month since the beginning of the school I received a notification from Quora: an invitation to the Quora Partner Program, and here the story begins…

The Quora Partner Program

Quora is: «A platform to ask questions and connect with people who contribute unique insights and quality answers.», the Quora Partner Program is an invitation only program (I don’t know the criteria for being invited but before the invitation I had already been actively using Quora for a year) and basically if you enter the program you can start earning money by asking questions, the gain of a question depends on its views. There is also a feature for requesting answers to Quora users for a specific questions so all I had to to do was to make questions and request answers.

Automating the Tasks

I didn’t want to spend much time on this, one of my dreams is to create a collection of bots for doing part of my work, so I started writing a Node.js application for automating the tasks (making questions on Quora and asking people to answer the questions) the main dependence of this application is puppeteer (an API for running and communicating with a headless version of Google Chrome) in order to simulate a «real» user with a true browser, performing actions like clicking buttons and writing on forms, and making questions, all of this in background. The questions were taken from the Quora feed in English, translated automatically through Google Translate and published on Quora in the other languages available like Italian and French. In the end I installed node-schedule, a library for running your application at a specific time, and I put my application on a Linux server which costs 5$ per month. These are the results after a few months.

Here is the main piece of code. This simple logic is used to create a bot for visiting web pages and execute JavaScript code inside them.

export default class Bot {
    constructor (name) {
        this.name = name;
        // A wrapper of the puppeteer module.
        this.browser = new Puppeteer();
        this.logger = fs.createWriteStream(`logs/${this.name}.log`, {
            flags: "a",
        });
    }
    
    async openBrowser (headless = true) {
        const options = {
            headless,
            userDataDir: `profiles/${this.name}`,
        };
        const parameters = [
            "--disable-infobars",
        ];
        
        await this.browser.open(options, parameters);

        return this.browser;
    }
    
    async openBrowserPage () {
        const page = await this.browser.openPage();
        
        await Promise.all([
            page.exposeFunction("__log__", (message) => this.log(message)),
            // A piece of code used to bypass puppeteer detection.
            page.evaluateOnNewDocument(PRELOAD_BYPASS),
        ]);
        
        return page;
    }
    
    async closeBrowser () {
        return await this.browser.close();
    }
    
    log (message) {
        this.logger.write(`${new Date().toGMTString()} : ${message}`);
        this.logger.write("\n");
        
        console.log(`${new Date().toGMTString()} : ${message}\n`);
    }
}

The following is a snippet used for retrieving questions from the visited feed. All those snippets are stored in a file and executed each time a page is visited , then the functions were called when needed.

async getQuestionsFromFeed (number = 10) {
    const questions = [];

    while (document.querySelectorAll(".question_link").length < number) {
        Utilities.scrollMaxY();
        await new Promise((resolve) => setTimeout(resolve, Utilities.getRandomInt(600, 1200)));
    }

    for (const question of document.querySelectorAll(".question_link")) {
        questions.push(question.innerText);
    }

    return questions;
}

The following snippet is used for requesting answers for a question to random Quora users. As you can see in each function there is a random delay before performing each action, this is for simulating a real user. It would be suspicious if a user sent hundreds of HTTP requests in a few seconds.

async requestQuestionAnswer (questionNode) {
    let modal;
    let buttons;
    let i = 0;

    jQuery(questionNode.querySelector(".AskToAnswerModalLink")).click();
    modal = document.querySelectorAll(".A2aModalStep")[0];

    while (!modal) {
        await new Promise((resolve) => setTimeout(resolve, 280));

        modal = document.querySelectorAll(".A2aModalStep")[0];
    }

    await new Promise((resolve) => setTimeout(resolve, Utilities.getRandomInt(750, 1600)));
    jQuery(".A2AModalNavItem.SendRequestModalNavItem.ModalNavItem").click();
    await new Promise((resolve) => setTimeout(resolve, Utilities.getRandomInt(750, 1600)));
    buttons = modal.querySelectorAll(`[id$="_request_button"]`);

    let z = 0;

    try {
        while (/*document.querySelector(".extra_actions").innerText.indexOf("25/25") === -1*/++z <= 10) {
            const button = buttons[i++];

            if (modal.querySelector(".reason_title") !== null) {
                jQuery(modal.querySelector(".modal_actions span + a.submit_button.modal_action")).click();
                await new Promise((resolve) => setTimeout(resolve, Utilities.getRandomInt(1259, 1623)));

                return -1;
            }
            else if (!button) {
                --i;

                break;
            }

            jQuery(button).click();
            await new Promise((resolve) => setTimeout(resolve, Utilities.getRandomInt(1359, 2000)));
        }
    }
    catch (e) {
        // Silence is golden.
    }

    await new Promise((resolve) => setTimeout(resolve, Utilities.getRandomInt(1259, 1623)));
    jQuery(modal.querySelector(".modal_actions span + a.submit_button.modal_action")).click();
    await new Promise((resolve) => setTimeout(resolve, Utilities.getRandomInt(1259, 1623)));
        
    return i;
}

I’m not publishing all the code (as you can see it’s rushed) as the main point of this publication is my story and how it’s easy nowadays making money with simple automation.

Am I doing right?

I don’t know, it’s difficult to say and and it’s a subjective point of view: I see myself as a person who has automated his tasks, with no bad intention, I did what a normal person could have done, but through a robot, without spending my time. This is a profit for Quora, given that I was paid and that I certainly received only a percentage of their total earnings. But I also feel a bit guilty for those who do it manually. I donated some of these earnings. The truth is that the Web is getting bigger and full of opportunities, you can do more and more extraordinary and concrete things, sitting on a chair, many still have to discover this reality.