Greasy Fork

Moon Captcha v2 Solver

Moon Captcha Captcha Solver by @satology @stealtosvra.

目前为 2023-03-09 提交的版本。查看 最新版本

// ==UserScript==
// @name        Moon Captcha v2 Solver 
// @namespace   moon.captcha.v2.solver
// @version     0.3
// @description Moon Captcha Captcha Solver by @satology @stealtosvra.
// @author      stealtosvra
// @match       https://coinpayz.xyz/*
// @match       https://coinpot.in/*
// @match       https://bits.re/*
// @match       https://viefaucet.com/*
// @match       https://claimtrx.com/*
// @match       https://feyorra.top/*
// @match       https://dogepool.xyz/*
// @resource    hashes https://stealtosvra.github.io/udImages/hashes.json
// @require     https://unpkg.com/[email protected]/browser/lib/jimp.min.js
// @icon        https://stealtosvra.github.io/udImages/udp.png
// @grant       GM_getResourceText
// @license     MIT
// ==/UserScript==

(function () {
  'use strict';

  const captchaImgs = document.querySelectorAll('.rscapimg, .captchaOptions');
  const hashes = JSON.parse(GM_getResourceText('hashes'));

  function readAsPng(base64Src) {
    return new Promise(resolve => {
      const base64Data = base64Src.replace(/^data:image\/png;base64,/, '');
      const buffer = Buffer.from(base64Data, 'base64');
      Jimp.read(buffer, (err, image) => {
        resolve(image);
      });
    });
  }

  async function checkImages() {
    const promises = Array.from(captchaImgs).map(async (img, i) => {
      const image = await readAsPng(img.src);
      const hash = image.hash(16);
      console.log(`IMG Hash : ${i}: ${hash}`);
      const resp = hashes.filter(x => x === hash);
      if (resp.length > 0) {
        console.log(`Matched Hash : ${i}! ${resp}`);
        const captchaImg = document.getElementById(`${i}`);
        captchaImg.dispatchEvent(new Event('click'));
      } else {
        console.log(`Not Upside Down! ${i}!`);
      }
    });
    await Promise.all(promises);
    console.log('end');
  }

  checkImages();
})();