2024-01-06, update for ibon/tixcraft.
parent
734eef7903
commit
4b3f743f33
|
@ -41,7 +41,7 @@ try:
|
|||
except Exception as exc:
|
||||
pass
|
||||
|
||||
CONST_APP_VERSION = "MaxBot (2024.01.05)"
|
||||
CONST_APP_VERSION = "MaxBot (2024.01.06)"
|
||||
|
||||
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
|
||||
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
||||
|
|
|
@ -22,7 +22,7 @@ import sys
|
|||
import threading
|
||||
import webbrowser
|
||||
|
||||
CONST_APP_VERSION = "MaxBot (2024.01.05)"
|
||||
CONST_APP_VERSION = "MaxBot (2024.01.06)"
|
||||
|
||||
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
|
||||
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
||||
|
|
|
@ -38,7 +38,7 @@ try:
|
|||
except Exception as exc:
|
||||
pass
|
||||
|
||||
CONST_APP_VERSION = "MaxBot (2024.01.05)"
|
||||
CONST_APP_VERSION = "MaxBot (2024.01.06)"
|
||||
|
||||
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
|
||||
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,21 +1,109 @@
|
|||
const storage = chrome.storage.local;
|
||||
var settings = null;
|
||||
|
||||
//console.log("start ibon area");
|
||||
|
||||
// price row.
|
||||
$("table > tbody > tr.disabled").remove();
|
||||
$("table > tbody > tr.sold-out").remove();
|
||||
$("table.table > tbody > tr.disabled").remove();
|
||||
$("table.table > tbody > tr.sold-out").remove();
|
||||
$("div.map > div > img").remove();
|
||||
$("footer").remove();
|
||||
let $tr=$("table > tbody > tr[onclick]");
|
||||
|
||||
var $tr=$("table.table > tbody > tr[onclick]");
|
||||
//console.log("$tr.length:"+$tr.length);
|
||||
if($tr.length==1) {
|
||||
//console.log("$tr.html:"+$tr.html());
|
||||
$tr.click();
|
||||
}
|
||||
|
||||
function ibon_area_ready(settings) {
|
||||
let area_keyword_array = [];
|
||||
if(settings) {
|
||||
if(settings.area_auto_select.area_keyword.length > 0) {
|
||||
if(settings.area_auto_select.area_keyword!='""') {
|
||||
area_keyword_array = JSON.parse('[' + settings.area_auto_select.area_keyword +']');
|
||||
}
|
||||
}
|
||||
}
|
||||
//let target_area = [];
|
||||
|
||||
let target_row=null;
|
||||
let all_row = $("table.table > tbody > tr[onclick]");
|
||||
if (all_row.length > 0)
|
||||
{
|
||||
if (all_row.length == 1) {
|
||||
// single select.
|
||||
target_row=all_row;
|
||||
} else {
|
||||
// multi select.
|
||||
all_row.each(function ()
|
||||
{
|
||||
//console.log(all_row.index(this));
|
||||
let is_match_keyword = false;
|
||||
if(all_row.index(this)==0) {
|
||||
target_row=$(this);
|
||||
} else {
|
||||
if(area_keyword_array.length) {
|
||||
let html_text=$(this).text();
|
||||
//console.log("html:"+html_text);
|
||||
|
||||
for (let i = 0; i < area_keyword_array.length; i++) {
|
||||
// TOOD: multi item matched, need sort.
|
||||
// target_area = get_target_area_with_order(settings, matched_block);
|
||||
|
||||
if(html_text.indexOf(area_keyword_array[i])>-1) {
|
||||
is_match_keyword = true;
|
||||
target_row=$(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(all_row.index(this)==0) {
|
||||
is_match_keyword = true;
|
||||
target_row=$(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
//console.log("is_match_keyword:"+is_match_keyword);
|
||||
if(is_match_keyword) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
if(target_row) {
|
||||
target_row.click();
|
||||
}
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
function ibon_area_clean_exclude(settings)
|
||||
{
|
||||
let exclude_keyword_array = [];
|
||||
if(settings) {
|
||||
if(settings.keyword_exclude.length > 0) {
|
||||
if(settings.keyword_exclude != '""') {
|
||||
exclude_keyword_array = JSON.parse('[' + settings.keyword_exclude +']');
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < exclude_keyword_array.length; i++) {
|
||||
$("table.table > tbody > tr").each(function ()
|
||||
{
|
||||
let html_text=$(this).text();
|
||||
//console.log("html:"+html_text);
|
||||
if(html_text.indexOf(exclude_keyword_array[i])>-1) {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ibon_area_main() {
|
||||
let reload=false;
|
||||
let $tr=$("table > tbody > tr[onclick]");
|
||||
let $tr=$("table.table > tbody > tr[onclick]");
|
||||
if($tr.length==0) {
|
||||
reload=true;
|
||||
}
|
||||
|
@ -33,6 +121,9 @@ function ibon_area_main() {
|
|||
location.reload();
|
||||
}, auto_reload_page_interval * 1000);
|
||||
}
|
||||
} else {
|
||||
ibon_area_clean_exclude(settings);
|
||||
ibon_area_ready(settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,164 @@
|
|||
// TODO: ...
|
||||
console.log("TODO: date auto click...");
|
||||
const storage = chrome.storage.local;
|
||||
var settings = null;
|
||||
|
||||
function ibon_detail_ajax_done(game_info)
|
||||
{
|
||||
let date_keyword_array = [];
|
||||
if(settings) {
|
||||
if(settings.date_auto_select.date_keyword.length > 0) {
|
||||
date_keyword_array = JSON.parse('[' + settings.date_auto_select.date_keyword +']');
|
||||
}
|
||||
}
|
||||
|
||||
let reload=false;
|
||||
let target_href = "";
|
||||
|
||||
//console.log(game_info.Item);
|
||||
if(game_info.Item.GIHtmls.length) {
|
||||
// one of game able to buy.
|
||||
let one_can_buy = false;
|
||||
|
||||
for (let i = 0; i < game_info.Item.GIHtmls.length; i++) {
|
||||
let rs = game_info.Item.GIHtmls[i];
|
||||
if(game_info.Item.GIHtmls.length==1) {
|
||||
// single row.
|
||||
if(rs.Href==null) {
|
||||
reload=true;
|
||||
} else {
|
||||
if(rs.CanBuy==false) {
|
||||
reload=true;
|
||||
} else {
|
||||
one_can_buy = true;
|
||||
target_href = rs.Href;
|
||||
}
|
||||
}
|
||||
if(reload) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// multi rows.
|
||||
if(settings) {
|
||||
let is_match_row = false;
|
||||
if(date_keyword_array.length) {
|
||||
for (let j = 0; j < date_keyword_array.length; j++) {
|
||||
// TOOD: multi item matched, need sort.
|
||||
// target_area = get_target_area_with_order(settings, matched_block);
|
||||
|
||||
if(rs.ShowSaleDate.indexOf(date_keyword_array[j])>-1) {
|
||||
is_match_row = true;
|
||||
}
|
||||
if(rs.GameInfoName.indexOf(date_keyword_array[j])>-1) {
|
||||
is_match_row = true;
|
||||
}
|
||||
if(is_match_row) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// empty keyword.
|
||||
is_match_row = true;
|
||||
}
|
||||
if(is_match_row) {
|
||||
if(rs.Href!=null) {
|
||||
if(rs.CanBuy!=false) {
|
||||
one_can_buy = true;
|
||||
target_href = rs.Href;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!reload) {
|
||||
if(one_can_buy == false) reload=true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log("reload:"+reload);
|
||||
console.log("target_href:"+target_href);
|
||||
if(reload) {
|
||||
let auto_reload_page_interval = 0.0;
|
||||
if(settings) {
|
||||
auto_reload_page_interval = settings.advanced.auto_reload_page_interval;
|
||||
}
|
||||
if(auto_reload_page_interval == 0) {
|
||||
//console.log('Start to reload now.');
|
||||
location.reload();
|
||||
} else {
|
||||
console.log('We are going to reload after few seconeds.');
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, auto_reload_page_interval * 1000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// goto target event.
|
||||
//console.log(target_href);
|
||||
if(target_href.length > 0) {
|
||||
location.href= "https://ticket.ibon.com.tw/" + target_href;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ibon_event_status_check()
|
||||
{
|
||||
const currentUrl = window.location.href;
|
||||
const event_code = currentUrl.split('/')[5];
|
||||
//console.log(currentUrl);
|
||||
//console.log(event_code);
|
||||
if(event_code){
|
||||
let api_url = "https://ticketapi.ibon.com.tw/api/ActivityInfo/GetGameInfoList";
|
||||
|
||||
"{\"id\":38042,\"hasDeadline\":true,\"SystemBrowseType\":0}"
|
||||
dataJSON = {
|
||||
id: parseInt(event_code, 10),
|
||||
hasDeadline: true,
|
||||
SystemBrowseType: 0
|
||||
}
|
||||
$.ajax({
|
||||
url: api_url,
|
||||
data: JSON.stringify(dataJSON),
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
headers: {
|
||||
"x-xsrf-token": getCookie("XSRF-TOKEN")
|
||||
},
|
||||
contentType: "application/json",
|
||||
success: function(returnData){
|
||||
ibon_detail_ajax_done(returnData);
|
||||
//console.log(returnData);
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError){
|
||||
//console.log(xhr.status);
|
||||
//console.log(thrownError);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
storage.get('settings', function (items)
|
||||
{
|
||||
if (items.settings)
|
||||
{
|
||||
settings = items.settings;
|
||||
}
|
||||
});
|
||||
|
||||
storage.get('status', function (items)
|
||||
{
|
||||
if (items.status && items.status=='ON')
|
||||
{
|
||||
console.log("start to ibon detail.");
|
||||
//console.log(document.cookie);
|
||||
//console.log(getCookie("XSRF-TOKEN"));
|
||||
ibon_event_status_check();
|
||||
} else {
|
||||
console.log('no status found');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ var settings = null;
|
|||
|
||||
$("footer").remove();
|
||||
|
||||
function assign_ticket_number(ticket_number)
|
||||
function ibon_assign_ticket_number(ticket_number)
|
||||
{
|
||||
let $main_table = $("table.table");
|
||||
if ($main_table.length > 0)
|
||||
|
@ -36,7 +36,7 @@ function assign_ticket_number(ticket_number)
|
|||
}
|
||||
}
|
||||
|
||||
function assign_adjacent_seat(flag) {
|
||||
function ibon_assign_adjacent_seat(flag) {
|
||||
//console.log("disable_adjacent_seat flag:"+flag);
|
||||
if(flag) {
|
||||
$('input[type=checkbox]').each(function() {
|
||||
|
@ -45,21 +45,133 @@ function assign_adjacent_seat(flag) {
|
|||
}
|
||||
}
|
||||
|
||||
function focus_on_captcha()
|
||||
function ibon_focus_on_captcha()
|
||||
{
|
||||
$("div.editor-box > div > input[type='text']").focus();
|
||||
}
|
||||
|
||||
var myInterval = null;
|
||||
|
||||
function ibon_get_ocr_image()
|
||||
{
|
||||
//console.log("get_ocr_image");
|
||||
let image_data = "";
|
||||
|
||||
// PS: tixcraft have different domain to use the same content script.
|
||||
const currentUrl = window.location.href;
|
||||
const domain = currentUrl.split('/')[2];
|
||||
|
||||
let image_id = 'chk_pic';
|
||||
let img = document.getElementById(image_id);
|
||||
if(img!=null) {
|
||||
let canvas = document.createElement('canvas');
|
||||
let context = canvas.getContext('2d');
|
||||
canvas.height = img.naturalHeight;
|
||||
canvas.width = img.naturalWidth;
|
||||
context.drawImage(img, 0, 0);
|
||||
let img_data = canvas.toDataURL();
|
||||
if(img_data) {
|
||||
image_data = img_data.split(",")[1];
|
||||
//console.log(image_data);
|
||||
}
|
||||
}
|
||||
return image_data;
|
||||
}
|
||||
|
||||
chrome.runtime.onMessage.addListener((message) => {
|
||||
//console.log('sent from background', message);
|
||||
ibon_set_ocr_answer(message.answer);
|
||||
});
|
||||
|
||||
function ibon_set_ocr_answer(answer)
|
||||
{
|
||||
console.log("answer:"+answer);
|
||||
if(answer.length > 0) {
|
||||
$("div.editor-box > div > input[type='text']").val(answer);
|
||||
//console.log($("div#ticket-wrap a[onclick]").length);
|
||||
//$("div#ticket-wrap a[onclick]").click();
|
||||
//$("#aspnetForm").submit();
|
||||
let done_div="<div style='display:none' id='done'></div>";
|
||||
$("body").append(done_div);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async function ibon_get_ocr_answer(api_url, image_data)
|
||||
{
|
||||
let bundle = {
|
||||
action: 'ocr',
|
||||
data: {
|
||||
'url': api_url + 'ocr',
|
||||
'image_data':image_data,
|
||||
}
|
||||
};
|
||||
|
||||
let bundle_string = JSON.stringify(bundle);
|
||||
const return_answer = await chrome.runtime.sendMessage(bundle);
|
||||
//console.log(return_answer);
|
||||
}
|
||||
|
||||
function ibon_orc_image_ready(api_url)
|
||||
{
|
||||
let ret=false;
|
||||
let image_data = ibon_get_ocr_image();
|
||||
if(image_data.length>0) {
|
||||
ret=true;
|
||||
if(myInterval) clearInterval(myInterval);
|
||||
ibon_get_ocr_answer(api_url, image_data);
|
||||
}
|
||||
//console.log("ibon_orc_image_ready:"+ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
storage.get('settings', function (items)
|
||||
{
|
||||
if (items.settings)
|
||||
{
|
||||
settings = items.settings;
|
||||
//console.log("ticket_number:"+ settings.ticket_number);
|
||||
assign_ticket_number(settings.ticket_number);
|
||||
assign_adjacent_seat(settings.advanced.disable_adjacent_seat);
|
||||
focus_on_captcha();
|
||||
} else {
|
||||
console.log('no settings found');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
storage.get('settings', function (items)
|
||||
{
|
||||
if (items.settings)
|
||||
{
|
||||
settings = items.settings;
|
||||
}
|
||||
});
|
||||
|
||||
storage.get('status', function (items)
|
||||
{
|
||||
if (items.status && items.status=='ON')
|
||||
{
|
||||
//console.log("ticket_number:"+ settings.ticket_number);
|
||||
ibon_assign_ticket_number(settings.ticket_number);
|
||||
ibon_assign_adjacent_seat(settings.advanced.disable_adjacent_seat);
|
||||
|
||||
// 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];
|
||||
}
|
||||
if(!ibon_orc_image_ready(remote_url_string)) {
|
||||
myInterval = setInterval(() => {
|
||||
ibon_orc_image_ready(remote_url_string);
|
||||
}, 100);
|
||||
}
|
||||
} else {
|
||||
// no orc, just focus;
|
||||
ibon_focus_on_captcha();
|
||||
}
|
||||
} else {
|
||||
console.log('no status found');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
var myInterval = null;
|
||||
//console.log("assign appear");
|
||||
|
||||
function kktix_area_keyword(settings, register_info)
|
||||
{
|
||||
let area_keyword_array = [];
|
||||
if(settings.area_auto_select.area_keyword.length > 0) {
|
||||
area_keyword_array = JSON.parse('[' + settings.area_auto_select.area_keyword +']');
|
||||
}
|
||||
// console.log(area_keyword_array);
|
||||
let target_area = [];
|
||||
if(area_keyword_array.length) {
|
||||
for (let i = 0; i < area_keyword_array.length; i++) {
|
||||
let matched_block=[];
|
||||
|
||||
$("div.ticket-unit").each(function ()
|
||||
{
|
||||
let html_text=$(this).text();
|
||||
if(html_text.indexOf(area_keyword_array[i])>-1) {
|
||||
matched_block.push($(this));
|
||||
}
|
||||
target_area = get_target_area_with_order(settings, matched_block);
|
||||
});
|
||||
|
||||
if (matched_block.length) {
|
||||
console.log("match keyword:" + area_keyword_array[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let query_string = "div.ticket-unit";
|
||||
let matched_block=$(query_string);
|
||||
target_area = get_target_area_with_order(settings, matched_block);
|
||||
}
|
||||
|
||||
if (target_area.length) {
|
||||
let first_node = target_area.find(":first-child");
|
||||
let link_id = first_node.attr("id");
|
||||
//console.log("link_id: " + link_id);
|
||||
if(link_id) {
|
||||
$('input[type=checkbox]').each(function() {
|
||||
//$(this).prop('checked', true);
|
||||
if(!$(this).is(':checked')) {
|
||||
$(this).click();
|
||||
}
|
||||
});
|
||||
|
||||
let seat_inventory_key=link_id.split("_")[1];
|
||||
let seat_inventory_number=register_info.inventory.seatInventory[seat_inventory_key];
|
||||
let ticket_number = settings.ticket_number;
|
||||
if(seat_inventory_number<ticket_number) {
|
||||
ticket_number=seat_inventory_number;
|
||||
}
|
||||
|
||||
if(ticket_number>0) {
|
||||
/*
|
||||
let target_input = target_area.find("input");
|
||||
target_input.click();
|
||||
target_input.prop("value", ticket_number);
|
||||
let down = $.Event('keydown');
|
||||
down.key=""+ticket_number;
|
||||
target_input.trigger(down);
|
||||
|
||||
let up = $.Event('keyup');
|
||||
up.key=""+ticket_number;
|
||||
target_input.trigger(up);
|
||||
*/
|
||||
let add_button = target_area.find('button[ng-click="quantityBtnClick(1)"]');
|
||||
for(let i=0; i<ticket_number; i++) {
|
||||
add_button.click();
|
||||
}
|
||||
|
||||
let $next_btn = $('div.register-new-next-button-area > button');
|
||||
$next_btn.click();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log("not target_area found.")
|
||||
}
|
||||
}
|
||||
|
||||
function begin()
|
||||
{
|
||||
console.log("begin to next");
|
||||
$("div#ticket-wrap a[onclick]").click();
|
||||
}
|
||||
|
||||
function dom_ready()
|
||||
{
|
||||
let ret=false;
|
||||
if($("#done").length>0) {
|
||||
$("#done").remove();
|
||||
ret=true;
|
||||
if(myInterval) clearInterval(myInterval);
|
||||
begin();
|
||||
}
|
||||
console.log("dom_ready:"+ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(!dom_ready()) {
|
||||
myInterval = setInterval(() => {
|
||||
dom_ready();
|
||||
}, 100);
|
||||
}
|
|
@ -4,32 +4,29 @@ var myInterval = null;
|
|||
function kktix_area_keyword(settings, register_info)
|
||||
{
|
||||
let area_keyword_array = [];
|
||||
if(settings) {
|
||||
if(settings.area_auto_select.area_keyword.length > 0) {
|
||||
if(settings.area_auto_select.area_keyword!='""') {
|
||||
area_keyword_array = JSON.parse('[' + settings.area_auto_select.area_keyword +']');
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log(area_keyword_array);
|
||||
let target_area = [];
|
||||
if(area_keyword_array.length) {
|
||||
for (let i = 0; i < area_keyword_array.length; i++) {
|
||||
let matched_flag=false;
|
||||
let matched_block=[];
|
||||
|
||||
$("div.ticket-unit").each(function ()
|
||||
{
|
||||
let html_text=$(this).text();
|
||||
if(html_text.indexOf(exclude_keyword_array[i])>-1) {
|
||||
is_match_keyword=true;
|
||||
}
|
||||
if(is_match_keyword) {
|
||||
if(html_text.indexOf(area_keyword_array[i])>-1) {
|
||||
matched_block.push($(this));
|
||||
}
|
||||
target_area = get_target_area_with_order(settings, matched_block);
|
||||
if (target_area.length) {
|
||||
matched_flag=true;
|
||||
}
|
||||
});
|
||||
|
||||
if (matched_flag) {
|
||||
if (matched_block.length) {
|
||||
console.log("match keyword:" + area_keyword_array[i]);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,14 @@ var myInterval = null;
|
|||
function kktix_clean_exclude(settings, register_info)
|
||||
{
|
||||
let exclude_keyword_array = [];
|
||||
if(settings) {
|
||||
if(settings.keyword_exclude.length > 0) {
|
||||
if(settings.keyword_exclude != '""') {
|
||||
exclude_keyword_array = JSON.parse('[' + settings.keyword_exclude +']');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < exclude_keyword_array.length; i++) {
|
||||
$("div.ticket-unit").each(function ()
|
||||
{
|
||||
|
|
|
@ -8,9 +8,14 @@ $("footer").remove();
|
|||
function tixcraft_clean_exclude(settings)
|
||||
{
|
||||
let exclude_keyword_array = [];
|
||||
if(settings) {
|
||||
if(settings.keyword_exclude.length > 0) {
|
||||
if(settings.keyword_exclude != '""') {
|
||||
exclude_keyword_array = JSON.parse('[' + settings.keyword_exclude +']');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < exclude_keyword_array.length; i++) {
|
||||
$("ul.area-list > li > a:contains('"+ exclude_keyword_array[i] +"')").each(function ()
|
||||
{
|
||||
|
@ -23,9 +28,13 @@ function tixcraft_clean_exclude(settings)
|
|||
function tixcraft_area_keyword(settings)
|
||||
{
|
||||
let area_keyword_array = [];
|
||||
if(settings) {
|
||||
if(settings.area_auto_select.area_keyword.length > 0) {
|
||||
if(settings.area_auto_select.area_keyword!='""') {
|
||||
area_keyword_array = JSON.parse('[' + settings.area_auto_select.area_keyword +']');
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log(area_keyword_array);
|
||||
let target_area=[];
|
||||
if(area_keyword_array.length) {
|
||||
|
|
|
@ -27,9 +27,13 @@ function date_clean()
|
|||
function date_keyword(settings)
|
||||
{
|
||||
let date_keyword_array = [];
|
||||
if(settings) {
|
||||
if(settings.date_auto_select.date_keyword.length > 0) {
|
||||
if(settings.date_auto_select.date_keyword!='""') {
|
||||
date_keyword_array = JSON.parse('[' + settings.date_auto_select.date_keyword +']');
|
||||
}
|
||||
}
|
||||
}
|
||||
//console.log(date_keyword_array);
|
||||
let target_date;
|
||||
if(date_keyword_array.length) {
|
||||
|
|
|
@ -9,26 +9,99 @@ $('input[type=checkbox]').each(function ()
|
|||
$("img[style='width: 100%; padding: 0;']").remove();
|
||||
$("footer").remove();
|
||||
|
||||
function assign_ticket_number(ticket_number)
|
||||
function tixcraft_ticket_clean_exclude(settings)
|
||||
{
|
||||
if ($("#ticketPriceList select").length > 0)
|
||||
let exclude_keyword_array = [];
|
||||
if(settings) {
|
||||
if(settings.keyword_exclude.length > 0) {
|
||||
if(settings.keyword_exclude!='""') {
|
||||
exclude_keyword_array = JSON.parse('[' + settings.keyword_exclude +']');
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < exclude_keyword_array.length; i++) {
|
||||
$("#ticketPriceList > tbody > tr").each(function ()
|
||||
{
|
||||
let $ticket_options = $("#ticketPriceList select:first option");
|
||||
let html_text=$(this).text();
|
||||
//console.log("html:"+html_text);
|
||||
if(html_text.indexOf(exclude_keyword_array[i])>-1) {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function tixcraft_assign_ticket_number(settings)
|
||||
{
|
||||
let area_keyword_array = [];
|
||||
if(settings) {
|
||||
if(settings.area_auto_select.area_keyword.length > 0) {
|
||||
if(settings.area_auto_select.area_keyword!='""') {
|
||||
area_keyword_array = JSON.parse('[' + settings.area_auto_select.area_keyword +']');
|
||||
}
|
||||
}
|
||||
}
|
||||
//let target_area = [];
|
||||
|
||||
let target_row=null;
|
||||
let all_row = $("#ticketPriceList > tbody > tr");
|
||||
if (all_row.length > 0)
|
||||
{
|
||||
if (all_row.length == 1) {
|
||||
// single select.
|
||||
target_row=all_row;
|
||||
} else {
|
||||
// single select.
|
||||
all_row.each(function ()
|
||||
{
|
||||
//console.log(all_row.index(this));
|
||||
let is_match_keyword = false;
|
||||
if(all_row.index(this)==0) {
|
||||
target_row=$(this);
|
||||
} else {
|
||||
if(area_keyword_array.length) {
|
||||
let html_text=$(this).text();
|
||||
//console.log("html:"+html_text);
|
||||
|
||||
for (let i = 0; i < area_keyword_array.length; i++) {
|
||||
// TOOD: multi item matched, need sort.
|
||||
// target_area = get_target_area_with_order(settings, matched_block);
|
||||
|
||||
if(html_text.indexOf(area_keyword_array[i])>-1) {
|
||||
is_match_keyword = true;
|
||||
target_row=$(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(all_row.index(this)==0) {
|
||||
is_match_keyword = true;
|
||||
target_row=$(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
//console.log("is_match_keyword:"+is_match_keyword);
|
||||
if(is_match_keyword) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let $ticket_options = target_row.find("option");
|
||||
if ($ticket_options.length)
|
||||
{
|
||||
let is_ticket_number_assign = false;
|
||||
if (ticket_number > 0)
|
||||
if (settings.ticket_number > 0)
|
||||
{
|
||||
$ticket_options.each(function ()
|
||||
{
|
||||
if ($(this).val() == ticket_number)
|
||||
if ($(this).val() == settings.ticket_number)
|
||||
{
|
||||
$(this).prop('selected', true);
|
||||
is_ticket_number_assign = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
if (!is_ticket_number_assign)
|
||||
{
|
||||
|
@ -68,19 +141,19 @@ function get_ocr_image()
|
|||
|
||||
chrome.runtime.onMessage.addListener((message) => {
|
||||
//console.log('sent from background', message);
|
||||
set_ocr_answer(message.answer);
|
||||
tixcraft_set_ocr_answer(message.answer);
|
||||
});
|
||||
|
||||
function set_ocr_answer(answer)
|
||||
function tixcraft_set_ocr_answer(answer)
|
||||
{
|
||||
console.log("answer:"+answer);
|
||||
//console.log("answer:"+answer);
|
||||
if(answer.length > 0) {
|
||||
$('#TicketForm_verifyCode').val(answer);
|
||||
$("button[type='submit']").click();
|
||||
}
|
||||
}
|
||||
|
||||
async function get_ocr_answer(api_url, image_data)
|
||||
async function tixcraft_get_ocr_answer(api_url, image_data)
|
||||
{
|
||||
let bundle = {
|
||||
action: 'ocr',
|
||||
|
@ -98,27 +171,47 @@ async function get_ocr_answer(api_url, image_data)
|
|||
//ocr(bundle.data.url, bundle.data.image_data, bundle.data.callback);
|
||||
}
|
||||
|
||||
function orc_image_ready(api_url)
|
||||
function tixcraft_orc_image_ready(api_url)
|
||||
{
|
||||
let ret=false;
|
||||
let image_data = get_ocr_image();
|
||||
if(image_data.length>0) {
|
||||
ret=true;
|
||||
if(myInterval) clearInterval(myInterval);
|
||||
get_ocr_answer(api_url, image_data);
|
||||
tixcraft_get_ocr_answer(api_url, image_data);
|
||||
}
|
||||
console.log("orc_image_ready:"+ret);
|
||||
//console.log("orc_image_ready:"+ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
storage.get('settings', function (items)
|
||||
{
|
||||
if (items.settings)
|
||||
{
|
||||
settings = items.settings;
|
||||
} else {
|
||||
console.log('no settings found');
|
||||
}
|
||||
});
|
||||
|
||||
storage.get('settings', function (items)
|
||||
{
|
||||
if (items.settings)
|
||||
{
|
||||
settings = items.settings;
|
||||
}
|
||||
});
|
||||
|
||||
storage.get('status', function (items)
|
||||
{
|
||||
if (items.status && items.status=='ON')
|
||||
{
|
||||
tixcraft_ticket_clean_exclude(settings);
|
||||
|
||||
//console.log("ticket_number:"+ settings.ticket_number);
|
||||
assign_ticket_number(settings.ticket_number);
|
||||
tixcraft_assign_ticket_number(settings);
|
||||
|
||||
// ocr
|
||||
if(settings.ocr_captcha.enable) {
|
||||
let remote_url_string = "";
|
||||
let remote_url_array = [];
|
||||
|
@ -128,13 +221,14 @@ storage.get('settings', function (items)
|
|||
if(remote_url_array.length) {
|
||||
remote_url_string = remote_url_array[0];
|
||||
}
|
||||
if(!orc_image_ready(remote_url_string)) {
|
||||
if(!tixcraft_orc_image_ready(remote_url_string)) {
|
||||
myInterval = setInterval(() => {
|
||||
orc_image_ready(remote_url_string);
|
||||
tixcraft_orc_image_ready(remote_url_string);
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('no settings found');
|
||||
console.log('no status found');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
"https://ticketmaster.sg/ticket/ticket/*"
|
||||
],
|
||||
"run_at": "document_end",
|
||||
"js" : [ "jquery.min.js", "js/tixcraft_ticket.js" ]
|
||||
"js" : [ "jquery.min.js", "js/common.js", "js/tixcraft_ticket.js" ]
|
||||
},
|
||||
{
|
||||
"matches" : [ "https://ticket.com.tw/application/utk01/utk0101_.aspx" ],
|
||||
|
@ -141,7 +141,7 @@
|
|||
},
|
||||
{
|
||||
"matches" : [ "https://ticket.ibon.com.tw/ActivityInfo/Details/*" ],
|
||||
"run_at": "document_end",
|
||||
"run_at": "document_start",
|
||||
"js" : [ "jquery.min.js", "js/ibon_detail.js" ]
|
||||
},
|
||||
{
|
||||
|
@ -157,6 +157,15 @@
|
|||
"run_at": "document_end",
|
||||
"js" : [ "jquery.min.js", "js/ibon_ticket.js" ]
|
||||
},
|
||||
{
|
||||
"matches" : [
|
||||
"https://orders.ibon.com.tw/application/UTK02/UTK0201_001.aspx?PERFORMANCE_ID=*PERFORMANCE_PRICE_AREA_ID=*",
|
||||
"https://orders.ibon.com.tw/application/UTK02/UTK0202_.aspx?PERFORMANCE_ID=*PERFORMANCE_PRICE_AREA_ID=*"
|
||||
],
|
||||
"run_at": "document_end",
|
||||
"world": "MAIN",
|
||||
"js" : [ "jquery.min.js", "js/ibon_ticket_next.js" ]
|
||||
},
|
||||
{
|
||||
"matches" : [
|
||||
"https://msg.cityline.com/*.html*"
|
||||
|
@ -224,5 +233,5 @@
|
|||
"js" : [ "jquery.min.js", "js/common.js", "js/kktix_registrations_reload.js" ]
|
||||
}
|
||||
],
|
||||
"version": "1.0.3"
|
||||
"version": "1.0.4"
|
||||
}
|
|
@ -11,6 +11,20 @@
|
|||
<div id="message"></div>
|
||||
<h2>MaxBot Settings</h2>
|
||||
|
||||
<div class="row g-3">
|
||||
|
||||
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home-tab-pane" type="button" role="tab" aria-controls="home-tab-pane" aria-selected="true">Perference</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="advanced-tab" data-bs-toggle="tab" data-bs-target="#advanced-tab-pane" type="button" role="tab" aria-controls="advanced-tab-pane" aria-selected="false">Advanced</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel" aria-labelledby="home-tab" tabindex="0">
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-12">
|
||||
<label for="ticket_number" class="form-label">Ticket Number</label>
|
||||
|
@ -61,7 +75,12 @@
|
|||
<label for="keyword_exclude" class="form-label">Exclude Keywords</label>
|
||||
<textarea class="form-control" id="keyword_exclude" rows="3"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="tab-pane fade" id="advanced-tab-pane" role="tabpanel" aria-labelledby="advanced-tab" tabindex="0">
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-12">
|
||||
<label for="auto_reload_page_interval" class="form-label">Reload page interval(sec.)</label>
|
||||
<input class="form-control" id="auto_reload_page_interval" value="" />
|
||||
|
@ -85,17 +104,20 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-12">
|
||||
<label for="remote_url" class="form-label">Remote URL</label>
|
||||
<input class="form-control" id="remote_url" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" id="save_btn">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -29,10 +29,23 @@ async function saveChanges()
|
|||
if(settings) {
|
||||
settings.ticket_number = ticket_number_value;
|
||||
settings.date_auto_select.mode = date_select_mode.value;
|
||||
settings.date_auto_select.date_keyword = date_keyword.value;
|
||||
|
||||
let date_keyword_string = date_keyword.value;
|
||||
if(date_keyword_string.indexOf('"')==-1) {
|
||||
date_keyword_string = '"' + date_keyword_string + '"';
|
||||
}
|
||||
settings.date_auto_select.date_keyword = date_keyword_string;
|
||||
|
||||
settings.area_auto_select.mode = area_select_mode.value;
|
||||
settings.area_auto_select.area_keyword = area_keyword.value;
|
||||
|
||||
let area_keyword_string = area_keyword.value;
|
||||
if(area_keyword_string.indexOf('"')==-1) {
|
||||
area_keyword_string = '"' + area_keyword_string + '"';
|
||||
}
|
||||
settings.area_auto_select.area_keyword = area_keyword_string;
|
||||
|
||||
settings.keyword_exclude = keyword_exclude.value;
|
||||
|
||||
settings.advanced.auto_reload_page_interval = auto_reload_page_interval.value;
|
||||
settings.advanced.disable_adjacent_seat = disable_adjacent_seat.checked;
|
||||
settings.ocr_captcha.enable = ocr_captcha_enable.checked;
|
||||
|
@ -67,8 +80,16 @@ function loadChanges()
|
|||
ticket_number.value = settings.ticket_number;
|
||||
date_select_mode.value = settings.date_auto_select.mode;
|
||||
date_keyword.value = settings.date_auto_select.date_keyword;
|
||||
if(date_keyword.value=='""') {
|
||||
date_keyword.value='';
|
||||
}
|
||||
|
||||
area_select_mode.value = settings.area_auto_select.mode;
|
||||
area_keyword.value = settings.area_auto_select.area_keyword;
|
||||
if(area_keyword.value=='""') {
|
||||
area_keyword.value='';
|
||||
}
|
||||
|
||||
keyword_exclude.value = settings.keyword_exclude;
|
||||
auto_reload_page_interval.value = settings.advanced.auto_reload_page_interval;
|
||||
disable_adjacent_seat.checked = settings.advanced.disable_adjacent_seat;
|
||||
|
|
Loading…
Reference in New Issue