This repository was archived by the owner on Apr 11, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 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==
910function 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 ) ;
Original file line number Diff line number Diff line change 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
1011declare 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 ) ;
You can’t perform that action at this time.
0 commit comments