From 436fe2b5352e1ae6a7ac9ec82028f57a56695d53 Mon Sep 17 00:00:00 2001 From: boomzero Date: Sun, 31 Dec 2023 21:11:58 +0800 Subject: [PATCH 1/8] Make it prettier --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3cfb3a4..773715a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # quickSubmit +[![Deno](https://github.com/boomzero/quicksubmit/actions/workflows/deno.yml/badge.svg)](https://github.com/boomzero/quicksubmit/actions/workflows/deno.yml) +[![Publish](https://github.com/boomzero/quicksubmit/actions/workflows/publish.yml/badge.svg)](https://github.com/boomzero/quicksubmit/actions/workflows/publish.yml) + Submit Code to XMOJ. image From 263e75a81c8846b400d3d9f1f23e8fb25a314c9c Mon Sep 17 00:00:00 2001 From: boomzero Date: Mon, 1 Jan 2024 14:36:14 +0800 Subject: [PATCH 2/8] clean up config + other things --- .fleet/run.json | 5 + .github/workflows/deno.yml | 8 - index.ts | 18 ++ package-lock.json | 437 +++++++++++++++++++++++++++++++++++++ tsconfig.json | 11 - 5 files changed, 460 insertions(+), 19 deletions(-) create mode 100644 .fleet/run.json create mode 100644 package-lock.json diff --git a/.fleet/run.json b/.fleet/run.json new file mode 100644 index 0000000..822a3ba --- /dev/null +++ b/.fleet/run.json @@ -0,0 +1,5 @@ +{ + "configurations": [ + + ] +} \ No newline at end of file diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml index b5a1e85..76e0551 100644 --- a/.github/workflows/deno.yml +++ b/.github/workflows/deno.yml @@ -1,11 +1,3 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# This workflow will install Deno then run `deno lint` and `deno test`. -# For more information see: https://github.com/denoland/setup-deno - name: Deno on: diff --git a/index.ts b/index.ts index f4327e8..6b9aba5 100644 --- a/index.ts +++ b/index.ts @@ -1,3 +1,21 @@ +/* + * quickSubmit + * Copyright (C) 2023-2024 boomzero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + import { Command } from "commander"; import { JSDOM } from "jsdom"; import MD5 from "crypto-js/md5.js"; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e4e990d --- /dev/null +++ b/package-lock.json @@ -0,0 +1,437 @@ +{ + "name": "quicksubmit", + "version": "1.4.3", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "quicksubmit", + "version": "1.4.3", + "license": "GPL-3.0-or-later", + "dependencies": { + "@types/crypto-js": "^4.2.1", + "@types/jsdom": "^21.1.6", + "commander": "^11.1.0", + "crypto-js": "^4.2.0", + "jsdom": "^23.0.1" + }, + "peerDependencies": { + "typescript": "^5.3.3" + } + }, + "node_modules/.deno/@types+node@18.16.19/node_modules/@types/node": { + "version": "18.16.19", + "license": "MIT" + }, + "node_modules/@types/crypto-js": { + "version": "4.2.1", + "license": "MIT" + }, + "node_modules/@types/jsdom": { + "version": "21.1.6", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/tough-cookie": "*", + "parse5": "^7.0.0" + } + }, + "node_modules/@types/node": { + "resolved": "node_modules/.deno/@types+node@18.16.19/node_modules/@types/node", + "link": true + }, + "node_modules/@types/tough-cookie": { + "version": "4.0.5", + "license": "MIT" + }, + "node_modules/agent-base": { + "version": "7.1.0", + "license": "MIT", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "license": "MIT" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "11.1.0", + "license": "MIT", + "engines": { + "node": ">=16" + } + }, + "node_modules/crypto-js": { + "version": "4.2.0", + "license": "MIT" + }, + "node_modules/cssstyle": { + "version": "3.0.0", + "license": "MIT", + "dependencies": { + "rrweb-cssom": "^0.6.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/data-urls": { + "version": "5.0.0", + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decimal.js": { + "version": "10.4.3", + "license": "MIT" + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/entities": { + "version": "4.5.0", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/html-encoding-sniffer": { + "version": "4.0.0", + "license": "MIT", + "dependencies": { + "whatwg-encoding": "^3.1.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/http-proxy-agent": { + "version": "7.0.0", + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.2", + "license": "MIT", + "dependencies": { + "agent-base": "^7.0.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "license": "MIT" + }, + "node_modules/jsdom": { + "version": "23.0.1", + "license": "MIT", + "dependencies": { + "cssstyle": "^3.0.0", + "data-urls": "^5.0.0", + "decimal.js": "^10.4.3", + "form-data": "^4.0.0", + "html-encoding-sniffer": "^4.0.0", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.2", + "is-potential-custom-element-name": "^1.0.1", + "nwsapi": "^2.2.7", + "parse5": "^7.1.2", + "rrweb-cssom": "^0.6.0", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^4.1.3", + "w3c-xmlserializer": "^5.0.0", + "webidl-conversions": "^7.0.0", + "whatwg-encoding": "^3.1.1", + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.0.0", + "ws": "^8.14.2", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "canvas": "^2.11.2" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "license": "MIT" + }, + "node_modules/nwsapi": { + "version": "2.2.7", + "license": "MIT" + }, + "node_modules/parse5": { + "version": "7.1.2", + "license": "MIT", + "dependencies": { + "entities": "^4.4.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/psl": { + "version": "1.9.0", + "license": "MIT" + }, + "node_modules/punycode": { + "version": "2.3.1", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/querystringify": { + "version": "2.2.0", + "license": "MIT" + }, + "node_modules/requires-port": { + "version": "1.0.0", + "license": "MIT" + }, + "node_modules/rrweb-cssom": { + "version": "0.6.0", + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "license": "MIT" + }, + "node_modules/saxes": { + "version": "6.0.0", + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "license": "MIT" + }, + "node_modules/tough-cookie": { + "version": "4.1.3", + "license": "BSD-3-Clause", + "dependencies": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.2.0", + "url-parse": "^1.5.3" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tr46": { + "version": "5.0.0", + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/typescript": { + "version": "5.3.3", + "license": "Apache-2.0", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/universalify": { + "version": "0.2.0", + "license": "MIT", + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/url-parse": { + "version": "1.5.10", + "license": "MIT", + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, + "node_modules/w3c-xmlserializer": { + "version": "5.0.0", + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-encoding": { + "version": "3.1.1", + "license": "MIT", + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-mimetype": { + "version": "4.0.0", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-url": { + "version": "14.0.0", + "license": "MIT", + "dependencies": { + "tr46": "^5.0.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/ws": { + "version": "8.15.1", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "license": "MIT" + } + } +} diff --git a/tsconfig.json b/tsconfig.json index a944192..f1cea33 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,19 +1,8 @@ { "compilerOptions": { "lib": ["ESNext", "dom"], - "module": "esnext", - "target": "esnext", - "moduleResolution": "bundler", - "moduleDetection": "force", - "noEmit": false, - "outDir": "./dist", - "composite": true, "strict": false, - "downlevelIteration": true, - "skipLibCheck": true, "jsx": "react-jsx", - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true, "allowJs": true } } From ab468af1b4aea8542ec8048a5ae196e6025ec944 Mon Sep 17 00:00:00 2001 From: boomzero Date: Mon, 1 Jan 2024 14:40:02 +0800 Subject: [PATCH 3/8] to maintain node.js compatibility... --- tsconfig.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tsconfig.json b/tsconfig.json index f1cea33..a944192 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,19 @@ { "compilerOptions": { "lib": ["ESNext", "dom"], + "module": "esnext", + "target": "esnext", + "moduleResolution": "bundler", + "moduleDetection": "force", + "noEmit": false, + "outDir": "./dist", + "composite": true, "strict": false, + "downlevelIteration": true, + "skipLibCheck": true, "jsx": "react-jsx", + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, "allowJs": true } } From 54a7f3aa1d8f5d4b24e6ee58c64f4d108512e6fb Mon Sep 17 00:00:00 2001 From: boomzero Date: Mon, 1 Jan 2024 17:34:55 +0800 Subject: [PATCH 4/8] use deno.json --- .github/workflows/deno.yml | 2 +- .github/workflows/publish.yml | 6 +++--- deno.json | 8 ++++++++ index.ts | 3 ++- package.json | 4 ++-- 5 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 deno.json diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml index 76e0551..1fa330b 100644 --- a/.github/workflows/deno.yml +++ b/.github/workflows/deno.yml @@ -31,5 +31,5 @@ jobs: run: deno lint - name: Run tests - run: deno compile -A -c tsconfig.json index.ts + run: deno compile -A index.ts diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7cb3675..6d81f80 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -18,9 +18,9 @@ jobs: deno-version: v1.x - name: Build run: | - deno compile -A -c tsconfig.json -o bin/quicksubmit-linux index.ts - deno compile -A -c tsconfig.json -o bin/quicksubmit-win.exe --target x86_64-pc-windows-msvc index.ts - deno compile -A -c tsconfig.json -o bin/quicksubmit-macos --target x86_64-apple-darwin index.ts + deno compile -A -o bin/quicksubmit-linux index.ts + deno compile -A -o bin/quicksubmit-win.exe --target x86_64-pc-windows-msvc index.ts + deno compile -A -o bin/quicksubmit-macos --target x86_64-apple-darwin index.ts - name: Upload Linux binaries to release uses: svenstaro/upload-release-action@v2 with: diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..e1f46a7 --- /dev/null +++ b/deno.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "lib": ["ESNext", "dom"], + "strict": false, + "jsx": "react-jsx", + "allowJs": true + } +} diff --git a/index.ts b/index.ts index 6b9aba5..720012a 100644 --- a/index.ts +++ b/index.ts @@ -275,9 +275,10 @@ program const rid: string = dom.window.document.querySelector( `tr.oddrow:nth-child(1) > td:nth-child(2)`, ).innerHTML; - //let rst:string = dom.window.document.querySelector('tr.oddrow:nth-child(1) > td:nth-child(5) > a:nth-child(1)').innerHTML; + let rst:string = dom.window.document.querySelector('tr.oddrow:nth-child(1) > td:nth-child(5) > a:nth-child(1)').innerHTML; console.log(`Submitted ${file} to problem ${rPID}!`); console.log(`Submission ID: ${rid}`); + console.log(rst); const logoutReq = await fetch("https://www.xmoj.tech/logout.php", { "credentials": "include", "headers": { diff --git a/package.json b/package.json index 2439d60..b022cff 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "main": "index.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "check": "deno check index.ts -c tsconfig.json", - "build": "deno compile -A -c tsconfig.json index.ts" + "check": "deno check index.ts", + "build": "deno compile -A index.ts" }, "repository": { "type": "git", From 03fad28556a2f7149bd8fd76fb56b44d29d91470 Mon Sep 17 00:00:00 2001 From: boomzero Date: Mon, 1 Jan 2024 17:38:04 +0800 Subject: [PATCH 5/8] fmt --- .fleet/run.json | 6 ++---- deno.json | 12 ++++++------ index.ts | 4 +++- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.fleet/run.json b/.fleet/run.json index 822a3ba..bef6011 100644 --- a/.fleet/run.json +++ b/.fleet/run.json @@ -1,5 +1,3 @@ { - "configurations": [ - - ] -} \ No newline at end of file + "configurations": [] +} diff --git a/deno.json b/deno.json index e1f46a7..f1cea33 100644 --- a/deno.json +++ b/deno.json @@ -1,8 +1,8 @@ { - "compilerOptions": { - "lib": ["ESNext", "dom"], - "strict": false, - "jsx": "react-jsx", - "allowJs": true - } + "compilerOptions": { + "lib": ["ESNext", "dom"], + "strict": false, + "jsx": "react-jsx", + "allowJs": true + } } diff --git a/index.ts b/index.ts index 720012a..f7b6139 100644 --- a/index.ts +++ b/index.ts @@ -275,7 +275,9 @@ program const rid: string = dom.window.document.querySelector( `tr.oddrow:nth-child(1) > td:nth-child(2)`, ).innerHTML; - let rst:string = dom.window.document.querySelector('tr.oddrow:nth-child(1) > td:nth-child(5) > a:nth-child(1)').innerHTML; + let rst: string = dom.window.document.querySelector( + "tr.oddrow:nth-child(1) > td:nth-child(5) > a:nth-child(1)", + ).innerHTML; console.log(`Submitted ${file} to problem ${rPID}!`); console.log(`Submission ID: ${rid}`); console.log(rst); From f3eeb96ccf868b29797fdfa6aa1e2c85c166fc32 Mon Sep 17 00:00:00 2001 From: boomzero Date: Wed, 3 Jul 2024 13:22:56 +0800 Subject: [PATCH 6/8] No need to break this --- deno.lock | 13 ++++++++++++- index.ts | 4 ---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/deno.lock b/deno.lock index f32ffb1..ebc4b27 100644 --- a/deno.lock +++ b/deno.lock @@ -2259,5 +2259,16 @@ } } }, - "remote": {} + "remote": {}, + "workspace": { + "packageJson": { + "dependencies": [ + "npm:@types/crypto-js@^4.2.1", + "npm:@types/jsdom@^21.1.6", + "npm:commander@^11.1.0", + "npm:crypto-js@^4.2.0", + "npm:jsdom@^23.0.1" + ] + } + } } diff --git a/index.ts b/index.ts index f7b6139..94db3eb 100644 --- a/index.ts +++ b/index.ts @@ -275,12 +275,8 @@ program const rid: string = dom.window.document.querySelector( `tr.oddrow:nth-child(1) > td:nth-child(2)`, ).innerHTML; - let rst: string = dom.window.document.querySelector( - "tr.oddrow:nth-child(1) > td:nth-child(5) > a:nth-child(1)", - ).innerHTML; console.log(`Submitted ${file} to problem ${rPID}!`); console.log(`Submission ID: ${rid}`); - console.log(rst); const logoutReq = await fetch("https://www.xmoj.tech/logout.php", { "credentials": "include", "headers": { From 29b5f1477b0c2f1b880f984abd392cb3eb285c0a Mon Sep 17 00:00:00 2001 From: boomzero Date: Wed, 3 Jul 2024 13:32:32 +0800 Subject: [PATCH 7/8] display a url to fix #1 --- index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/index.ts b/index.ts index 94db3eb..4819c9d 100644 --- a/index.ts +++ b/index.ts @@ -277,6 +277,7 @@ program ).innerHTML; console.log(`Submitted ${file} to problem ${rPID}!`); console.log(`Submission ID: ${rid}`); + console.log(`Submission URL: \u001b]8;;https://www.xmoj.tech/reinfo.php?sid=${rid}\u001b\\https://www.xmoj.tech/reinfo.php?sid=${rid}\u001b]8;;\u001b\\`); const logoutReq = await fetch("https://www.xmoj.tech/logout.php", { "credentials": "include", "headers": { From 64951abbf2aca23df06a4d82006d9f85c32eff42 Mon Sep 17 00:00:00 2001 From: boomzero Date: Wed, 3 Jul 2024 13:33:15 +0800 Subject: [PATCH 8/8] fmt --- index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 4819c9d..c84b97b 100644 --- a/index.ts +++ b/index.ts @@ -277,7 +277,9 @@ program ).innerHTML; console.log(`Submitted ${file} to problem ${rPID}!`); console.log(`Submission ID: ${rid}`); - console.log(`Submission URL: \u001b]8;;https://www.xmoj.tech/reinfo.php?sid=${rid}\u001b\\https://www.xmoj.tech/reinfo.php?sid=${rid}\u001b]8;;\u001b\\`); + console.log( + `Submission URL: \u001b]8;;https://www.xmoj.tech/reinfo.php?sid=${rid}\u001b\\https://www.xmoj.tech/reinfo.php?sid=${rid}\u001b]8;;\u001b\\`, + ); const logoutReq = await fetch("https://www.xmoj.tech/logout.php", { "credentials": "include", "headers": {