This commit is contained in:
zino
2021-03-03 01:23:32 +01:00
parent 2a81dfec0e
commit a566040f3f
5 changed files with 133 additions and 3 deletions

View File

78
client/src/inject.ts Normal file
View File

@@ -0,0 +1,78 @@
import jQuery = require("jquery");
interface IinputsWithValue {
[HTMLInputElement: string]: string;
}
interface IConfig {
debug: boolean,
branch: string
}
const config: IConfig = {
debug: true,
branch: "staging"
}
const checkoutParams: string[] = [
'APPTE', 'age_consent_is_checked', 'agency', 'cancelAndRedirectTrxState', 'cogid', 'coids', 'discount=A=IE', 'discount=A=IV', 'discountdesc=A=IE', 'discountdesc=A=IV', 'discountfees=A=IE', 'discountfees=A=IV', 'discountprice=A=IE', 'discountprice=A=IV', 'dpa_selection', 'etpgcode', 'flashDetected', 'gid', 'hbx_discount_prices', 'hbx_discounts', 'hbx_offered_pg', 'hbx_perf_codes', 'hbx_perf_sub_codes', 'hbx_pids', 'hbx_requested_pg', 'hbx_selected_tixx', 'hbx_upsell_flag', 'request_type', 'invalid_seats', 'inventory_filtering_action', 'inventory_month', 'inventory_year', 'isCapEnabled', 'is_availability_switch_from_map', 'is_ticket_exchange_request', 'ism_map_current_state_json_data', 'jcarousel_auto_off_val', 'listing_type', 'mainEventPID', 'map_coupon_code', 'mlbamsp', 'oid', 'ooids', 'orderkey', 'orgid', 'p_orgid', 'package_pids', 'parent_offer_id', 'pay_pal_token', 'pid', 'prevtrxstate', 'recapToken', 'redeem_voucher_data_event_mapping', 'replay_request', 'request_action', 's_mem_tkt_ren_retrieval', 'schedule', 'secure_trxn_enabled', 'selected_seat_indexes', 'selected_upsell_option', 'supplierCode', 'supplier_code', 'target_name_value', 'target_prev_trxstate', 'target_trxstate', 'target_url', 'timeout_seconds', 'trxstate', 'upsell_selected', 'user_context', 'valid_coupon_code_message'
];
jQuery(document).ready(() => {
const content: string = new XMLSerializer().serializeToString(document);
const inputsWithValue: IinputsWithValue = getInputs(content);
console.log(inputsWithValue);
checkTrxState(inputsWithValue, content);
});
function getInputs(inContent: string): IinputsWithValue {
let inputsWithValue: IinputsWithValue = {};
const parsedHTML: Node[] = jQuery.parseHTML(inContent);
jQuery(parsedHTML).find('input').each(function() {
if (this.value !== '' && checkoutParams.includes(this.name))
inputsWithValue[this.name] = this.value;
});
inputsWithValue["posturl"] = inContent.match(/posturl:"(.+?)"/)![1];
inputsWithValue["event"] = inContent.match(/event:"(.+?)"/)![1];
inputsWithValue["holdcode"] = inContent.match(/holdcode:"(.+?)"/)![1];
return inputsWithValue;
}
function checkTrxState(inInputsWithValue: IinputsWithValue, content: string): void {
if (!jQuery.isEmptyObject(inInputsWithValue)) {
if (inInputsWithValue.hasOwnProperty("trxstate") && inInputsWithValue["trxstate"] === "20") {
getImportantNote(inInputsWithValue);
showSeatmapButton();
injectSeatmap(inInputsWithValue, content);
}
else if (inInputsWithValue.hasOwnProperty("prevtrxstate") && inInputsWithValue["prevtrxstate"] === "30")
console.log("prevtrxstate 30 identified");
else
console.log("No action set: trxstate: " + inInputsWithValue["trxstate"]);
}
}
// todo: check with different venues
function getImportantNote(inInputsWithValue: IinputsWithValue): void {
const importantNote: string | null = jQuery(".important_note")[0].textContent;
if (importantNote !== null && importantNote.trim().length) {
const importantNoteEncoded: string = encodeURIComponent(importantNote);
inInputsWithValue["importantNote"] = importantNote;
inInputsWithValue["importantNoteEncoded"] = importantNoteEncoded;
}
}
function showSeatmapButton(): void {
jQuery('#flash_seat_map_box_id').css('display', 'block');
jQuery('#get_flash').css('display', 'none');
}
function injectSeatmap(inInputsWithValue: IinputsWithValue, content: string): void {
}