백준허브처럼 코딩테스트를 자동커밋해주는 LeetHub를 설치하였다.
그러나 백준허브랑 다른 부분이 있어서 LeetHub를 fork해서 커스텀하였다.

설치

크롬 확장 스토어에서 LeetHub version 2 설치
version2 설치를 추천함, v3은 커스텀했을 때 정상작동하지 않음
https://chromewebstore.google.com/category/extensions?utm_source=ext_sidebar&hl=ko

fork

LeetHub version 2를 fork함
https://github.com/arunbhardwaj/LeetHub-2.0.git

fork한 레포를 로컬에 git clone해서 커스텀 진행하면 됨

1
git clone https://github.com/arunbhardwaj/LeetHub-2.0.git

경로 수정

백준허브처럼 LeetCode 폴더에 difficult별로 파일을 넣도록 수정함. 총 3부분을 수정하면 됨

1
const URL = `https://api.github.com/repos/${hook}/contents/${problem}/${filename}`;
1
const URL = `https://api.github.com/repos/${hook}/contents/LeetCode/${difficulty}/${problem}/${filename}`;

커밋 메세지 수정

기존 커밋 메세지
Time: 173 ms (8.71%), Space: 16.9 MB (82.32%) - LeetHub

수정 커밋 메세지
[Easy] Title: 1395-minimum-time-visiting-all-points, Time: 46 ms (98.2%), Space: 16.4 MB (94.93%) - LeetHub

변경 코드

  • formatStats 함수를 수정하면 됨

    1
    2
    3
    function formatStats(time, timePercentile, space, spacePercentile) {
    return `Time: ${time} (${timePercentile}%), Space: ${space} (${spacePercentile}%) - LeetHub`;
    }
    1
    2
    3
    function formatStats(qid, title, difficulty, time, timePercentile, space, spacePercentile) {
    return `[${difficulty}] Title: ${qid}.${title}, Time: ${time} (${timePercentile}%), Space: ${space} (${spacePercentile}%) - LeetHub`;
    }
  • 호출하는 부분에도 인자를 추가함

    1
    2
    3
    4
    5
    6
    7
    8
    return formatStats(
    this.submissionData.runtimeDisplay,
    runtimePercentile,
    this.submissionData.memoryDisplay,
    spacePercentile,
    );

    return formatStats(time, timePercentile, space, spacePercentile);
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    return formatStats(
    this.submissionData.question.questionId,
    this.submissionData.question.titleSlug,
    this.submissionData.question.difficulty,
    this.submissionData.runtimeDisplay,
    runtimePercentile,
    this.submissionData.memoryDisplay,
    spacePercentile,
    );

    return formatStats(this.submissionData.question.questionId, this.submissionData.question.titleSlug, this.submissionData.question.difficulty, time, timePercentile, space, spacePercentile);

README.md 커밋 삭제

백준허브랑 달리 커밋 메세지가 두개 생기는 것이 불편해서 README.md 커밋은 업로드하지 않도록 수정함.

1
2
3
4
5
6
7
8
return uploadGit(
btoa(unescape(encodeURIComponent(probStatement))),
problemName,
'README.md',
readmeMsg,
'upload',
false,
);
1
2
3
4
5
6
7
8
//  return uploadGit(
// btoa(unescape(encodeURIComponent(probStatement))),
// problemName,
// 'README.md',
// readmeMsg,
// 'upload',
// false,
// );

로컬 확장 프로그램 적용

  • 수정한 프로젝트를 아래와 같이 확장 프로그램으로 설치함


전체 수정코드

파일 경로와 커밋 메세지 수정
README.md 커밋 삭제