CAPTCHAs.IO OnlineBooking UserScript

This script is a UserScript to auto solve captchas in http://onlinebooking.sand.telangana.gov.in/Masters/Home.aspx the SSMMS or Sand Sale Management and Monitoring System website.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        CAPTCHAs.IO OnlineBooking UserScript
// @namespace   https://app.captchas.io/ssmms/
// @include     https://onlinebooking.sand.telangana.gov.in/Masters/Home.aspx
// @include     *
// @connect     app.captchas.io
// @grant       GM_xmlhttpRequest
// @version     1.0.3
// @description This script is a UserScript to auto solve captchas in http://onlinebooking.sand.telangana.gov.in/Masters/Home.aspx the SSMMS or Sand Sale Management and Monitoring System website.
// ==/UserScript==

function getBase64(img) {
	var canvas = document.createElement('canvas');
	var ctx = canvas.getContext('2d');

	canvas.width = img.width
	canvas.height = img.height
	ctx.drawImage(img, 0, 0)

	return canvas.toDataURL();
}

function doAnswer(k, b) {
	var __data = new FormData();
	__data.append("key", k);
	__data.append("body", b);

	GM_xmlhttpRequest ({
		method: "POST",
		data: __data,
		url: 'https://app.captchas.io/ssmms/validator.php',
		onload: function(response) {
			var result = JSON.parse(response.responseText);

			if (result.status == 'OK') {
				document.querySelector('#txtEnterCode').value = result.answer;
			} else {
				console.log(response.responseText);
			}
		}
	});
};

(function() {
	'use strict';
	
	var key = '<YOUR_CAPTCHAs_IO_SSMMMS_KEY>';
	var base64 = getBase64(document.getElementById("imgCaptcha"));

	doAnswer(key, base64);
})();