Skip to content

Instantly share code, notes, and snippets.

@Leo7654
Last active March 18, 2024 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Leo7654/fd499e57a052ff5f0a90ab07b0816b85 to your computer and use it in GitHub Desktop.
Save Leo7654/fd499e57a052ff5f0a90ab07b0816b85 to your computer and use it in GitHub Desktop.
Auth Autofill Capcha js
// ==UserScript==
// @name Auth Autofill Capcha
// @version 2024-03-10-2
// @description Auth Autofill Capcha
// @author Leo7654
// @updateURL https://gist.github.com/Leo7654/fd499e57a052ff5f0a90ab07b0816b85/raw/fa68198eed37b3545daa343da3669faf6292a8bd/AuthAutofillCapcha.user.js
// @match https://nice.checkplus.co.kr/cert/mobileCert/certification
// @icon https://www.google.com/s2/favicons?sz=64&domain=checkplus.co.kr
// @grant none
// @require https://cdn.jsdelivr.net/npm/tesseract.js@5/dist/tesseract.min.js
// ==/UserScript==
(function() {
var img = 'https://nice.checkplus.co.kr/cert/captcha/image/6f814745410dd12b17d0135fbab259ef05595aefdfa1e70b212562d09b49d965'
img = document.getElementById("simpleCaptchaImg");
const run = (async () => {
const blob = await getImageBlob(img)
img.src = URL.createObjectURL(blob)
const worker = await Tesseract.createWorker('eng', {
tessedit_char_whitelist: '0123456789',
});
const ret = await worker.recognize(blob);
console.log(ret);
worker.terminate();
const text = ret.data.text
console.log(text);
document.getElementById("captchaAnswer").value = text
});
async function getImageBlob(img) {
return new Promise(resolve => {
var x = new XMLHttpRequest();
x.open('GET', img.src);
x.responseType = 'blob';
x.onload = function() {
var blob = x.response;
resolve(blob)
};
x.send();
});
}
run()
})();
@ParkJeongseop
Copy link

안녕하세요!
리뷰에 남긴 메시지 보고 왔습니다.
먼저 좋은 코드 감사드립니다.

해당 코드로 nice.checkplus.co.kr 인증기관으로 테스트해보았는데 캡챠다 보니 정확도가 떨어지는것같습니다. 제가 적용을 잘못한건지 Tampermonkey 코드로 보이는데 정확도가 잘나오나요?

또 화이트리스트로 정수만 인식되도록 한것같은데 알파벳으로 인식하는 경우도 있는것같습니다.

@Leo7654
Copy link
Author

Leo7654 commented Mar 18, 2024

안녕하세요! 리뷰에 남긴 메시지 보고 왔습니다. 먼저 좋은 코드 감사드립니다.

해당 코드로 nice.checkplus.co.kr 인증기관으로 테스트해보았는데 캡챠다 보니 정확도가 떨어지는것같습니다. 제가 적용을 잘못한건지 Tampermonkey 코드로 보이는데 정확도가 잘나오나요?

또 화이트리스트로 정수만 인식되도록 한것같은데 알파벳으로 인식하는 경우도 있는것같습니다.

반갑습니다. 익스텐션 잘 쓰고 있습니다. 감사합니다.

캡챠가 신기한게 같은 주소여도 이미지를 로딩할때마다 이미지가 계속 바뀝니다. 최신의 이미지(정답)으로 로직이 구현되어 있는것 같습니다. 보이는 이미지와 답이 달라도 확인을 누르시면 뚤릴것입니다.
(getImageBlob함수의 결과를 최신 이미지로 덮어씌우는것까지 해볼까 하다 안했습니다.)

알파벳으로 인식하는것은 제가 테스트했을땐 발견하지 못했었네요. https://github.com/tesseract-ocr/tesseract 숫자만 인식하는 언어지원을 하면좋을 텐데 안하고 있네요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment