Skip to content

added handle Cses submit and cses injected script to submit the cses… - #39

Merged
agrawal-d merged 7 commits into
agrawal-d:masterfrom
sachin-prmndani:CSES-sbmtBtn
Jun 6, 2026
Merged

added handle Cses submit and cses injected script to submit the cses…#39
agrawal-d merged 7 commits into
agrawal-d:masterfrom
sachin-prmndani:CSES-sbmtBtn

Conversation

@sachin-prmndani

Copy link
Copy Markdown
Contributor

Title :Added automated submission support for CSES
[https://github.com/agrawal-d/cph/pull/676](THE FEATURE)
Workflow & Implementation:
This PR manages the "Execution" phase of the pipeline:

Targeting: A new detection logic, isCSESProblem, identifies when a submission request is for cses.fi.

Context Injection: Upon navigation to the CSES submit page, the background script injects csesInjectedScript.ts.

Pseudo-File Creation: Since browser extensions are restricted from accessing local files directly for security reasons, the script uses the DataTransfer API to create a virtual File object in-memory from the provided source code.

DOM Manipulation: The script programmatically attaches this virtual file to the CSES file input, selects the appropriate language from the dropdown, and dispatches native browser events to ensure the form registers the changes.

Submission: The script triggers the form submission, completing the end-to-end automation.
Proof Of Work : please watch the video

2026-06-04.22-18-47.mp4
Screenshot (262)

Comment thread manifest-chrome.partial.json Outdated
{
"manifest_version": 3,
"permissions": ["scripting", "webNavigation", "offscreen"],
"permissions": ["scripting", "webNavigation", "offscreen","tabs"],

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it need this new permission?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it, That was my bad. I thought it was needed for tab operations.

@agrawal-d

Copy link
Copy Markdown
Owner

Thanks. Can you verify it works on both Firefox and Chrome? Also update the readme.

@sachin-prmndani

Copy link
Copy Markdown
Contributor Author

Thanks. Can you verify it works on both Firefox and Chrome? Also update the readme.
Yup, its working for both Chrome and firefox now, earlier it was only working for firefox due to chrome polyfill issue.
Proof: (ignore the submitting file name it will be solution.langName in commited version, i was trying to change it before recording so)

2026-06-06.19-03-50.mp4
2026-06-06.19-06-31.mp4

Comment thread package.json Outdated
"license": "MIT",
"devDependencies": {
"copy-webpack-plugin": "^14.0.0",
"merge-jsons-webpack-plugin": "^2.0.1",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this added? Undo all changes in package.json and package-lock.json

@agrawal-d

Copy link
Copy Markdown
Owner

@sachin-prmndani please ensure the pipelines pass.

Comment thread readme.md Outdated

Browser add on that enables Codeforces submit with
[Competitive Programming Helper](https://github.com/agrawal-d/cph)
Browser add on that enables direct submit on platforms like codeforces and CSES with [Competitive Programming Helper](https://github.com/agrawal-d/cph)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalization missing. Also break the long line.

Comment thread src/csesInjectedScript.ts

const form = document.querySelector('form');
if (!form) {
log('CSES form not found');

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be an alert.

@sachin-prmndani

Copy link
Copy Markdown
Contributor Author

@agrawal-d
Sir I have done as you said. Please lmk if its there anything else i have to work on. And sorry for the issues, its my first PR actually.

@agrawal-d

Copy link
Copy Markdown
Owner

Thanks for the contribution! Looks good.

@agrawal-d
agrawal-d merged commit d6083e6 into agrawal-d:master Jun 6, 2026
2 checks passed
@sachin-prmndani
sachin-prmndani deleted the CSES-sbmtBtn branch June 7, 2026 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants