Skip to content

Bluore/submit-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPH Auto Submitter Chrome Extension

A Chrome extension that polls a local HTTP server on port 4578 for CPH (Competitive Programming Helper) tool requests and automatically submits code to AtCoder.

Features

  • Polls http://localhost:4578/submit every second for submission tasks.
  • Parses problem ID (e.g., abc123a) and generates AtCoder URLs.
  • Opens the AtCoder submission page, fills in the code, and clicks submit.
  • Stores submission history in Chrome storage.
  • Popup displays history with links to problem and results.

Installation

  1. Clone or download this repository.
  2. Open Chrome and go to chrome://extensions/.
  3. Enable Developer mode (toggle in top-right).
  4. Click Load unpacked and select the folder containing this extension (the folder with manifest.json).
  5. The extension should appear with icon "CPH Auto Submitter".

Usage

1. Start the local server (CPH tool)

You need a local HTTP server running on port 4578 that provides submission tasks. For testing, you can use the provided server.js:

node server.js

This server will respond to GET http://localhost:4578/submit with a sample submission task.

2. Start the extension

After loading the extension, its background script will automatically start polling the local server every second. You should see console logs (inspect background page) confirming "Starting polling to http://localhost:4578/submit".

3. Automatic submission

When the local server returns a valid task (JSON with problem, code, and optional language), the extension will:

  • Open a new tab with the AtCoder submission page.
  • Inject the code into the editor.
  • Click the submit button.
  • Store the submission in history.

4. View history

Click the extension icon to open the popup, which shows a list of past submissions with links to the problem and results.

Configuration

  • Polling endpoint: Currently fixed at http://localhost:4578/submit (can be changed in background.js).
  • Polling interval: 1 second (adjustable in background.js).
  • Language mapping: Not yet implemented; defaults to C++ (GCC 9.2.1). To change, modify content.js setLanguage function.
  • Options page: Access via right-click extension icon → Options (basic port setting).

Development

Project Structure

.
├── manifest.json
├── background.js          # HTTP polling and submission handling
├── content.js            # DOM automation on AtCoder submit page
├── popup/
│   ├── popup.html
│   ├── popup.js
│   └── popup.css
├── icons/
│   ├── icon16.png
│   ├── icon48.png
│   └── icon128.png
├── options/              # Options page (basic)
│   ├── options.html
│   └── options.js
├── plan.md               # Design plan
├── todo.md               # Implementation todo list
├── server.js             # Test local server
├── test.js               # Legacy test script (TCP)
└── README.md

Testing without Chrome

To verify the extension's polling behavior, you can run the provided test local server:

node server.js

Then load the extension and inspect the background page logs. The extension should poll http://localhost:4578/submit every second and, upon receiving a task, automatically open AtCoder and submit.

For a quick integration test, you can also modify server.js to return custom tasks.

Debugging

  • Inspect background page: go to chrome://extensions/, find the extension, click "service worker" link.
  • Inspect popup: right-click the extension icon, select "Inspect popup".
  • Inspect content script: open AtCoder submit page, open DevTools, look for console logs.

Known Limitations

  • AtCoder page structure may change, breaking the code editor selector.
  • Requires user to be logged into AtCoder; otherwise submission fails.
  • Only supports ABC problem format (abc123a). Can be extended to ARC/AGC.
  • Language mapping is hardcoded; future version should allow configuration.
  • Polling may cause unnecessary network traffic if local server is not running.
  • The extension requires a local HTTP server running on port 4578; if not present, polling will fail silently.

Future Enhancements

  • Support for multiple contest types (ARC, AGC, etc.)
  • Configurable language mapping via options page.
  • Submission result polling and notification.
  • Better error handling and retry logic.
  • Support for other competitive programming platforms (Codeforces, etc.)

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors