playttm 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.d.ts CHANGED
@@ -92,12 +92,15 @@ export declare class ThaiTicketMajor {
92
92
  */
93
93
  static syncCookiesToChrome(cookieString: string, domainUrl?: string): Promise<void>;
94
94
  /**
95
- * Setup declarativeNetRequest session rules in Chrome Extension to set Referer header for API requests only.
95
+ * Setup declarativeNetRequest session rules for Chrome Extension environment.
96
+ * Overrides forbidden headers (Referer, Origin) to bypass TTM and Kasikorn referrer checks.
97
+ * Uses excludedInitiatorDomains to NEVER alter requests made directly by tabs on thaiticketmajor.com.
96
98
  */
97
- /**
98
- * Setup declarativeNetRequest session rules in Chrome Extension to set Referer headers accurately for each endpoint.
99
- */
100
- static setupExtensionRules(): Promise<void>;
99
+ static setupExtensionRules(context?: {
100
+ k?: string;
101
+ zone?: string;
102
+ roundId?: string;
103
+ }): Promise<void>;
101
104
  syncCookies(domainUrl?: string): Promise<void>;
102
105
  private emitProgress;
103
106
  /**
package/dist/lib.js CHANGED
@@ -175,200 +175,370 @@ class ThaiTicketMajor {
175
175
  });
176
176
  }
177
177
  /**
178
- * Setup declarativeNetRequest session rules in Chrome Extension to set Referer header for API requests only.
178
+ * Setup declarativeNetRequest session rules for Chrome Extension environment.
179
+ * Overrides forbidden headers (Referer, Origin) to bypass TTM and Kasikorn referrer checks.
180
+ * Uses excludedInitiatorDomains to NEVER alter requests made directly by tabs on thaiticketmajor.com.
179
181
  */
180
- /**
181
- * Setup declarativeNetRequest session rules in Chrome Extension to set Referer headers accurately for each endpoint.
182
- */
183
- static setupExtensionRules() {
182
+ static setupExtensionRules(context) {
184
183
  return __awaiter(this, void 0, void 0, function* () {
185
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
184
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28;
186
185
  if (typeof chrome === "undefined" || !((_a = chrome === null || chrome === void 0 ? void 0 : chrome.declarativeNetRequest) === null || _a === void 0 ? void 0 : _a.updateSessionRules)) {
187
186
  return;
188
187
  }
188
+ const fixedReferer = ((context === null || context === void 0 ? void 0 : context.k) && (context === null || context === void 0 ? void 0 : context.zone) && (context === null || context === void 0 ? void 0 : context.roundId))
189
+ ? `https://booking.thaiticketmajor.com/booking/3m/fixed.php?k=${context.k}&zone=${context.zone}&round=${context.roundId}`
190
+ : "https://booking.thaiticketmajor.com/booking/3m/fixed.php";
191
+ const festivalReferer = ((context === null || context === void 0 ? void 0 : context.k) && (context === null || context === void 0 ? void 0 : context.zone) && (context === null || context === void 0 ? void 0 : context.roundId))
192
+ ? `https://booking.thaiticketmajor.com/booking/3m/festival.php?k=${context.k}&zone=${context.zone}&round=${context.roundId}`
193
+ : "https://booking.thaiticketmajor.com/booking/3m/festival.php";
194
+ const enrollReferer = ((context === null || context === void 0 ? void 0 : context.k) && (context === null || context === void 0 ? void 0 : context.zone) && (context === null || context === void 0 ? void 0 : context.roundId))
195
+ ? `https://booking.thaiticketmajor.com/booking/3m/enroll.php?k=${context.k}&zone=${context.zone}&round=${context.roundId}`
196
+ : "https://booking.thaiticketmajor.com/booking/3m/enroll.php";
197
+ const excludedDomains = ["booking.thaiticketmajor.com", "www.thaiticketmajor.com", "thaiticketmajor.com"];
189
198
  try {
190
- const ruleIdsToRemove = [1001, 1002, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019];
199
+ const ruleIdsToRemove = [
200
+ 1001, 1002, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019,
201
+ 1020, 1021, 1022, 1023
202
+ ];
191
203
  yield chrome.declarativeNetRequest.updateSessionRules({
192
204
  removeRuleIds: ruleIdsToRemove,
193
205
  addRules: [
194
206
  {
195
- id: 1010,
196
- priority: 20,
207
+ id: 1020,
208
+ priority: 25,
197
209
  action: {
198
210
  type: ((_b = chrome.declarativeNetRequest.RuleActionType) === null || _b === void 0 ? void 0 : _b.MODIFY_HEADERS) || "modifyHeaders",
199
211
  requestHeaders: [
200
212
  {
201
213
  header: "Referer",
202
214
  operation: ((_c = chrome.declarativeNetRequest.HeaderOperation) === null || _c === void 0 ? void 0 : _c.SET) || "set",
215
+ value: fixedReferer,
216
+ },
217
+ {
218
+ header: "Origin",
219
+ operation: ((_d = chrome.declarativeNetRequest.HeaderOperation) === null || _d === void 0 ? void 0 : _d.SET) || "set",
220
+ value: "https://booking.thaiticketmajor.com",
221
+ },
222
+ ],
223
+ },
224
+ condition: {
225
+ urlFilter: "bookingseats.php",
226
+ resourceTypes: [
227
+ ((_e = chrome.declarativeNetRequest.ResourceType) === null || _e === void 0 ? void 0 : _e.XMLHTTPREQUEST) || "xmlhttprequest",
228
+ ],
229
+ excludedInitiatorDomains: excludedDomains,
230
+ },
231
+ },
232
+ {
233
+ id: 1021,
234
+ priority: 25,
235
+ action: {
236
+ type: ((_f = chrome.declarativeNetRequest.RuleActionType) === null || _f === void 0 ? void 0 : _f.MODIFY_HEADERS) || "modifyHeaders",
237
+ requestHeaders: [
238
+ {
239
+ header: "Referer",
240
+ operation: ((_g = chrome.declarativeNetRequest.HeaderOperation) === null || _g === void 0 ? void 0 : _g.SET) || "set",
241
+ value: fixedReferer,
242
+ },
243
+ {
244
+ header: "Origin",
245
+ operation: ((_h = chrome.declarativeNetRequest.HeaderOperation) === null || _h === void 0 ? void 0 : _h.SET) || "set",
246
+ value: "https://booking.thaiticketmajor.com",
247
+ },
248
+ ],
249
+ },
250
+ condition: {
251
+ urlFilter: "validateseat.php",
252
+ resourceTypes: [
253
+ ((_j = chrome.declarativeNetRequest.ResourceType) === null || _j === void 0 ? void 0 : _j.XMLHTTPREQUEST) || "xmlhttprequest",
254
+ ],
255
+ excludedInitiatorDomains: excludedDomains,
256
+ },
257
+ },
258
+ {
259
+ id: 1022,
260
+ priority: 25,
261
+ action: {
262
+ type: ((_k = chrome.declarativeNetRequest.RuleActionType) === null || _k === void 0 ? void 0 : _k.MODIFY_HEADERS) || "modifyHeaders",
263
+ requestHeaders: [
264
+ {
265
+ header: "Referer",
266
+ operation: ((_l = chrome.declarativeNetRequest.HeaderOperation) === null || _l === void 0 ? void 0 : _l.SET) || "set",
267
+ value: festivalReferer,
268
+ },
269
+ {
270
+ header: "Origin",
271
+ operation: ((_m = chrome.declarativeNetRequest.HeaderOperation) === null || _m === void 0 ? void 0 : _m.SET) || "set",
272
+ value: "https://booking.thaiticketmajor.com",
273
+ },
274
+ ],
275
+ },
276
+ condition: {
277
+ urlFilter: "bookingfestival.php",
278
+ resourceTypes: [
279
+ ((_o = chrome.declarativeNetRequest.ResourceType) === null || _o === void 0 ? void 0 : _o.XMLHTTPREQUEST) || "xmlhttprequest",
280
+ ],
281
+ excludedInitiatorDomains: excludedDomains,
282
+ },
283
+ },
284
+ {
285
+ id: 1023,
286
+ priority: 25,
287
+ action: {
288
+ type: ((_p = chrome.declarativeNetRequest.RuleActionType) === null || _p === void 0 ? void 0 : _p.MODIFY_HEADERS) || "modifyHeaders",
289
+ requestHeaders: [
290
+ {
291
+ header: "Referer",
292
+ operation: ((_q = chrome.declarativeNetRequest.HeaderOperation) === null || _q === void 0 ? void 0 : _q.SET) || "set",
293
+ value: enrollReferer,
294
+ },
295
+ {
296
+ header: "Origin",
297
+ operation: ((_r = chrome.declarativeNetRequest.HeaderOperation) === null || _r === void 0 ? void 0 : _r.SET) || "set",
298
+ value: "https://booking.thaiticketmajor.com",
299
+ },
300
+ ],
301
+ },
302
+ condition: {
303
+ urlFilter: "enroll_process.php",
304
+ resourceTypes: [
305
+ ((_s = chrome.declarativeNetRequest.ResourceType) === null || _s === void 0 ? void 0 : _s.XMLHTTPREQUEST) || "xmlhttprequest",
306
+ ],
307
+ excludedInitiatorDomains: excludedDomains,
308
+ },
309
+ },
310
+ {
311
+ id: 1010,
312
+ priority: 20,
313
+ action: {
314
+ type: ((_t = chrome.declarativeNetRequest.RuleActionType) === null || _t === void 0 ? void 0 : _t.MODIFY_HEADERS) || "modifyHeaders",
315
+ requestHeaders: [
316
+ {
317
+ header: "Referer",
318
+ operation: ((_u = chrome.declarativeNetRequest.HeaderOperation) === null || _u === void 0 ? void 0 : _u.SET) || "set",
203
319
  value: "https://booking.thaiticketmajor.com/booking/3m/orderenc_kbankqr.php",
204
320
  },
321
+ {
322
+ header: "Origin",
323
+ operation: ((_v = chrome.declarativeNetRequest.HeaderOperation) === null || _v === void 0 ? void 0 : _v.SET) || "set",
324
+ value: "https://booking.thaiticketmajor.com",
325
+ },
205
326
  ],
206
327
  },
207
328
  condition: {
208
329
  urlFilter: "getkbankqr.php",
209
330
  resourceTypes: [
210
- ((_d = chrome.declarativeNetRequest.ResourceType) === null || _d === void 0 ? void 0 : _d.XMLHTTPREQUEST) || "xmlhttprequest",
331
+ ((_w = chrome.declarativeNetRequest.ResourceType) === null || _w === void 0 ? void 0 : _w.XMLHTTPREQUEST) || "xmlhttprequest",
211
332
  ],
333
+ excludedInitiatorDomains: excludedDomains,
212
334
  },
213
335
  },
214
336
  {
215
337
  id: 1011,
216
338
  priority: 20,
217
339
  action: {
218
- type: ((_e = chrome.declarativeNetRequest.RuleActionType) === null || _e === void 0 ? void 0 : _e.MODIFY_HEADERS) || "modifyHeaders",
340
+ type: ((_x = chrome.declarativeNetRequest.RuleActionType) === null || _x === void 0 ? void 0 : _x.MODIFY_HEADERS) || "modifyHeaders",
219
341
  requestHeaders: [
220
342
  {
221
343
  header: "Referer",
222
- operation: ((_f = chrome.declarativeNetRequest.HeaderOperation) === null || _f === void 0 ? void 0 : _f.SET) || "set",
344
+ operation: ((_y = chrome.declarativeNetRequest.HeaderOperation) === null || _y === void 0 ? void 0 : _y.SET) || "set",
223
345
  value: "https://booking.thaiticketmajor.com/booking/3m/orderenc_kbankqr.php",
224
346
  },
347
+ {
348
+ header: "Origin",
349
+ operation: ((_z = chrome.declarativeNetRequest.HeaderOperation) === null || _z === void 0 ? void 0 : _z.SET) || "set",
350
+ value: "https://booking.thaiticketmajor.com",
351
+ },
225
352
  ],
226
353
  },
227
354
  condition: {
228
355
  urlFilter: "payment_kbankqr.php",
229
356
  resourceTypes: [
230
- ((_g = chrome.declarativeNetRequest.ResourceType) === null || _g === void 0 ? void 0 : _g.XMLHTTPREQUEST) || "xmlhttprequest",
357
+ ((_0 = chrome.declarativeNetRequest.ResourceType) === null || _0 === void 0 ? void 0 : _0.XMLHTTPREQUEST) || "xmlhttprequest",
231
358
  ],
359
+ excludedInitiatorDomains: excludedDomains,
232
360
  },
233
361
  },
234
362
  {
235
363
  id: 1012,
236
364
  priority: 20,
237
365
  action: {
238
- type: ((_h = chrome.declarativeNetRequest.RuleActionType) === null || _h === void 0 ? void 0 : _h.MODIFY_HEADERS) || "modifyHeaders",
366
+ type: ((_1 = chrome.declarativeNetRequest.RuleActionType) === null || _1 === void 0 ? void 0 : _1.MODIFY_HEADERS) || "modifyHeaders",
239
367
  requestHeaders: [
240
368
  {
241
369
  header: "Referer",
242
- operation: ((_j = chrome.declarativeNetRequest.HeaderOperation) === null || _j === void 0 ? void 0 : _j.SET) || "set",
370
+ operation: ((_2 = chrome.declarativeNetRequest.HeaderOperation) === null || _2 === void 0 ? void 0 : _2.SET) || "set",
243
371
  value: "https://booking.thaiticketmajor.com/booking/3m/paycfmall.php",
244
372
  },
373
+ {
374
+ header: "Origin",
375
+ operation: ((_3 = chrome.declarativeNetRequest.HeaderOperation) === null || _3 === void 0 ? void 0 : _3.SET) || "set",
376
+ value: "https://booking.thaiticketmajor.com",
377
+ },
245
378
  ],
246
379
  },
247
380
  condition: {
248
381
  urlFilter: "orderenc_kbankqr.php",
249
382
  resourceTypes: [
250
- ((_k = chrome.declarativeNetRequest.ResourceType) === null || _k === void 0 ? void 0 : _k.XMLHTTPREQUEST) || "xmlhttprequest",
383
+ ((_4 = chrome.declarativeNetRequest.ResourceType) === null || _4 === void 0 ? void 0 : _4.XMLHTTPREQUEST) || "xmlhttprequest",
251
384
  ],
385
+ excludedInitiatorDomains: excludedDomains,
252
386
  },
253
387
  },
254
388
  {
255
389
  id: 1013,
256
390
  priority: 20,
257
391
  action: {
258
- type: ((_l = chrome.declarativeNetRequest.RuleActionType) === null || _l === void 0 ? void 0 : _l.MODIFY_HEADERS) || "modifyHeaders",
392
+ type: ((_5 = chrome.declarativeNetRequest.RuleActionType) === null || _5 === void 0 ? void 0 : _5.MODIFY_HEADERS) || "modifyHeaders",
259
393
  requestHeaders: [
260
394
  {
261
395
  header: "Referer",
262
- operation: ((_m = chrome.declarativeNetRequest.HeaderOperation) === null || _m === void 0 ? void 0 : _m.SET) || "set",
396
+ operation: ((_6 = chrome.declarativeNetRequest.HeaderOperation) === null || _6 === void 0 ? void 0 : _6.SET) || "set",
263
397
  value: "https://booking.thaiticketmajor.com/booking/3m/paymentall.php",
264
398
  },
399
+ {
400
+ header: "Origin",
401
+ operation: ((_7 = chrome.declarativeNetRequest.HeaderOperation) === null || _7 === void 0 ? void 0 : _7.SET) || "set",
402
+ value: "https://booking.thaiticketmajor.com",
403
+ },
265
404
  ],
266
405
  },
267
406
  condition: {
268
407
  urlFilter: "paycfmall.php",
269
408
  resourceTypes: [
270
- ((_o = chrome.declarativeNetRequest.ResourceType) === null || _o === void 0 ? void 0 : _o.XMLHTTPREQUEST) || "xmlhttprequest",
409
+ ((_8 = chrome.declarativeNetRequest.ResourceType) === null || _8 === void 0 ? void 0 : _8.XMLHTTPREQUEST) || "xmlhttprequest",
271
410
  ],
411
+ excludedInitiatorDomains: excludedDomains,
272
412
  },
273
413
  },
274
414
  {
275
415
  id: 1014,
276
416
  priority: 20,
277
417
  action: {
278
- type: ((_p = chrome.declarativeNetRequest.RuleActionType) === null || _p === void 0 ? void 0 : _p.MODIFY_HEADERS) || "modifyHeaders",
418
+ type: ((_9 = chrome.declarativeNetRequest.RuleActionType) === null || _9 === void 0 ? void 0 : _9.MODIFY_HEADERS) || "modifyHeaders",
279
419
  requestHeaders: [
280
420
  {
281
421
  header: "Referer",
282
- operation: ((_q = chrome.declarativeNetRequest.HeaderOperation) === null || _q === void 0 ? void 0 : _q.SET) || "set",
422
+ operation: ((_10 = chrome.declarativeNetRequest.HeaderOperation) === null || _10 === void 0 ? void 0 : _10.SET) || "set",
283
423
  value: "https://booking.thaiticketmajor.com/booking/3m/fixed.php",
284
424
  },
425
+ {
426
+ header: "Origin",
427
+ operation: ((_11 = chrome.declarativeNetRequest.HeaderOperation) === null || _11 === void 0 ? void 0 : _11.SET) || "set",
428
+ value: "https://booking.thaiticketmajor.com",
429
+ },
285
430
  ],
286
431
  },
287
432
  condition: {
288
433
  urlFilter: "paymentall.php",
289
434
  resourceTypes: [
290
- ((_r = chrome.declarativeNetRequest.ResourceType) === null || _r === void 0 ? void 0 : _r.XMLHTTPREQUEST) || "xmlhttprequest",
435
+ ((_12 = chrome.declarativeNetRequest.ResourceType) === null || _12 === void 0 ? void 0 : _12.XMLHTTPREQUEST) || "xmlhttprequest",
291
436
  ],
437
+ excludedInitiatorDomains: excludedDomains,
292
438
  },
293
439
  },
294
440
  {
295
441
  id: 1015,
296
442
  priority: 20,
297
443
  action: {
298
- type: ((_s = chrome.declarativeNetRequest.RuleActionType) === null || _s === void 0 ? void 0 : _s.MODIFY_HEADERS) || "modifyHeaders",
444
+ type: ((_13 = chrome.declarativeNetRequest.RuleActionType) === null || _13 === void 0 ? void 0 : _13.MODIFY_HEADERS) || "modifyHeaders",
299
445
  requestHeaders: [
300
446
  {
301
447
  header: "Referer",
302
- operation: ((_t = chrome.declarativeNetRequest.HeaderOperation) === null || _t === void 0 ? void 0 : _t.SET) || "set",
448
+ operation: ((_14 = chrome.declarativeNetRequest.HeaderOperation) === null || _14 === void 0 ? void 0 : _14.SET) || "set",
303
449
  value: "https://booking.thaiticketmajor.com/booking/3m/fixed.php",
304
450
  },
451
+ {
452
+ header: "Origin",
453
+ operation: ((_15 = chrome.declarativeNetRequest.HeaderOperation) === null || _15 === void 0 ? void 0 : _15.SET) || "set",
454
+ value: "https://booking.thaiticketmajor.com",
455
+ },
305
456
  ],
306
457
  },
307
458
  condition: {
308
- urlFilter: "enroll",
459
+ urlFilter: "enroll.php",
309
460
  resourceTypes: [
310
- ((_u = chrome.declarativeNetRequest.ResourceType) === null || _u === void 0 ? void 0 : _u.XMLHTTPREQUEST) || "xmlhttprequest",
461
+ ((_16 = chrome.declarativeNetRequest.ResourceType) === null || _16 === void 0 ? void 0 : _16.XMLHTTPREQUEST) || "xmlhttprequest",
311
462
  ],
463
+ excludedInitiatorDomains: excludedDomains,
312
464
  },
313
465
  },
314
466
  {
315
467
  id: 1018,
316
468
  priority: 20,
317
469
  action: {
318
- type: ((_v = chrome.declarativeNetRequest.RuleActionType) === null || _v === void 0 ? void 0 : _v.MODIFY_HEADERS) || "modifyHeaders",
470
+ type: ((_17 = chrome.declarativeNetRequest.RuleActionType) === null || _17 === void 0 ? void 0 : _17.MODIFY_HEADERS) || "modifyHeaders",
319
471
  requestHeaders: [
320
472
  {
321
473
  header: "Referer",
322
- operation: ((_w = chrome.declarativeNetRequest.HeaderOperation) === null || _w === void 0 ? void 0 : _w.SET) || "set",
474
+ operation: ((_18 = chrome.declarativeNetRequest.HeaderOperation) === null || _18 === void 0 ? void 0 : _18.SET) || "set",
323
475
  value: "https://booking.thaiticketmajor.com/booking/3m/zones.php",
324
476
  },
477
+ {
478
+ header: "Origin",
479
+ operation: ((_19 = chrome.declarativeNetRequest.HeaderOperation) === null || _19 === void 0 ? void 0 : _19.SET) || "set",
480
+ value: "https://booking.thaiticketmajor.com",
481
+ },
325
482
  ],
326
483
  },
327
484
  condition: {
328
485
  urlFilter: "zonesavail.php",
329
486
  resourceTypes: [
330
- ((_x = chrome.declarativeNetRequest.ResourceType) === null || _x === void 0 ? void 0 : _x.XMLHTTPREQUEST) || "xmlhttprequest",
487
+ ((_20 = chrome.declarativeNetRequest.ResourceType) === null || _20 === void 0 ? void 0 : _20.XMLHTTPREQUEST) || "xmlhttprequest",
331
488
  ],
489
+ excludedInitiatorDomains: excludedDomains,
332
490
  },
333
491
  },
334
492
  {
335
493
  id: 1002,
336
494
  priority: 20,
337
495
  action: {
338
- type: ((_y = chrome.declarativeNetRequest.RuleActionType) === null || _y === void 0 ? void 0 : _y.MODIFY_HEADERS) || "modifyHeaders",
496
+ type: ((_21 = chrome.declarativeNetRequest.RuleActionType) === null || _21 === void 0 ? void 0 : _21.MODIFY_HEADERS) || "modifyHeaders",
339
497
  requestHeaders: [
340
498
  {
341
499
  header: "Referer",
342
- operation: ((_z = chrome.declarativeNetRequest.HeaderOperation) === null || _z === void 0 ? void 0 : _z.SET) || "set",
500
+ operation: ((_22 = chrome.declarativeNetRequest.HeaderOperation) === null || _22 === void 0 ? void 0 : _22.SET) || "set",
343
501
  value: "https://kpaymentgateway.kasikornbank.com/",
344
502
  },
503
+ {
504
+ header: "Origin",
505
+ operation: ((_23 = chrome.declarativeNetRequest.HeaderOperation) === null || _23 === void 0 ? void 0 : _23.SET) || "set",
506
+ value: "https://kpaymentgateway.kasikornbank.com",
507
+ },
345
508
  ],
346
509
  },
347
510
  condition: {
348
511
  urlFilter: "kasikornbank.com",
349
512
  resourceTypes: [
350
- ((_0 = chrome.declarativeNetRequest.ResourceType) === null || _0 === void 0 ? void 0 : _0.XMLHTTPREQUEST) || "xmlhttprequest",
513
+ ((_24 = chrome.declarativeNetRequest.ResourceType) === null || _24 === void 0 ? void 0 : _24.XMLHTTPREQUEST) || "xmlhttprequest",
351
514
  ],
515
+ excludedInitiatorDomains: excludedDomains,
352
516
  },
353
517
  },
354
518
  {
355
519
  id: 1001,
356
520
  priority: 1,
357
521
  action: {
358
- type: ((_1 = chrome.declarativeNetRequest.RuleActionType) === null || _1 === void 0 ? void 0 : _1.MODIFY_HEADERS) || "modifyHeaders",
522
+ type: ((_25 = chrome.declarativeNetRequest.RuleActionType) === null || _25 === void 0 ? void 0 : _25.MODIFY_HEADERS) || "modifyHeaders",
359
523
  requestHeaders: [
360
524
  {
361
525
  header: "Referer",
362
- operation: ((_2 = chrome.declarativeNetRequest.HeaderOperation) === null || _2 === void 0 ? void 0 : _2.SET) || "set",
526
+ operation: ((_26 = chrome.declarativeNetRequest.HeaderOperation) === null || _26 === void 0 ? void 0 : _26.SET) || "set",
363
527
  value: "https://booking.thaiticketmajor.com/booking/3m/",
364
528
  },
529
+ {
530
+ header: "Origin",
531
+ operation: ((_27 = chrome.declarativeNetRequest.HeaderOperation) === null || _27 === void 0 ? void 0 : _27.SET) || "set",
532
+ value: "https://booking.thaiticketmajor.com",
533
+ },
365
534
  ],
366
535
  },
367
536
  condition: {
368
537
  urlFilter: "thaiticketmajor.com",
369
538
  resourceTypes: [
370
- ((_3 = chrome.declarativeNetRequest.ResourceType) === null || _3 === void 0 ? void 0 : _3.XMLHTTPREQUEST) || "xmlhttprequest",
539
+ ((_28 = chrome.declarativeNetRequest.ResourceType) === null || _28 === void 0 ? void 0 : _28.XMLHTTPREQUEST) || "xmlhttprequest",
371
540
  ],
541
+ excludedInitiatorDomains: excludedDomains,
372
542
  },
373
543
  },
374
544
  ],
@@ -1419,6 +1589,13 @@ class ThaiTicketMajor {
1419
1589
  let paymentAllData;
1420
1590
  // 5. ดำเนินการตามประเภทโซน (Fixed vs Festival)
1421
1591
  if (targetZone.page === "fixed.php") {
1592
+ if (this.inBrowser) {
1593
+ yield ThaiTicketMajor.setupExtensionRules({
1594
+ k: zoneData.k,
1595
+ zone: targetZone.value,
1596
+ roundId: targetPerformRound.id,
1597
+ });
1598
+ }
1422
1599
  const fixedData = yield this.getFixedSeats(zoneData.k, targetZone.value, targetPerformRound.id);
1423
1600
  const availableSeats = fixedData.seats;
1424
1601
  if (availableSeats.length < ticketCount) {
@@ -1461,6 +1638,13 @@ class ThaiTicketMajor {
1461
1638
  }
1462
1639
  else {
1463
1640
  // Festival Flow
1641
+ if (this.inBrowser) {
1642
+ yield ThaiTicketMajor.setupExtensionRules({
1643
+ k: zoneData.k,
1644
+ zone: targetZone.value,
1645
+ roundId: targetPerformRound.id,
1646
+ });
1647
+ }
1464
1648
  const festivalForm = yield this.getFestival(zoneData.k, zoneData.tk, selectedRound.query, targetZone.value, targetPerformRound.id);
1465
1649
  yield this.validateFestivalSeats(zoneData.k, festivalForm, ticketCount);
1466
1650
  const bookingFestivalRes = yield this.bookFestivalSeats(zoneData.k, festivalForm, ticketCount);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playttm",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Make HTML Metadata to JSON",
5
5
  "main": "dist/lib.js",
6
6
  "types": "dist/lib.d.ts",
package/src/lib.ts CHANGED
@@ -258,22 +258,143 @@ export class ThaiTicketMajor {
258
258
  }
259
259
  }
260
260
 
261
+
261
262
  /**
262
- * Setup declarativeNetRequest session rules in Chrome Extension to set Referer header for API requests only.
263
- */
264
- /**
265
- * Setup declarativeNetRequest session rules in Chrome Extension to set Referer headers accurately for each endpoint.
263
+ * Setup declarativeNetRequest session rules for Chrome Extension environment.
264
+ * Overrides forbidden headers (Referer, Origin) to bypass TTM and Kasikorn referrer checks.
265
+ * Uses excludedInitiatorDomains to NEVER alter requests made directly by tabs on thaiticketmajor.com.
266
266
  */
267
- public static async setupExtensionRules(): Promise<void> {
267
+ public static async setupExtensionRules(context?: { k?: string; zone?: string; roundId?: string }): Promise<void> {
268
268
  if (typeof chrome === "undefined" || !chrome?.declarativeNetRequest?.updateSessionRules) {
269
269
  return;
270
270
  }
271
271
 
272
+ const fixedReferer = (context?.k && context?.zone && context?.roundId)
273
+ ? `https://booking.thaiticketmajor.com/booking/3m/fixed.php?k=${context.k}&zone=${context.zone}&round=${context.roundId}`
274
+ : "https://booking.thaiticketmajor.com/booking/3m/fixed.php";
275
+
276
+ const festivalReferer = (context?.k && context?.zone && context?.roundId)
277
+ ? `https://booking.thaiticketmajor.com/booking/3m/festival.php?k=${context.k}&zone=${context.zone}&round=${context.roundId}`
278
+ : "https://booking.thaiticketmajor.com/booking/3m/festival.php";
279
+
280
+ const enrollReferer = (context?.k && context?.zone && context?.roundId)
281
+ ? `https://booking.thaiticketmajor.com/booking/3m/enroll.php?k=${context.k}&zone=${context.zone}&round=${context.roundId}`
282
+ : "https://booking.thaiticketmajor.com/booking/3m/enroll.php";
283
+
284
+ const excludedDomains = ["booking.thaiticketmajor.com", "www.thaiticketmajor.com", "thaiticketmajor.com"];
285
+
272
286
  try {
273
- const ruleIdsToRemove = [1001, 1002, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019];
287
+ const ruleIdsToRemove = [
288
+ 1001, 1002, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019,
289
+ 1020, 1021, 1022, 1023
290
+ ];
274
291
  await chrome.declarativeNetRequest.updateSessionRules({
275
292
  removeRuleIds: ruleIdsToRemove,
276
293
  addRules: [
294
+ {
295
+ id: 1020,
296
+ priority: 25,
297
+ action: {
298
+ type: chrome.declarativeNetRequest.RuleActionType?.MODIFY_HEADERS || "modifyHeaders",
299
+ requestHeaders: [
300
+ {
301
+ header: "Referer",
302
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
303
+ value: fixedReferer,
304
+ },
305
+ {
306
+ header: "Origin",
307
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
308
+ value: "https://booking.thaiticketmajor.com",
309
+ },
310
+ ],
311
+ },
312
+ condition: {
313
+ urlFilter: "bookingseats.php",
314
+ resourceTypes: [
315
+ chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
316
+ ],
317
+ excludedInitiatorDomains: excludedDomains,
318
+ },
319
+ },
320
+ {
321
+ id: 1021,
322
+ priority: 25,
323
+ action: {
324
+ type: chrome.declarativeNetRequest.RuleActionType?.MODIFY_HEADERS || "modifyHeaders",
325
+ requestHeaders: [
326
+ {
327
+ header: "Referer",
328
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
329
+ value: fixedReferer,
330
+ },
331
+ {
332
+ header: "Origin",
333
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
334
+ value: "https://booking.thaiticketmajor.com",
335
+ },
336
+ ],
337
+ },
338
+ condition: {
339
+ urlFilter: "validateseat.php",
340
+ resourceTypes: [
341
+ chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
342
+ ],
343
+ excludedInitiatorDomains: excludedDomains,
344
+ },
345
+ },
346
+ {
347
+ id: 1022,
348
+ priority: 25,
349
+ action: {
350
+ type: chrome.declarativeNetRequest.RuleActionType?.MODIFY_HEADERS || "modifyHeaders",
351
+ requestHeaders: [
352
+ {
353
+ header: "Referer",
354
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
355
+ value: festivalReferer,
356
+ },
357
+ {
358
+ header: "Origin",
359
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
360
+ value: "https://booking.thaiticketmajor.com",
361
+ },
362
+ ],
363
+ },
364
+ condition: {
365
+ urlFilter: "bookingfestival.php",
366
+ resourceTypes: [
367
+ chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
368
+ ],
369
+ excludedInitiatorDomains: excludedDomains,
370
+ },
371
+ },
372
+ {
373
+ id: 1023,
374
+ priority: 25,
375
+ action: {
376
+ type: chrome.declarativeNetRequest.RuleActionType?.MODIFY_HEADERS || "modifyHeaders",
377
+ requestHeaders: [
378
+ {
379
+ header: "Referer",
380
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
381
+ value: enrollReferer,
382
+ },
383
+ {
384
+ header: "Origin",
385
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
386
+ value: "https://booking.thaiticketmajor.com",
387
+ },
388
+ ],
389
+ },
390
+ condition: {
391
+ urlFilter: "enroll_process.php",
392
+ resourceTypes: [
393
+ chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
394
+ ],
395
+ excludedInitiatorDomains: excludedDomains,
396
+ },
397
+ },
277
398
  {
278
399
  id: 1010,
279
400
  priority: 20,
@@ -285,6 +406,11 @@ export class ThaiTicketMajor {
285
406
  operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
286
407
  value: "https://booking.thaiticketmajor.com/booking/3m/orderenc_kbankqr.php",
287
408
  },
409
+ {
410
+ header: "Origin",
411
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
412
+ value: "https://booking.thaiticketmajor.com",
413
+ },
288
414
  ],
289
415
  },
290
416
  condition: {
@@ -292,6 +418,7 @@ export class ThaiTicketMajor {
292
418
  resourceTypes: [
293
419
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
294
420
  ],
421
+ excludedInitiatorDomains: excludedDomains,
295
422
  },
296
423
  },
297
424
  {
@@ -305,6 +432,11 @@ export class ThaiTicketMajor {
305
432
  operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
306
433
  value: "https://booking.thaiticketmajor.com/booking/3m/orderenc_kbankqr.php",
307
434
  },
435
+ {
436
+ header: "Origin",
437
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
438
+ value: "https://booking.thaiticketmajor.com",
439
+ },
308
440
  ],
309
441
  },
310
442
  condition: {
@@ -312,6 +444,7 @@ export class ThaiTicketMajor {
312
444
  resourceTypes: [
313
445
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
314
446
  ],
447
+ excludedInitiatorDomains: excludedDomains,
315
448
  },
316
449
  },
317
450
  {
@@ -325,6 +458,11 @@ export class ThaiTicketMajor {
325
458
  operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
326
459
  value: "https://booking.thaiticketmajor.com/booking/3m/paycfmall.php",
327
460
  },
461
+ {
462
+ header: "Origin",
463
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
464
+ value: "https://booking.thaiticketmajor.com",
465
+ },
328
466
  ],
329
467
  },
330
468
  condition: {
@@ -332,6 +470,7 @@ export class ThaiTicketMajor {
332
470
  resourceTypes: [
333
471
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
334
472
  ],
473
+ excludedInitiatorDomains: excludedDomains,
335
474
  },
336
475
  },
337
476
  {
@@ -345,6 +484,11 @@ export class ThaiTicketMajor {
345
484
  operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
346
485
  value: "https://booking.thaiticketmajor.com/booking/3m/paymentall.php",
347
486
  },
487
+ {
488
+ header: "Origin",
489
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
490
+ value: "https://booking.thaiticketmajor.com",
491
+ },
348
492
  ],
349
493
  },
350
494
  condition: {
@@ -352,6 +496,7 @@ export class ThaiTicketMajor {
352
496
  resourceTypes: [
353
497
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
354
498
  ],
499
+ excludedInitiatorDomains: excludedDomains,
355
500
  },
356
501
  },
357
502
  {
@@ -365,6 +510,11 @@ export class ThaiTicketMajor {
365
510
  operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
366
511
  value: "https://booking.thaiticketmajor.com/booking/3m/fixed.php",
367
512
  },
513
+ {
514
+ header: "Origin",
515
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
516
+ value: "https://booking.thaiticketmajor.com",
517
+ },
368
518
  ],
369
519
  },
370
520
  condition: {
@@ -372,6 +522,7 @@ export class ThaiTicketMajor {
372
522
  resourceTypes: [
373
523
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
374
524
  ],
525
+ excludedInitiatorDomains: excludedDomains,
375
526
  },
376
527
  },
377
528
  {
@@ -385,13 +536,19 @@ export class ThaiTicketMajor {
385
536
  operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
386
537
  value: "https://booking.thaiticketmajor.com/booking/3m/fixed.php",
387
538
  },
539
+ {
540
+ header: "Origin",
541
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
542
+ value: "https://booking.thaiticketmajor.com",
543
+ },
388
544
  ],
389
545
  },
390
546
  condition: {
391
- urlFilter: "enroll",
547
+ urlFilter: "enroll.php",
392
548
  resourceTypes: [
393
549
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
394
550
  ],
551
+ excludedInitiatorDomains: excludedDomains,
395
552
  },
396
553
  },
397
554
  {
@@ -405,6 +562,11 @@ export class ThaiTicketMajor {
405
562
  operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
406
563
  value: "https://booking.thaiticketmajor.com/booking/3m/zones.php",
407
564
  },
565
+ {
566
+ header: "Origin",
567
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
568
+ value: "https://booking.thaiticketmajor.com",
569
+ },
408
570
  ],
409
571
  },
410
572
  condition: {
@@ -412,6 +574,7 @@ export class ThaiTicketMajor {
412
574
  resourceTypes: [
413
575
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
414
576
  ],
577
+ excludedInitiatorDomains: excludedDomains,
415
578
  },
416
579
  },
417
580
  {
@@ -425,6 +588,11 @@ export class ThaiTicketMajor {
425
588
  operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
426
589
  value: "https://kpaymentgateway.kasikornbank.com/",
427
590
  },
591
+ {
592
+ header: "Origin",
593
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
594
+ value: "https://kpaymentgateway.kasikornbank.com",
595
+ },
428
596
  ],
429
597
  },
430
598
  condition: {
@@ -432,6 +600,7 @@ export class ThaiTicketMajor {
432
600
  resourceTypes: [
433
601
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
434
602
  ],
603
+ excludedInitiatorDomains: excludedDomains,
435
604
  },
436
605
  },
437
606
  {
@@ -445,6 +614,11 @@ export class ThaiTicketMajor {
445
614
  operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
446
615
  value: "https://booking.thaiticketmajor.com/booking/3m/",
447
616
  },
617
+ {
618
+ header: "Origin",
619
+ operation: chrome.declarativeNetRequest.HeaderOperation?.SET || "set",
620
+ value: "https://booking.thaiticketmajor.com",
621
+ },
448
622
  ],
449
623
  },
450
624
  condition: {
@@ -452,6 +626,7 @@ export class ThaiTicketMajor {
452
626
  resourceTypes: [
453
627
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
454
628
  ],
629
+ excludedInitiatorDomains: excludedDomains,
455
630
  },
456
631
  },
457
632
  ],
@@ -1726,6 +1901,14 @@ export class ThaiTicketMajor {
1726
1901
 
1727
1902
  // 5. ดำเนินการตามประเภทโซน (Fixed vs Festival)
1728
1903
  if (targetZone.page === "fixed.php") {
1904
+ if (this.inBrowser) {
1905
+ await ThaiTicketMajor.setupExtensionRules({
1906
+ k: zoneData.k,
1907
+ zone: targetZone.value,
1908
+ roundId: targetPerformRound.id,
1909
+ });
1910
+ }
1911
+
1729
1912
  const fixedData = await this.getFixedSeats(zoneData.k, targetZone.value, targetPerformRound.id);
1730
1913
  const availableSeats = fixedData.seats;
1731
1914
 
@@ -1771,6 +1954,14 @@ export class ThaiTicketMajor {
1771
1954
  }
1772
1955
  } else {
1773
1956
  // Festival Flow
1957
+ if (this.inBrowser) {
1958
+ await ThaiTicketMajor.setupExtensionRules({
1959
+ k: zoneData.k,
1960
+ zone: targetZone.value,
1961
+ roundId: targetPerformRound.id,
1962
+ });
1963
+ }
1964
+
1774
1965
  const festivalForm = await this.getFestival(zoneData.k, zoneData.tk, selectedRound.query, targetZone.value, targetPerformRound.id);
1775
1966
 
1776
1967
  await this.validateFestivalSeats(zoneData.k, festivalForm, ticketCount);