Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

edxie

Node.js License Playwright

A semi-automated CLI toolkit for interacting with edX-based learning platforms using Playwright and Chrome DevTools.

Description

This repository provides a set of semi-automated helper tools for platforms powered by edX.

Written in JavaScript and powered by the Playwright library with the Chrome DevTools Protocol (CDP), edxie connects to an existing Chromium browser session and enables the following functionality:

  • Quiz Management: Save quizzes as HTML files and capture full-page screenshots for archival purposes; auto-fill quiz answers based on prepared database.
  • Database Operations: Import quiz results, perform fuzzy searches, and manage database entries.
  • Video Tools: Accelerate video playback or download video content for offline viewing
  • Smart Validation: Intelligent error checking and validation to prevent mistakes

Quickstart

1. Install JavaScript Runtime

  • Node.js 22+ (recommended)
  • Deno (alternative, version compatibility may vary)

2. Install edxie

# Clone the repository
git clone https://github.com/nadvotsky/edxie.git
cd edxie

# Install the required dependencies:

# Using npm
npm install

# Using yarn
yarn install

# Using pnpm
pnpm install

3. Configuring the Platform

edxie is intended to be hackable. Start by configuring ./src/common/constants.mjs first, paying close attention to these variables:

  • HOSTS: The hostnames of your target edX platform.
  • PERSIST_DIR: The default storage directory for all relative paths (e.g., databases, exports).

Other platform-specific constants (like CSS selectors) can also be adjusted here. They are kept as constants to avoid bloating the CLI with too many arguments.

4. Prepare the Browser Session

edxie requires a Chromium-based browser with Chrome DevTools Protocol support.

WARNING: Since Chromium 136+, remote debugging is not allowed when using the default user data directory. See Chrome for Developers.

Therefore, launch the browser from the command line with the following required flags:

  • --user-data-dir=<PATH>: Specifies a custom path for the browser profile. See the official Chromium Docs for more information.
  • --remote-debugging-port=<INT>: Sets the local port for the DevTools Protocol.

Example:

# For Windows
"%LOCALAPPDATA%\Chromium\Application\chrome.exe" ^
  --user-data-dir="%USERPROFILE%\edxie-volatile" ^
  --remote-debugging-port=9000

# For Linux
chromium \
  --user-data-dir="$HOME/edxie-volatile" \
  --remote-debugging-port=9000

# For macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --user-data-dir="$HOME/edxie-volatile" \
  --remote-debugging-port=9000

5. Run edxie

Typical workflow includes the following steps:

  1. Launch the browser and complete the login process.
  2. Navigate to the learning platform resource and keep the browser session active.
  3. Execute edxie commands.
# Example: Export a quiz
node src/index.mjs -P 9000 quiz:export -O 01-cs-introduction

# Example: Accelerate a video
node src/index.mjs -P 9000 video:accel -A 10

Note: edxie always filters open tabs and picks the first one that matches the HOSTS constant.

Command-Line Interface

Anatomy

The CLI is inspired by familiar hyphen-minus prefix UNIX-style utilities:

  • Command: A required string that specifies the action to execute in the format module:name (e.g., video:accel).
  • Flags: Boolean switches to enable a feature (e.g., -f or --flush-dirty).
  • Options: Key-value pairs separated by a space or an equals sign, (e.g., -d directory, --database-path=/path/db.sqlite). An additional validation specific to the paramater may occur (e.g., specifying the same flag multiple times).

If a required value is not provided, edxie will ask interactively with built-in validation and retry support.

Example Screencast

Shared Options

These options are common to multiple commands and are documented here for brevity.

  • --browser-port PORT, -P PORT:

    • Description: The remote debugging port to connect to.
    • Required: No (default is 9000).
    • Validation: Must be an integer between 0 and 65535.
  • --database-path PATH, -d PATH:

    • Description: A path to the local database to operate on.
    • Required: No (default is PERSIST_DIR/database.sqlite).
    • Validation: Relative paths are resolved against PERSIST_DIR.

Quiz Operations

quiz:export

Exports the quiz on the currently active page. It produces an HTML file of the page content and a PNG screenshot for archival purposes.

Options:

  • --browser-port PORT, -P PORT: See Shared Options.
  • --output PATTERN, -O PATTERN:
    • Description: A file path pattern (without extension). It will be appended with .html and .png.
    • Required: Yes.
    • Validation: The target .html and .png files must not already exist.

quiz:answer

Fills the quiz on the currently active page with answers from the database.

It performs several intelligent safeguards to prevent errors:

  • Verifies database existence.
  • Ensures question integrity (i.e., DOM selectors are correct).
  • Checks for already answered questions (can be overridden with --flush-dirty).
  • Validates that the available answers match the question type (e.g., radio vs. checkbox).
  • Compares database snapshot to live content

At the end of the operation, it prints a summary table of the actions performed.

Options:

  • --browser-port PORT, -P PORT: See Shared Options.
  • --database-path PATH, -d PATH: See Shared Options.
  • --flush-dirty, -f:
    • Description: Forcefully clears and re-answers draft questions.
    • Required: No (default is false).
    • Validation: Must be a valid boolean.

Database Operations

db:populate

Creates a new or populates the existing database by parsing exported HTML quiz files.

It validates all entries and checks for compatibility with existing data in the database. At the end of the operation, it prints a comprehensive table, summarizing the performed work.

Options:

  • --database-path PATH, -d PATH: See Shared Options.
  • --I, --inputs PATH, ...:
    • Description: A list of one or more exported quiz files to import.
    • Required: Yes.
    • Validation: Paths must have an .html extension. Relative paths are resolved against PERSIST_DIR.

db:list

Lists all entries currently in the database in a table format.

Options:

db:query

Performs a fuzzy search against the database. The search query is matched against all fields, including question text and answer choices.

This command may be useful to manually look up for some specific question, as well as to find similar questions.

Options:

  • --database-path PATH, -d PATH: See Shared Options.
  • --query QUERY, -Q QUERY:
    • Description: The search term.
    • Required: Yes.
    • Validation: Must not be an empty string.

Video Operations

video:save

Downloads the video artifact from the currently active page.

  • --browser-port PORT, -P PORT: See Shared Options.
  • --save PATH, -S PATH:
    • Description: The file path where the video will be saved.
    • Required: Yes.
    • Validation: Relative paths are resolved against PERSIST_DIR.

video:accel: Accelerate Video Speed

Plays the video on the current page at an accelerated speed.

  • --browser-port PORT, -P PORT: See Shared Options.
  • --accel-speed INT, -A INT:
    • Description: The speed multiplier. For example, 16 means 16x faster.
    • Required: No (default is 10).
    • Validation: Must be bigger than 4 and less than or equal to 20.

Examples

Typical Workflow

# Export multiple quizzes
node src/index.mjs -P 9000 quiz:export -O chapter-1-quiz
node src/index.mjs -P 9000 quiz:export -O chapter-2-quiz

# Build your database
node src/index.mjs db:populate -I chapter-1-quiz.html -I chapter-2-quiz.html

# Search for specific questions
node src/index.mjs db:query -Q "machine learning"

# Auto-fill a new quiz
node src/index.mjs quiz:answer

Multiple Browser Sessions

# Session 1 (port 9000)
chromium --user-data-dir="/tmp/session-alpha" --remote-debugging-port=9000 --window-position=0,0

# Session 2 (port 9001)  
chromium --user-data-dir="/tmp/session-beta" --remote-debugging-port=9001 --window-position=800,0

# Use different sessions
node src/index.mjs -P 9000 video:accel -A 8
node src/index.mjs -P 9001 video:accel -A 8

Open Source Licenses

Thanks for using edxie! Hopefully, this experiment in automating learning platforms in a semi-manual way was a right sandbox for your needs.

It is built with the help of these amazing open-source libraries:

Library Purpose
Playwright Browser automation
Sequelize Database ORM
Commander.js CLI framework
injection-js Dependency Injection for commands
Cheerio DOM Parsing
Fuse.js Fuzzy search
Consola Elegant console logging
colors.js Colors for terminal
Inquirer.js Interactive prompts
cli-table3 Terminal tables
Joi Data validation

And many other projects they depend on!

About

A helper for the edX learning platform that offers various guided tasks within an existing browser session.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages