Skip to content
This repository was archived by the owner on Apr 11, 2022. It is now read-only.

Commit 0b162ef

Browse files
committed
support /contests/CONTEST_ID/tasks/PROBLEM_ID
1 parent ece8405 commit 0b162ef

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

index.user.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// ==UserScript==
22
// @name AtCoder dos2unix UserScript
33
// @namespace https://github.com/kmyk
4-
// @version 1.0
4+
// @version 1.1
55
// @description submit code using LF instead of CRLF
66
// @author Kimiyuki Onaka
77
// @match *://beta.atcoder.jp/contests/*/submit
8+
// @match *://beta.atcoder.jp/contests/*/tasks/*
89
// ==/UserScript==
910
function main() {
1011
const taskScreenName = document.getElementsByName("data.TaskScreenName")[0];
@@ -14,6 +15,8 @@ function main() {
1415
const submit = document.getElementById("submit");
1516
submit.addEventListener("click", function (e) {
1617
e.preventDefault();
18+
const contestId = location.pathname.split('/')[2];
19+
const path = "/contests/" + contestId + "/submit";
1720
const data = [];
1821
for (const tag of [taskScreenName, languageId, sourceCode, csrfToken]) {
1922
var value = tag.value;
@@ -26,7 +29,7 @@ function main() {
2629
const payload = data.join('&');
2730
console.log(payload);
2831
const xhr = new XMLHttpRequest();
29-
xhr.open("POST", location.pathname, false);
32+
xhr.open("POST", path, false);
3033
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
3134
xhr.send(payload);
3235
console.log(xhr);

index.user.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// ==UserScript==
22
// @name AtCoder dos2unix UserScript
33
// @namespace https://github.com/kmyk
4-
// @version 1.0
4+
// @version 1.1
55
// @description submit code using LF instead of CRLF
66
// @author Kimiyuki Onaka
77
// @match *://beta.atcoder.jp/contests/*/submit
8+
// @match *://beta.atcoder.jp/contests/*/tasks/*
89
// ==/UserScript==
910

1011
declare const $ : any;
@@ -19,6 +20,8 @@ function main(): void {
1920
submit.addEventListener("click", function (e) {
2021
e.preventDefault();
2122

23+
const contestId = location.pathname.split('/')[2];
24+
const path = "/contests/" + contestId + "/submit";
2225
const data = [];
2326
for (const tag of [ taskScreenName, languageId, sourceCode, csrfToken ]) {
2427
var value = tag.value;
@@ -32,7 +35,7 @@ function main(): void {
3235
console.log(payload);
3336

3437
const xhr = new XMLHttpRequest();
35-
xhr.open("POST", location.pathname, false);
38+
xhr.open("POST", path, false);
3639
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
3740
xhr.send(payload);
3841
console.log(xhr);

0 commit comments

Comments
 (0)