Added direct Submission for CodeChef & Atcoder with CPH creating codeChefInjectedScript and atcoderInjectedScript - #40
Open
sachin-prmndani wants to merge 11 commits into
Conversation
Contributor
Author
|
Hi @agrawal-d , just wanted to gently follow up on this PR. I've also pushed several improvements since opening it and tested on practice and live contests as well. When you have time, I'd appreciate any feedback or review. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Add CodeChef & Atcoder Direct Submission Support
closes #41
Overview
This PR introduces direct problem submission support for CodeChef & Atcoder in CPH, compatible with both Chrome (Manifest V3) and Firefox.
Problem
CodeChef & Atcoder uses the Ace editor, which enforces a strict Content Security Policy (CSP) that prevents direct script injection via Chrome's Manifest V3. This required a non-standard approach to interact with the editor programmatically.
Solution
for codehef:
To bypass the CSP restriction, source code is pushed directly into the page's main world memory rather than injected as a script. To bypass React's state isolation, we implemented a "human-simulation" approach . The script dispatches full native mouse event lifecycles (mouseover, mousedown, mouseup, click) to interact with the Material-UI dropdowns, forcing React to register the interactions and update its internal state accordingly.
for Atcoder:
we mapped the compiler ids to atcoder select options. Added cloudFareVerificationChecker() to constantly poll for verification for 4 times in every second, as soon as it finds the cloudfare token it auto submits the problem.
Workflow
handleSubmit.tsdetects a CodeChef or Atcoder problem and triggerscodechefInjectedScript.tsor 'atcoderInjectedScript.ts'3.After a brief wait for the React portal to render, it locates the target language via data-value matching and simulates a click to select it.
4.The script waits for the UI animation to close and the internal React state to lock.
5.Source code is injected directly into the main world's ace editor instance.
6.final simulated click triggers the "Submit" button
Changes
codechefInjectedScript.ts— handles language selection and source code injectionhandleSubmit.ts— added CodeChef , Atcoder submission handlermanifest.json— added required host permissions for CodeChef and AtcoderNotes
CodeChef:
https://github.com/user-attachments/assets/5c797f9b-c523-4b14-a387-0a2ddbd98bfc
Atcoder:
2026-06-13.22-06-34.mp4