add delay when auto reload for ticket-plus.

master
unknown 2024-01-05 11:41:43 +08:00
parent 9f8b92f232
commit 6b8602987f
7 changed files with 45 additions and 16 deletions

View File

@ -54,7 +54,7 @@ import webbrowser
import chromedriver_autoinstaller import chromedriver_autoinstaller
CONST_APP_VERSION = "MaxBot (2023.12.22)" CONST_APP_VERSION = "MaxBot (2023.12.23)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
@ -12109,6 +12109,7 @@ def ticketplus_main(driver, url, config_dict, ocr, Captcha_Browser, ticketplus_d
is_reloading = False is_reloading = False
# move below code to extension. # move below code to extension.
#is_reloading = ticketplus_order_auto_reload_coming_soon(driver) #is_reloading = ticketplus_order_auto_reload_coming_soon(driver)
if not is_reloading: if not is_reloading:
is_captcha_sent, ticketplus_dict = ticketplus_order(driver, config_dict, ocr, Captcha_Browser, ticketplus_dict) is_captcha_sent, ticketplus_dict = ticketplus_order(driver, config_dict, ocr, Captcha_Browser, ticketplus_dict)

View File

@ -22,7 +22,7 @@ import sys
import threading import threading
import webbrowser import webbrowser
CONST_APP_VERSION = "MaxBot (2023.12.22)" CONST_APP_VERSION = "MaxBot (2023.12.23)"
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -34,7 +34,7 @@ import ssl
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
CONST_APP_VERSION = "MaxBot (2023.12.22)" CONST_APP_VERSION = "MaxBot (2023.12.23)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
@ -246,7 +246,7 @@ def load_translate():
zh_tw["pass_date_is_sold_out"] = '避開「搶購一空」的日期' zh_tw["pass_date_is_sold_out"] = '避開「搶購一空」的日期'
zh_tw["auto_reload_coming_soon_page"] = '自動刷新倒數中的日期頁面' zh_tw["auto_reload_coming_soon_page"] = '自動刷新倒數中的日期頁面'
zh_tw["auto_reload_page_interval"] = '自動刷新頁面間隔(秒)(香港)' zh_tw["auto_reload_page_interval"] = '自動刷新頁面間隔(秒)(香港)'
zh_tw["auto_reload_random_delay"] = '自動刷新時隨機延遲(台灣)' zh_tw["auto_reload_random_delay"] = '刷新清票建議增加隨機延遲(台灣)'
zh_tw["proxy_server_port"] = 'Proxy IP:PORT' zh_tw["proxy_server_port"] = 'Proxy IP:PORT'
zh_tw["area_select_order"] = '區域排序方式' zh_tw["area_select_order"] = '區域排序方式'

View File

@ -27,7 +27,7 @@ import pyperclip
import tornado import tornado
from tornado.web import Application from tornado.web import Application
CONST_APP_VERSION = "MaxBot (2023.12.22)" CONST_APP_VERSION = "MaxBot (2023.12.23)"
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt" CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"

View File

@ -26369,10 +26369,8 @@ const session_id = currentUrl.split('/')[5];
//console.log(session_id); //console.log(session_id);
var retry_count =0; var retry_count =0;
console.log("retry_count:"+retry_count);
function get_event_status(real_event_id, real_session_id) { function get_event_status(real_event_id, real_session_id) {
console.log("get_event_status")
console.log("retry_count:"+retry_count);
storage.get('status', function (items) storage.get('status', function (items)
{ {
if (items.status && items.status=='ON') if (items.status && items.status=='ON')
@ -26413,15 +26411,42 @@ function get_event_status_core(real_event_id, real_session_id) {
if(data.result.session[0].status=="pending" || data.result.session[0].status=="soldout") { if(data.result.session[0].status=="pending" || data.result.session[0].status=="soldout") {
retry_count +=1; retry_count +=1;
chrome.storage.local.set({'ticketplus_last_status': real_session_id + "-FAIL" }); chrome.storage.local.set({'ticketplus_last_status': real_session_id + "-FAIL" });
storage.get('settings', function (items)
{
if (items.settings)
{
if(!items.settings.advanced.auto_reload_random_delay) {
location.reload(); location.reload();
} else {
setTimeout(function () {
location.reload();
}, 8000);
}
} else {
console.log('no settings found');
}
}
);
storage.get('status', function (items)
{
if (items.status && items.status=='ON')
{
get_event_status_core(real_event_id, real_session_id);
} else {
console.log('no status found');
}
});
} }
//console.log("retry_count:"+retry_count); //console.log("retry_count:"+retry_count);
if(data.result.session[0].status=="onsale") { if(data.result.session[0].status=="onsale") {
chrome.storage.local.set({'ticketplus_last_status': real_session_id + "-OK" }); //chrome.storage.local.set({'ticketplus_last_status': real_session_id + "-OK" });
// no need to check last status if "run_at": "document_start". // no need to check last status if "run_at": "document_start".
//if(last_status==real_session_id + "-FAIL") { //if(last_status==real_session_id + "-FAIL") {
location.reload(); //location.reload();
//} //}
} }
}) })

View File

@ -63,11 +63,11 @@
<label for="keyword_exclude" class="form-label">Exclude Keywords</label> <label for="keyword_exclude" class="form-label">Exclude Keywords</label>
<textarea class="form-control" id="keyword_exclude" rows="3"></textarea> <textarea class="form-control" id="keyword_exclude" rows="3"></textarea>
</div> </div>
<!-- div class="col-12"> <div class="col-12">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="checkbox" id="gridCheck"> <input class="form-check-input" type="checkbox" id="auto_reload_random_delay">
<label class="form-check-label" for="gridCheck"> <label class="form-check-label" for="auto_reload_random_delay">
Check me out Add random delay for auto reload
</label> </label>
</div> </div>
</div --> </div -->

View File

@ -7,6 +7,7 @@ const date_keyword = document.querySelector('#date_keyword');
const area_select_mode = document.querySelector('#area_select_mode'); const area_select_mode = document.querySelector('#area_select_mode');
const area_keyword = document.querySelector('#area_keyword'); const area_keyword = document.querySelector('#area_keyword');
const keyword_exclude = document.querySelector('#keyword_exclude'); const keyword_exclude = document.querySelector('#keyword_exclude');
const auto_reload_random_delay = document.querySelector('#auto_reload_random_delay');
var settings = null; var settings = null;
loadChanges(); loadChanges();
@ -28,6 +29,7 @@ async function saveChanges()
settings.area_auto_select.mode = area_select_mode.value; settings.area_auto_select.mode = area_select_mode.value;
settings.area_auto_select.area_keyword = area_keyword.value; settings.area_auto_select.area_keyword = area_keyword.value;
settings.keyword_exclude = keyword_exclude.value; settings.keyword_exclude = keyword_exclude.value;
settings.advanced.auto_reload_random_delay = auto_reload_random_delay.checked;
await storage.set( await storage.set(
{ {
@ -43,7 +45,7 @@ function loadChanges()
{ {
storage.get('settings', function (items) storage.get('settings', function (items)
{ {
console.log(items); //console.log(items);
if (items.settings) if (items.settings)
{ {
settings = items.settings; settings = items.settings;
@ -54,6 +56,7 @@ function loadChanges()
area_select_mode.value = settings.area_auto_select.mode; area_select_mode.value = settings.area_auto_select.mode;
area_keyword.value = settings.area_auto_select.area_keyword; area_keyword.value = settings.area_auto_select.area_keyword;
keyword_exclude.value = settings.keyword_exclude; keyword_exclude.value = settings.keyword_exclude;
auto_reload_random_delay.checked = settings.advanced.auto_reload_random_delay;
//message('Loaded saved settings.'); //message('Loaded saved settings.');
} else { } else {
console.log('no settings found'); console.log('no settings found');