Fully automated Chegg Discord bot for "homework help"

Overview

cheggbog

Fully automated Chegg Discord bot for "homework help". Working Sept 15, 2021

Overview

Recently, Chegg has made it extremely difficult to automate retrieval of content from their website. They started using a service called PerimeterX that detects the usage of automation tools like Selenium when accessing the website.

I still wanted to automate the process, so I took it to the extreme with this project. It uses a virtual machine and fake keystrokes to simulate a real user on the website.

Requirements

  • Paid Chegg account (will need to sign in)
  • A decent computer to run the VM
  • Basic Python skills
  • A Discord bot

Step 0: Obtaining the bot and creating the VM

Look up how to create a Discord bot, then add it to any server. It needs the permissions to read messages and add reactions.

For the virtual machine, I am using VMware Workstation 16 Player. It's free and works well. Once it is installed, grab the Media Creation Tool from Microsoft's website, and use it to create a .iso of Windows. Create a new virtual machine using that .iso file, and go through the setup process.

For the VM, click on "I don't have a product key". When it asks you to sign in with a Microsoft account, you can disconnect from the internet, which allows for the creation of a local account and having an empty password. Then, you'll want to install VMware Tools, Chrome, and Python (tested on version 3.9.7). Make sure to check the box to add Python to PATH when installing.

Step 1: Setting up Chrome

The way the bot works is that it opens the URL in Chrome, takes a screenshot of it using the GoFullPage extension by pressing a shortcut for it, then sends that image in the channel where the Chegg link was sent. The tab is also closed and the image is deleted once it is done.

Go to the Chegg website and sign in. Make sure that the device is registered to your account by going to any homework-help link.

Install the GoFullPage extension from the Chrome web store. Right click the icon, go to settings:

  • Set Image format to jpg
  • Set directory to screenshots
  • Check Auto-download files
  • If it asks for permissions, make sure to allow it

Optional (but recommended) tools to improve image output

See below

Install uBlock Origin and add the following as a filter to trim useless page information

! 2021-09-10 https://www.chegg.com
www.chegg.com##.loggedIn.subtype-.type-study.kit-kat-search.force-desktop.chgg-hdr
www.chegg.com##.header-nav.no-subnav.no-nav.chg-body > div > oc-component
www.chegg.com##.sidebar-container
www.chegg.com##.right-sidebar
www.chegg.com##.csrec-cards.csrec-qna

! 2021-09-15 https://www.chegg.com
www.chegg.com###playerpages-right-content
www.chegg.com##.playerpages-right-content.col-3

! 2021-09-23 https://www.chegg.com
www.chegg.com###\35 451367596
www.chegg.com##.csp-content
www.chegg.com##.app-promotion.text-me-app-container

Install Tampermonkey and add the following as a script to improve formatting

// ==UserScript==
// @name         Clean Chegg Website
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  try to take over the world!
// @author       You
// @match        https://www.chegg.com/homework-help/questions-and-answers/*
// @icon         https://www.google.com/s2/favicons?domain=chegg.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    document.querySelector("div.chg-container.center-content").style.maxWidth = "calc(100% - 13px)";
    document.querySelector("div.chg-container.center-content").style.padding = "0";
    document.querySelector("div.chg-container.center-content").style.margin = "0";
    document.querySelector("div.main-content.question-page").style.width = "calc(100% - 13px)";
    document.getElementById("popup-4").style.paddingBottom = "0";
    document.querySelector("div.chg-footer").style.display = "none";
    document.querySelector('div.txt-2-small.global-breadcrumb').style.display = "none";
    document.querySelector('div.parent-container.question-headline').style.paddingTop = "0";
    document.querySelector('div.parent-container.question-headline').style.paddingBottom = "0";
    document.querySelector('div.main-content.question-page').style.width = "100%";
    document.querySelector('div.chg-content.HomeworkhelpQuestion').style.padding = "0";
    document.querySelector('div.chg-content.HomeworkhelpQuestion').style.minWidth = "unset";
})();

Change the VM resolution to something like 1600x1200 in Display Settings in Windows

In Chrome, set a default resolution by right clicking on the empty space next to the tabs and clicking Size (unsure if this works).

Step 2: Setting up the Discord bot

Download this repository as a zip and extract it to anywhere. Add your bot's private key to key.txt. Open cheggbog.py and edit the variable called "path" with your username.

Open a command prompt in the folder and install the required libraries using the following

python -m pip install -r requirements.txt

Then you can run the bot by typing the following command

python cheggbog.py

Make sure to have at least 1 tab open while the bot is running to improve loading times

Step 3: Testing and final parts

When the bot is running, it is looking for both DMs and messages sent in any channel it can see. Send any Chegg homework help link and make sure not to touch the virtual machine. The intended behavior is the following:

  • Link sent, bot reacts with an emoji to show processing
  • Bot opens link in Chrome, waits for a bit, then triggers the full page screenshot tool
  • After a set amount of time, the bot sends the image in the same channel as the link, closes the Chegg window, and deletes the image file
  • Finally, reacts to the original message to show that it is complete

(Optional) Adding the bot to startup

In the cheggbog folder, create a new file called run.bat with the following contents

python cheggbog.py

Press Win+R and type shell:startup to access the startup programs folder. Create a shortcut to the run.bat file and drop it in this folder, along with a shortcut to Chrome.

(Optional) Adding the VM to startup

On the host computer, go to the location of the VM (default C:\Users[User]\Documents\Virtual Machines[Your VM]). Create a .bat file with the following contents (substitute things in brackets)

"C:\Program Files (x86)\VMware\VMware Player\vmrun" -T player start "C:\Users\[User]\Documents\Virtual Machines\[Your VM]\[Your VM].vmx"

Create a shortcut to this file and place it in the shell:startup folder of the host

Thanks for reading, please leave a star if you found this tool useful, or send me a message if it was useless.

Owner
Bryce Hackel
work
Bryce Hackel
Use Seaborn to visualize interpret the byte layout of Solana account types

solana-account-vis Use Seaborn to visually interpret the byte layout of Solana account types Usage from account_visualization import generate_account_

Jarry Xiao 15 Aug 25, 2022
An interactive and multi-function Telegram bot, made especially for Telegram groups.

PyKorone An interaction and fun bot for Telegram groups, having some useful and other useless commands. Created as an experiment and learning bot but

Amano Team 17 Nov 12, 2022
Simple integration between FastAPI and cloud authentication services (AWS Cognito, Auth0, Firebase Authentication).

FastAPI Cloud Auth fastapi-cloudauth standardizes and simplifies the integration between FastAPI and cloud authentication services (AWS Cognito, Auth0

tokusumi 255 Jan 07, 2023
A python client for the Software-Challenge Germany.

sc-client-python A python client for the Software-Challenge Germany. Creating a new project (Optional) Install virtualenv virtualenv is a tool that cr

rpkak 3 Jan 22, 2022
Mailjet API implementation in Python

READ THIS FIRST!! This repository isn't compatible with the current Mailjet API (v3) and, as a consequence, is considered deprecated and won't undergo

Rick van Hattem 18 Oct 21, 2022
Nonebot2 简易群管

简易群管 ✨ NoneBot2 简易群管 ✨ _ 踢 改 禁 欢迎issue pr 权限说明:permission=SUPERUSER 安装 💿 pip install nonebot-plugin-admin 导入 📲 在bot.py 导入,语句: nonebot.load_plugin("n

幼稚园园长 74 Dec 22, 2022
Autofill HZDR Zeitman entries

Zeitman_autofill Filling out Zeitman is boring. This script might make some of the pain go away. Requirements The selenium package and Chrome webdrive

Tim Callow 8 Mar 14, 2022
Die wichtigsten APIs Deutschlands in einem Python Paket.

Deutschland A python package that gives you easy access to the most valuable datasets of Germany. Installation pip install deutschland Geographic data

Bundesstelle für Open Data 921 Jan 08, 2023
The purpose of this bot is to take soundcloud track requests, that are posted in the stream-requests channel, and add them to a playlist, to make the process of scrolling through the requests easier for Root

Discord Song Collector Dont know if anyone is actually going to read this, but the purpose of this bot is to check every message in the stream-request

2 Mar 01, 2022
A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.

Light Gradient Boosting Machine LightGBM is a gradient boosting framework that uses tree based learning algorithms. It is designed to be distributed a

Microsoft 14.5k Jan 08, 2023
Monitor robot of Apple Store's products, using DingTalk notification.

概述 本项目应用主要用来监测Apple Store线下直营店货源情况,主要使用Python实现。 首先感谢iPhone-Pickup-Monitor项目带来的灵感,同时有些实现也直接使用了该项目的一些代码。 本项目在iPhone-Pickup-Monitor原有功能的基础上去掉了声音通知,但添加了多

Lennon Chin 159 Dec 09, 2022
This repository contains code written in the AWS Cloud Development Kit (CDK)

This repository contains code written in the AWS Cloud Development Kit (CDK) which launches infrastructure across two different regions to demonstrate using AWS AppSync in a multi-region setup.

AWS Samples 5 Jun 03, 2022
Python lib to control HottoH based stove devices

Project desciption This library can be used to discuss with HootoH based stove devices Actually tested and validated with a CMG Drum stove. To use thi

3 May 16, 2022
Generate direct m3u playlist for all the channels subscribed in the Tata Sky portal

Tata Sky IPTV Script generator A script to generate the m3u playlist containing direct streamable file (.mpd or MPEG-DASH or DASH) based on the channe

Gaurav Thakkar 250 Jan 01, 2023
TypeRig is a Python library aimed at simplifying the current FontLab API

TypeRig TypeRig is a Python library aimed at simplifying the current FontLab API while offering some additional functionality that is heavily biased t

Vassil Kateliev 41 Nov 02, 2022
RChecker - Checker for minecraft servers

🔎 RChecker v1.0 Checker for Minecraft Servers 💻 Supported operating systems: ✅

Pedro Vega 1 Aug 30, 2022
A high level library for building Discord bots.

Qord A high level library for building Discord bots. 🚧 This library is currently in development. Questions that you are having What is this? This is

Izhar Ahmad 16 May 14, 2022
Simple yet efficient tool used to check and sort tokens in terms of there validation.

Discord Token Checker Simple yet efficient tool used to check and sort tokens in terms of there validation.When the program is done,go to the "output"

Robotnik 15 Dec 27, 2022
Automatically detect changes made to the official Telegram sites.

🕷 Telegram Web Crawler This project is developed to automatically detect changes made to the official Telegram sites. This is necessary for anticipat

Il'ya 115 Dec 31, 2022
Python notebook allows send bulk whatsapp messages to contacts (not necessarily saved) using an excel file and the selenium package. It also produces a final report on the sending status of the messages.

WhatsApp messages bulk sending 📩 Este notebook (python) te permite enviar mensajes masivos de WhatsApp. El insumo principal es una hoja excel que con

Braulio Arteaga Lescano 8 Sep 15, 2022