Last active
December 31, 2019 06:18
-
-
Save Gowee/afb1dfe73a7b770f2f8a441587fbc8e6 to your computer and use it in GitHub Desktop.
This file contains 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
async function run() { | |
const contest = 169; | |
const pages = [...Array(25).keys()].map(v => v + 1); | |
const question_id = 1429; | |
const is_cheating = function(code) { | |
const words = [/*"MONEY", "POINT",*/ "HOPE", "SATURN", "SEIS", "GEMINI", "ELM", "YOUVE", "PLANETS", "PEOPLE", "EHGEEE", "CANCER", "FBCDE", "TWENTY", "TREES", "EUROPE", "ABCDE", "NOVENTA", "EAII", "FUNNY", "ADICG", "FALSE", "TRUE", "EEIE", "THREE", "DHCF", "DHBADI", "INDEED"]; | |
let score = 0; | |
for (const word of words) { | |
if (code.indexOf(word) != -1) { | |
score += 1; | |
} | |
} | |
return score > 2; | |
} | |
for (const page of pages) { | |
console.log("Page: " + page); | |
const r = await fetch(`https://leetcode.com/contest/api/ranking/weekly-contest-${contest}/?pagination=${page}®ion=global`, { | |
"credentials": "include", | |
"referrer": `https://leetcode.com/contest/weekly-contest-${contest}/ranking/${page}/`, | |
"method": "GET", | |
"mode": "cors" | |
}); | |
const d = await r.json(); | |
for (const index of Array(25).keys()) { | |
const submission_id = d.submissions[index][question_id].submission_id; | |
const data_region = d.submissions[index][question_id].data_region; | |
let data_url; | |
if (data_region == "CN") { | |
data_url = "leetcode-cn.com" | |
} | |
else { | |
data_url = "leetcode.com" | |
} | |
const submission = await fetch(`https://${data_url}/api/submissions/${submission_id}/`, { | |
"credentials": "omit", | |
"referrer": `https://leetcode.com/contest/weekly-contest-${contest}/ranking/${page}/`, | |
"method": "GET", | |
"mode": "cors" | |
}); | |
const submission_data = await submission.json(); | |
if (is_cheating(submission_data.code)) { | |
console.log(`CHEATING: page ${page}, rank ${index + 1} (${d.total_rank[index].rank}), username ${d.total_rank[index].username} (${d.total_rank[index].user_slug}), region ${d.total_rank[index].data_region}`); | |
} | |
} | |
} | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment