Skip to content

Instantly share code, notes, and snippets.

@lifthrasiir
Created January 7, 2020 18:49
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 lifthrasiir/c1d83f6710a070c4dfc70dce7fc4dbe9 to your computer and use it in GitHub Desktop.
Save lifthrasiir/c1d83f6710a070c4dfc70dce7fc4dbe9 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name eagate captcha solver
// @namespace about:eagate-captcha-solver
// @version 0
// @match https://p.eagate.573.jp/gate/p/*
// @grant GM_xmlhttpRequest
// ==/UserScript==
let g_observer;
(function() {
'use strict';
// https://gist.github.com/123jimin/0ebabe54fc06b445dffdcc61c376ef13 is probably better
let sizeMap = {
7565: 'blue', 11283: 'blue', 12172: 'blue', 12943: 'blue', 14003: 'blue', 15462: 'blue',
8092: 'hotpink', 9570: 'hotpink', 9619: 'hotpink', 9939: 'hotpink', 10285: 'hotpink', 10736: 'hotpink',
8081: 'red', 9147: 'red', 10074: 'red', 10903: 'red', 12052: 'red', 12433: 'red', 12611: 'red',
7311: 'silver', 7448: 'silver', 9016: 'silver', 10307: 'silver', 11737: 'silver', 12099: 'silver',
7488: 'teal', 9188: 'teal', 9215: 'teal', 10206: 'teal', 10730: 'teal', 11260: 'teal',
};
function process(im, border, onload) {
GM_xmlhttpRequest({
method: 'GET',
url: im.src,
responseType: 'arraybuffer',
onload: r => {
let size = r.response.byteLength;
border.title = size;
if (sizeMap[size]) {
border.style.borderColor = sizeMap[size];
border.style.borderWidth = '2px';
} else {
border.style.borderColor = 'black';
border.style.borderStyle = 'dashed';
}
onload();
}
});
}
g_observer = new MutationObserver(muts => {
let correctImg = document.getElementById('id_cpfm_correct_pic');
let optionImgs = document.querySelectorAll('.cl_cpfm_choicelistbox');
if (!correctImg || optionImgs.length !== 5) return;
let count = 0;
function check() {
if (++count <= optionImgs.length) return;
let targetColor = correctImg.style.borderColor;
for (let i of optionImgs) {
if (i.style.borderColor === targetColor) i.querySelector('input').click();
}
}
process(correctImg, correctImg, check);
for (let i of optionImgs) process(i.querySelector('img'), i, check);
g_observer.disconnect();
});
g_observer.observe(document, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment