Coder Social home page Coder Social logo

aoc-watcher's Introduction

๐ŸŽ๐ŸŽ„ AoC ๐Ÿคถ Watcher ๐ŸŽ„ ๐ŸŽ

Allows for an automated browser experience during Advent of Code subsmissions. Verified with Python interop and the current LTS NodeJS. If you prefer something else there are serveral other tools that could be worth a try. Examples are listed below. Built with Chrome Remote Interface and Javascript.

The following configurations have been verified or documented as unsupported.

OS Browser Verified
Windows Firefox โœ… 2022-12-04
Windows Brave โœ… 2022-12-04
MacOS Firefox โŒ 2022-12-05: Firefox doesn't allow for Javascript injection.
MacOS Brave โœ… 2022-12-22

โญ Basic outline

  • Awaits todays puzzle by long-polling the DOM. No additional HTTP requests.
  • Navigates to puzzle once available.
  • Downloads the puzzle input.
  • Long-polls a process standard output and attempts a JSON extract.
  • Prints any pending errors while coding.
  • Submits and continues to part 2.
  • Skips if a previous submission was correct.
  • In-process prevention against duplicate submissions.
  • Keeps track of bounds for failed submissions ("too high" or "low" answers), yet again in-process.

The browser will have to authenticate at some point. Might just do that in same browser that will run the debugger.

โญ Tasks

Purpose Browser Comment
Install npm i
Test npm test Runner provided by jasmine
Starting browser ./brave.ps1 firefox.ps1 and chrome.sh also available but may have to be modified to match path.
Running today npm start Requires a debuggable browser and enviroment variables (see below).
Running some other day npm start "2018-02" Requires a debuggable browser and enviroment variables (see below).

โญ Notes on running

Some environment variables needs to be set. Here an example (on Windows) but you might just want to change the script used or use an env-file. Days will be padded with single digit zero fill (for now). On Windows I prefer to copy variables into a Powershell script.

# Kindly take note of employed Mustasche template string.
$env:AOCW_PUZZLE_FILE = 'puzzle.txt'
$env:AOCW_PUZZLE_FOLDER = 'C:\\development\\aoc\\year_{{year}}\\day_{{day}}\\'
$env:AOCW_MODULE = 'C:\\development\\aoc\\year_{{year}}\\day_{{day}}\\solve.py'
$env:AOCW_EXEC = 'C:\\development\\aoc\\.venv\\Scripts\\python.exe'

or in an .env:

AOCW_PUZZLE_FILE=puzzle.txt
AOCW_PUZZLE_FOLDER=M:\\development\\aoc\\year_{{year}}\\day_{{day}}\\
AOCW_MODULE=M:\\development\\aoc\\year_{{year}}\\day_{{day}}\\solve.py
AOCW_EXEC=M:\\development\\aoc\\.venv\\Scripts\\python.exe

โญ Implementing support for puzzles answers

The watcher does interop via standard output from a user configured process. If the output contains a flat JSON dictionary with the word uzzle in the message it it's results will processed. It generally must also conform to the example below.

{
  "ok": true,
  "puzzle": 1475698
  "test": 42
}

โญ Additional notes

Advent of Code is a puzzle oriented calendar by Eric Wastl and other contributors. Please consider supporting their work.

This repository is provided under MIT and isn't directly affiliated with Advent of Code, Firefox, Brave, Safari or Chrome. Any referenced libraries are licensed separately.

โญ Other tools

These are examples of other Advent of Code tools for puzzle download or answer submission. I do not recommended or condone their use.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.