Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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}&region=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