allow to get new captcha when ocr fail in chrome extension.

master
Your Name 2024-01-25 11:01:42 +08:00
parent 7108f4179c
commit 1f6bcdb2ac
4 changed files with 94 additions and 36 deletions

View File

@ -16,3 +16,17 @@ function getCookie(cname) {
}
return "";
}
function get_url_parameter(sParam, sPageURL) {
var sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
}

View File

@ -144,6 +144,21 @@ storage.get('settings', function (items)
}
});
function get_remote_url(settings)
{
let remote_url_string = "";
if(settings) {
let remote_url_array = [];
if(settings.advanced.remote_url.length > 0) {
remote_url_array = JSON.parse('[' + settings.advanced.remote_url +']');
}
if(remote_url_array.length) {
remote_url_string = remote_url_array[0];
}
}
return remote_url_string;
}
storage.get('status', function (items)
{
if (items.status && items.status=='ON')
@ -154,14 +169,7 @@ storage.get('status', function (items)
// ocr
if(settings.ocr_captcha.enable) {
let remote_url_string = "";
let remote_url_array = [];
if(settings.advanced.remote_url.length > 0) {
remote_url_array = JSON.parse('[' + settings.advanced.remote_url +']');
}
if(remote_url_array.length) {
remote_url_string = remote_url_array[0];
}
let remote_url_string = get_remote_url(settings);
if(!ibon_orc_image_ready(remote_url_string)) {
myInterval = setInterval(() => {
ibon_orc_image_ready(remote_url_string);

View File

@ -52,12 +52,13 @@ chrome.runtime.onMessage.addListener((message) => {
function ticket_set_ocr_answer(answer)
{
//console.log("answer:"+answer);
console.log("answer:"+answer);
if(answer.length > 0) {
const currentUrl = window.location.href;
const domain = currentUrl.split('/')[2];
const scrip_page = currentUrl.split('/')[5];
if(answer.length == 4) {
answer = answer.toUpperCase();
let query_string = "div.form-group input[autocomplete='off']";
if(domain.indexOf('kham') > -1) {
@ -69,6 +70,25 @@ function ticket_set_ocr_answer(answer)
//$("#aspnetForm").submit();
let done_div="<div style='display:none' id='done'></div>";
$("body").append(done_div);
} else {
let query_string = "div.form-group a img";
if(domain.indexOf('kham') > -1) {
query_string = ".step2Login a img";
}
let onclick_event = $(query_string).attr("onclick");
let onclick_url = onclick_event.split('?')[1];
let ocr_type = get_url_parameter("TYPE", onclick_url);
//console.log("get new captcha:", onclick_event);
if(ocr_type && ocr_type.length > 0) {
let new_image_src = "/pic.aspx?TYPE="+ ocr_type +"&ts=" + new Date().getTime();
$("#chk_pic").attr("src", new_image_src);
let remote_url_string = get_remote_url(settings);
myInterval = setInterval(() => {
ticket_orc_image_ready(remote_url_string);
}, 400);
}
}
}
}
@ -120,6 +140,21 @@ storage.get('settings', function (items)
}
});
function get_remote_url(settings)
{
let remote_url_string = "";
if(settings) {
let remote_url_array = [];
if(settings.advanced.remote_url.length > 0) {
remote_url_array = JSON.parse('[' + settings.advanced.remote_url +']');
}
if(remote_url_array.length) {
remote_url_string = remote_url_array[0];
}
}
return remote_url_string;
}
storage.get('status', function (items)
{
if (items.status && items.status=='ON')
@ -129,14 +164,7 @@ storage.get('status', function (items)
// ocr
if(settings.ocr_captcha.enable) {
let remote_url_string = "";
let remote_url_array = [];
if(settings.advanced.remote_url.length > 0) {
remote_url_array = JSON.parse('[' + settings.advanced.remote_url +']');
}
if(remote_url_array.length) {
remote_url_string = remote_url_array[0];
}
let remote_url_string = get_remote_url(settings);
if(!ticket_orc_image_ready(remote_url_string)) {
myInterval = setInterval(() => {
ticket_orc_image_ready(remote_url_string);

View File

@ -204,6 +204,21 @@ storage.get('settings', function (items)
}
});
function get_remote_url(settings)
{
let remote_url_string = "";
if(settings) {
let remote_url_array = [];
if(settings.advanced.remote_url.length > 0) {
remote_url_array = JSON.parse('[' + settings.advanced.remote_url +']');
}
if(remote_url_array.length) {
remote_url_string = remote_url_array[0];
}
}
return remote_url_string;
}
storage.get('status', function (items)
{
if (items.status && items.status=='ON')
@ -215,14 +230,7 @@ storage.get('status', function (items)
// ocr
if(settings.ocr_captcha.enable) {
let remote_url_string = "";
let remote_url_array = [];
if(settings.advanced.remote_url.length > 0) {
remote_url_array = JSON.parse('[' + settings.advanced.remote_url +']');
}
if(remote_url_array.length) {
remote_url_string = remote_url_array[0];
}
let remote_url_string = get_remote_url(settings);
if(!tixcraft_orc_image_ready(remote_url_string)) {
myInterval = setInterval(() => {
tixcraft_orc_image_ready(remote_url_string);