playttm 0.0.9 → 0.0.10

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
@@ -91,10 +91,14 @@ export declare class ThaiTicketMajor {
91
91
  * Automatically ignores bot protection cookies (Akamai _abck, bm_*, WAF) to prevent Access Denied (403) bans.
92
92
  */
93
93
  static syncCookiesToChrome(cookieString: string, domainUrl?: string): Promise<void>;
94
+ /**
95
+ * Clear any session and dynamic rules set by the extension so the browser is left 100% clean.
96
+ */
97
+ static clearExtensionRules(): Promise<void>;
94
98
  /**
95
99
  * 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.
100
+ * Uses initiatorDomains=[chrome.runtime.id] so Chrome ONLY modifies requests
101
+ * originating from this extension popup, and NEVER touches normal browser tabs!
98
102
  */
99
103
  static setupExtensionRules(context?: {
100
104
  k?: string;
package/dist/lib.js CHANGED
@@ -174,17 +174,56 @@ class ThaiTicketMajor {
174
174
  }
175
175
  });
176
176
  }
177
+ /**
178
+ * Clear any session and dynamic rules set by the extension so the browser is left 100% clean.
179
+ */
180
+ static clearExtensionRules() {
181
+ return __awaiter(this, void 0, void 0, function* () {
182
+ if (typeof chrome === "undefined" || !(chrome === null || chrome === void 0 ? void 0 : chrome.declarativeNetRequest)) {
183
+ return;
184
+ }
185
+ try {
186
+ // Clear all session rules
187
+ if (chrome.declarativeNetRequest.getSessionRules && chrome.declarativeNetRequest.updateSessionRules) {
188
+ const existing = yield chrome.declarativeNetRequest.getSessionRules();
189
+ const ids = existing.map((r) => r.id);
190
+ if (ids.length > 0) {
191
+ yield chrome.declarativeNetRequest.updateSessionRules({
192
+ removeRuleIds: ids,
193
+ });
194
+ }
195
+ }
196
+ // Clear any lingering dynamic rules
197
+ if (chrome.declarativeNetRequest.getDynamicRules && chrome.declarativeNetRequest.updateDynamicRules) {
198
+ const dynamicRules = yield chrome.declarativeNetRequest.getDynamicRules();
199
+ const dynamicIds = dynamicRules.map((r) => r.id);
200
+ if (dynamicIds.length > 0) {
201
+ yield chrome.declarativeNetRequest.updateDynamicRules({
202
+ removeRuleIds: dynamicIds,
203
+ });
204
+ }
205
+ }
206
+ }
207
+ catch (err) {
208
+ console.warn("Could not clear declarativeNetRequest rules:", err);
209
+ }
210
+ });
211
+ }
177
212
  /**
178
213
  * 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.
214
+ * Uses initiatorDomains=[chrome.runtime.id] so Chrome ONLY modifies requests
215
+ * originating from this extension popup, and NEVER touches normal browser tabs!
181
216
  */
182
217
  static setupExtensionRules(context) {
183
218
  return __awaiter(this, void 0, void 0, function* () {
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;
219
+ 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, _29;
185
220
  if (typeof chrome === "undefined" || !((_a = chrome === null || chrome === void 0 ? void 0 : chrome.declarativeNetRequest) === null || _a === void 0 ? void 0 : _a.updateSessionRules)) {
186
221
  return;
187
222
  }
223
+ const extensionId = (_b = chrome.runtime) === null || _b === void 0 ? void 0 : _b.id;
224
+ // IMPORTANT: By specifying initiatorDomains with the extension ID, Chrome will ONLY
225
+ // modify requests sent by this extension, and will NEVER touch normal browser tabs!
226
+ const initiatorDomains = extensionId ? [extensionId] : undefined;
188
227
  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
228
  ? `https://booking.thaiticketmajor.com/booking/3m/fixed.php?k=${context.k}&zone=${context.zone}&round=${context.roundId}`
190
229
  : "https://booking.thaiticketmajor.com/booking/3m/fixed.php";
@@ -207,339 +246,287 @@ class ThaiTicketMajor {
207
246
  id: 1020,
208
247
  priority: 25,
209
248
  action: {
210
- type: ((_b = chrome.declarativeNetRequest.RuleActionType) === null || _b === void 0 ? void 0 : _b.MODIFY_HEADERS) || "modifyHeaders",
249
+ type: ((_c = chrome.declarativeNetRequest.RuleActionType) === null || _c === void 0 ? void 0 : _c.MODIFY_HEADERS) || "modifyHeaders",
211
250
  requestHeaders: [
212
251
  {
213
252
  header: "Referer",
214
- operation: ((_c = chrome.declarativeNetRequest.HeaderOperation) === null || _c === void 0 ? void 0 : _c.SET) || "set",
253
+ operation: ((_d = chrome.declarativeNetRequest.HeaderOperation) === null || _d === void 0 ? void 0 : _d.SET) || "set",
215
254
  value: fixedReferer,
216
255
  },
217
256
  {
218
257
  header: "Origin",
219
- operation: ((_d = chrome.declarativeNetRequest.HeaderOperation) === null || _d === void 0 ? void 0 : _d.SET) || "set",
258
+ operation: ((_e = chrome.declarativeNetRequest.HeaderOperation) === null || _e === void 0 ? void 0 : _e.SET) || "set",
220
259
  value: "https://booking.thaiticketmajor.com",
221
260
  },
222
261
  ],
223
262
  },
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
- },
263
+ condition: Object.assign(Object.assign({ urlFilter: "bookingseats.php", resourceTypes: [
264
+ ((_f = chrome.declarativeNetRequest.ResourceType) === null || _f === void 0 ? void 0 : _f.XMLHTTPREQUEST) || "xmlhttprequest",
265
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
231
266
  },
232
267
  {
233
268
  id: 1021,
234
269
  priority: 25,
235
270
  action: {
236
- type: ((_f = chrome.declarativeNetRequest.RuleActionType) === null || _f === void 0 ? void 0 : _f.MODIFY_HEADERS) || "modifyHeaders",
271
+ type: ((_g = chrome.declarativeNetRequest.RuleActionType) === null || _g === void 0 ? void 0 : _g.MODIFY_HEADERS) || "modifyHeaders",
237
272
  requestHeaders: [
238
273
  {
239
274
  header: "Referer",
240
- operation: ((_g = chrome.declarativeNetRequest.HeaderOperation) === null || _g === void 0 ? void 0 : _g.SET) || "set",
275
+ operation: ((_h = chrome.declarativeNetRequest.HeaderOperation) === null || _h === void 0 ? void 0 : _h.SET) || "set",
241
276
  value: fixedReferer,
242
277
  },
243
278
  {
244
279
  header: "Origin",
245
- operation: ((_h = chrome.declarativeNetRequest.HeaderOperation) === null || _h === void 0 ? void 0 : _h.SET) || "set",
280
+ operation: ((_j = chrome.declarativeNetRequest.HeaderOperation) === null || _j === void 0 ? void 0 : _j.SET) || "set",
246
281
  value: "https://booking.thaiticketmajor.com",
247
282
  },
248
283
  ],
249
284
  },
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
- },
285
+ condition: Object.assign(Object.assign({ urlFilter: "validateseat.php", resourceTypes: [
286
+ ((_k = chrome.declarativeNetRequest.ResourceType) === null || _k === void 0 ? void 0 : _k.XMLHTTPREQUEST) || "xmlhttprequest",
287
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
257
288
  },
258
289
  {
259
290
  id: 1022,
260
291
  priority: 25,
261
292
  action: {
262
- type: ((_k = chrome.declarativeNetRequest.RuleActionType) === null || _k === void 0 ? void 0 : _k.MODIFY_HEADERS) || "modifyHeaders",
293
+ type: ((_l = chrome.declarativeNetRequest.RuleActionType) === null || _l === void 0 ? void 0 : _l.MODIFY_HEADERS) || "modifyHeaders",
263
294
  requestHeaders: [
264
295
  {
265
296
  header: "Referer",
266
- operation: ((_l = chrome.declarativeNetRequest.HeaderOperation) === null || _l === void 0 ? void 0 : _l.SET) || "set",
297
+ operation: ((_m = chrome.declarativeNetRequest.HeaderOperation) === null || _m === void 0 ? void 0 : _m.SET) || "set",
267
298
  value: festivalReferer,
268
299
  },
269
300
  {
270
301
  header: "Origin",
271
- operation: ((_m = chrome.declarativeNetRequest.HeaderOperation) === null || _m === void 0 ? void 0 : _m.SET) || "set",
302
+ operation: ((_o = chrome.declarativeNetRequest.HeaderOperation) === null || _o === void 0 ? void 0 : _o.SET) || "set",
272
303
  value: "https://booking.thaiticketmajor.com",
273
304
  },
274
305
  ],
275
306
  },
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
- },
307
+ condition: Object.assign(Object.assign({ urlFilter: "bookingfestival.php", resourceTypes: [
308
+ ((_p = chrome.declarativeNetRequest.ResourceType) === null || _p === void 0 ? void 0 : _p.XMLHTTPREQUEST) || "xmlhttprequest",
309
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
283
310
  },
284
311
  {
285
312
  id: 1023,
286
313
  priority: 25,
287
314
  action: {
288
- type: ((_p = chrome.declarativeNetRequest.RuleActionType) === null || _p === void 0 ? void 0 : _p.MODIFY_HEADERS) || "modifyHeaders",
315
+ type: ((_q = chrome.declarativeNetRequest.RuleActionType) === null || _q === void 0 ? void 0 : _q.MODIFY_HEADERS) || "modifyHeaders",
289
316
  requestHeaders: [
290
317
  {
291
318
  header: "Referer",
292
- operation: ((_q = chrome.declarativeNetRequest.HeaderOperation) === null || _q === void 0 ? void 0 : _q.SET) || "set",
319
+ operation: ((_r = chrome.declarativeNetRequest.HeaderOperation) === null || _r === void 0 ? void 0 : _r.SET) || "set",
293
320
  value: enrollReferer,
294
321
  },
295
322
  {
296
323
  header: "Origin",
297
- operation: ((_r = chrome.declarativeNetRequest.HeaderOperation) === null || _r === void 0 ? void 0 : _r.SET) || "set",
324
+ operation: ((_s = chrome.declarativeNetRequest.HeaderOperation) === null || _s === void 0 ? void 0 : _s.SET) || "set",
298
325
  value: "https://booking.thaiticketmajor.com",
299
326
  },
300
327
  ],
301
328
  },
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
- },
329
+ condition: Object.assign(Object.assign({ urlFilter: "enroll_process.php", resourceTypes: [
330
+ ((_t = chrome.declarativeNetRequest.ResourceType) === null || _t === void 0 ? void 0 : _t.XMLHTTPREQUEST) || "xmlhttprequest",
331
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
309
332
  },
310
333
  {
311
334
  id: 1010,
312
335
  priority: 20,
313
336
  action: {
314
- type: ((_t = chrome.declarativeNetRequest.RuleActionType) === null || _t === void 0 ? void 0 : _t.MODIFY_HEADERS) || "modifyHeaders",
337
+ type: ((_u = chrome.declarativeNetRequest.RuleActionType) === null || _u === void 0 ? void 0 : _u.MODIFY_HEADERS) || "modifyHeaders",
315
338
  requestHeaders: [
316
339
  {
317
340
  header: "Referer",
318
- operation: ((_u = chrome.declarativeNetRequest.HeaderOperation) === null || _u === void 0 ? void 0 : _u.SET) || "set",
341
+ operation: ((_v = chrome.declarativeNetRequest.HeaderOperation) === null || _v === void 0 ? void 0 : _v.SET) || "set",
319
342
  value: "https://booking.thaiticketmajor.com/booking/3m/orderenc_kbankqr.php",
320
343
  },
321
344
  {
322
345
  header: "Origin",
323
- operation: ((_v = chrome.declarativeNetRequest.HeaderOperation) === null || _v === void 0 ? void 0 : _v.SET) || "set",
346
+ operation: ((_w = chrome.declarativeNetRequest.HeaderOperation) === null || _w === void 0 ? void 0 : _w.SET) || "set",
324
347
  value: "https://booking.thaiticketmajor.com",
325
348
  },
326
349
  ],
327
350
  },
328
- condition: {
329
- urlFilter: "getkbankqr.php",
330
- resourceTypes: [
331
- ((_w = chrome.declarativeNetRequest.ResourceType) === null || _w === void 0 ? void 0 : _w.XMLHTTPREQUEST) || "xmlhttprequest",
332
- ],
333
- excludedInitiatorDomains: excludedDomains,
334
- },
351
+ condition: Object.assign(Object.assign({ urlFilter: "getkbankqr.php", resourceTypes: [
352
+ ((_x = chrome.declarativeNetRequest.ResourceType) === null || _x === void 0 ? void 0 : _x.XMLHTTPREQUEST) || "xmlhttprequest",
353
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
335
354
  },
336
355
  {
337
356
  id: 1011,
338
357
  priority: 20,
339
358
  action: {
340
- type: ((_x = chrome.declarativeNetRequest.RuleActionType) === null || _x === void 0 ? void 0 : _x.MODIFY_HEADERS) || "modifyHeaders",
359
+ type: ((_y = chrome.declarativeNetRequest.RuleActionType) === null || _y === void 0 ? void 0 : _y.MODIFY_HEADERS) || "modifyHeaders",
341
360
  requestHeaders: [
342
361
  {
343
362
  header: "Referer",
344
- operation: ((_y = chrome.declarativeNetRequest.HeaderOperation) === null || _y === void 0 ? void 0 : _y.SET) || "set",
363
+ operation: ((_z = chrome.declarativeNetRequest.HeaderOperation) === null || _z === void 0 ? void 0 : _z.SET) || "set",
345
364
  value: "https://booking.thaiticketmajor.com/booking/3m/orderenc_kbankqr.php",
346
365
  },
347
366
  {
348
367
  header: "Origin",
349
- operation: ((_z = chrome.declarativeNetRequest.HeaderOperation) === null || _z === void 0 ? void 0 : _z.SET) || "set",
368
+ operation: ((_0 = chrome.declarativeNetRequest.HeaderOperation) === null || _0 === void 0 ? void 0 : _0.SET) || "set",
350
369
  value: "https://booking.thaiticketmajor.com",
351
370
  },
352
371
  ],
353
372
  },
354
- condition: {
355
- urlFilter: "payment_kbankqr.php",
356
- resourceTypes: [
357
- ((_0 = chrome.declarativeNetRequest.ResourceType) === null || _0 === void 0 ? void 0 : _0.XMLHTTPREQUEST) || "xmlhttprequest",
358
- ],
359
- excludedInitiatorDomains: excludedDomains,
360
- },
373
+ condition: Object.assign(Object.assign({ urlFilter: "payment_kbankqr.php", resourceTypes: [
374
+ ((_1 = chrome.declarativeNetRequest.ResourceType) === null || _1 === void 0 ? void 0 : _1.XMLHTTPREQUEST) || "xmlhttprequest",
375
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
361
376
  },
362
377
  {
363
378
  id: 1012,
364
379
  priority: 20,
365
380
  action: {
366
- type: ((_1 = chrome.declarativeNetRequest.RuleActionType) === null || _1 === void 0 ? void 0 : _1.MODIFY_HEADERS) || "modifyHeaders",
381
+ type: ((_2 = chrome.declarativeNetRequest.RuleActionType) === null || _2 === void 0 ? void 0 : _2.MODIFY_HEADERS) || "modifyHeaders",
367
382
  requestHeaders: [
368
383
  {
369
384
  header: "Referer",
370
- operation: ((_2 = chrome.declarativeNetRequest.HeaderOperation) === null || _2 === void 0 ? void 0 : _2.SET) || "set",
385
+ operation: ((_3 = chrome.declarativeNetRequest.HeaderOperation) === null || _3 === void 0 ? void 0 : _3.SET) || "set",
371
386
  value: "https://booking.thaiticketmajor.com/booking/3m/paycfmall.php",
372
387
  },
373
388
  {
374
389
  header: "Origin",
375
- operation: ((_3 = chrome.declarativeNetRequest.HeaderOperation) === null || _3 === void 0 ? void 0 : _3.SET) || "set",
390
+ operation: ((_4 = chrome.declarativeNetRequest.HeaderOperation) === null || _4 === void 0 ? void 0 : _4.SET) || "set",
376
391
  value: "https://booking.thaiticketmajor.com",
377
392
  },
378
393
  ],
379
394
  },
380
- condition: {
381
- urlFilter: "orderenc_kbankqr.php",
382
- resourceTypes: [
383
- ((_4 = chrome.declarativeNetRequest.ResourceType) === null || _4 === void 0 ? void 0 : _4.XMLHTTPREQUEST) || "xmlhttprequest",
384
- ],
385
- excludedInitiatorDomains: excludedDomains,
386
- },
395
+ condition: Object.assign(Object.assign({ urlFilter: "orderenc_kbankqr.php", resourceTypes: [
396
+ ((_5 = chrome.declarativeNetRequest.ResourceType) === null || _5 === void 0 ? void 0 : _5.XMLHTTPREQUEST) || "xmlhttprequest",
397
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
387
398
  },
388
399
  {
389
400
  id: 1013,
390
401
  priority: 20,
391
402
  action: {
392
- type: ((_5 = chrome.declarativeNetRequest.RuleActionType) === null || _5 === void 0 ? void 0 : _5.MODIFY_HEADERS) || "modifyHeaders",
403
+ type: ((_6 = chrome.declarativeNetRequest.RuleActionType) === null || _6 === void 0 ? void 0 : _6.MODIFY_HEADERS) || "modifyHeaders",
393
404
  requestHeaders: [
394
405
  {
395
406
  header: "Referer",
396
- operation: ((_6 = chrome.declarativeNetRequest.HeaderOperation) === null || _6 === void 0 ? void 0 : _6.SET) || "set",
407
+ operation: ((_7 = chrome.declarativeNetRequest.HeaderOperation) === null || _7 === void 0 ? void 0 : _7.SET) || "set",
397
408
  value: "https://booking.thaiticketmajor.com/booking/3m/paymentall.php",
398
409
  },
399
410
  {
400
411
  header: "Origin",
401
- operation: ((_7 = chrome.declarativeNetRequest.HeaderOperation) === null || _7 === void 0 ? void 0 : _7.SET) || "set",
412
+ operation: ((_8 = chrome.declarativeNetRequest.HeaderOperation) === null || _8 === void 0 ? void 0 : _8.SET) || "set",
402
413
  value: "https://booking.thaiticketmajor.com",
403
414
  },
404
415
  ],
405
416
  },
406
- condition: {
407
- urlFilter: "paycfmall.php",
408
- resourceTypes: [
409
- ((_8 = chrome.declarativeNetRequest.ResourceType) === null || _8 === void 0 ? void 0 : _8.XMLHTTPREQUEST) || "xmlhttprequest",
410
- ],
411
- excludedInitiatorDomains: excludedDomains,
412
- },
417
+ condition: Object.assign(Object.assign({ urlFilter: "paycfmall.php", resourceTypes: [
418
+ ((_9 = chrome.declarativeNetRequest.ResourceType) === null || _9 === void 0 ? void 0 : _9.XMLHTTPREQUEST) || "xmlhttprequest",
419
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
413
420
  },
414
421
  {
415
422
  id: 1014,
416
423
  priority: 20,
417
424
  action: {
418
- type: ((_9 = chrome.declarativeNetRequest.RuleActionType) === null || _9 === void 0 ? void 0 : _9.MODIFY_HEADERS) || "modifyHeaders",
425
+ type: ((_10 = chrome.declarativeNetRequest.RuleActionType) === null || _10 === void 0 ? void 0 : _10.MODIFY_HEADERS) || "modifyHeaders",
419
426
  requestHeaders: [
420
427
  {
421
428
  header: "Referer",
422
- operation: ((_10 = chrome.declarativeNetRequest.HeaderOperation) === null || _10 === void 0 ? void 0 : _10.SET) || "set",
429
+ operation: ((_11 = chrome.declarativeNetRequest.HeaderOperation) === null || _11 === void 0 ? void 0 : _11.SET) || "set",
423
430
  value: "https://booking.thaiticketmajor.com/booking/3m/fixed.php",
424
431
  },
425
432
  {
426
433
  header: "Origin",
427
- operation: ((_11 = chrome.declarativeNetRequest.HeaderOperation) === null || _11 === void 0 ? void 0 : _11.SET) || "set",
434
+ operation: ((_12 = chrome.declarativeNetRequest.HeaderOperation) === null || _12 === void 0 ? void 0 : _12.SET) || "set",
428
435
  value: "https://booking.thaiticketmajor.com",
429
436
  },
430
437
  ],
431
438
  },
432
- condition: {
433
- urlFilter: "paymentall.php",
434
- resourceTypes: [
435
- ((_12 = chrome.declarativeNetRequest.ResourceType) === null || _12 === void 0 ? void 0 : _12.XMLHTTPREQUEST) || "xmlhttprequest",
436
- ],
437
- excludedInitiatorDomains: excludedDomains,
438
- },
439
+ condition: Object.assign(Object.assign({ urlFilter: "paymentall.php", resourceTypes: [
440
+ ((_13 = chrome.declarativeNetRequest.ResourceType) === null || _13 === void 0 ? void 0 : _13.XMLHTTPREQUEST) || "xmlhttprequest",
441
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
439
442
  },
440
443
  {
441
444
  id: 1015,
442
445
  priority: 20,
443
446
  action: {
444
- type: ((_13 = chrome.declarativeNetRequest.RuleActionType) === null || _13 === void 0 ? void 0 : _13.MODIFY_HEADERS) || "modifyHeaders",
447
+ type: ((_14 = chrome.declarativeNetRequest.RuleActionType) === null || _14 === void 0 ? void 0 : _14.MODIFY_HEADERS) || "modifyHeaders",
445
448
  requestHeaders: [
446
449
  {
447
450
  header: "Referer",
448
- operation: ((_14 = chrome.declarativeNetRequest.HeaderOperation) === null || _14 === void 0 ? void 0 : _14.SET) || "set",
451
+ operation: ((_15 = chrome.declarativeNetRequest.HeaderOperation) === null || _15 === void 0 ? void 0 : _15.SET) || "set",
449
452
  value: "https://booking.thaiticketmajor.com/booking/3m/fixed.php",
450
453
  },
451
454
  {
452
455
  header: "Origin",
453
- operation: ((_15 = chrome.declarativeNetRequest.HeaderOperation) === null || _15 === void 0 ? void 0 : _15.SET) || "set",
456
+ operation: ((_16 = chrome.declarativeNetRequest.HeaderOperation) === null || _16 === void 0 ? void 0 : _16.SET) || "set",
454
457
  value: "https://booking.thaiticketmajor.com",
455
458
  },
456
459
  ],
457
460
  },
458
- condition: {
459
- urlFilter: "enroll.php",
460
- resourceTypes: [
461
- ((_16 = chrome.declarativeNetRequest.ResourceType) === null || _16 === void 0 ? void 0 : _16.XMLHTTPREQUEST) || "xmlhttprequest",
462
- ],
463
- excludedInitiatorDomains: excludedDomains,
464
- },
461
+ condition: Object.assign(Object.assign({ urlFilter: "enroll.php", resourceTypes: [
462
+ ((_17 = chrome.declarativeNetRequest.ResourceType) === null || _17 === void 0 ? void 0 : _17.XMLHTTPREQUEST) || "xmlhttprequest",
463
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
465
464
  },
466
465
  {
467
466
  id: 1018,
468
467
  priority: 20,
469
468
  action: {
470
- type: ((_17 = chrome.declarativeNetRequest.RuleActionType) === null || _17 === void 0 ? void 0 : _17.MODIFY_HEADERS) || "modifyHeaders",
469
+ type: ((_18 = chrome.declarativeNetRequest.RuleActionType) === null || _18 === void 0 ? void 0 : _18.MODIFY_HEADERS) || "modifyHeaders",
471
470
  requestHeaders: [
472
471
  {
473
472
  header: "Referer",
474
- operation: ((_18 = chrome.declarativeNetRequest.HeaderOperation) === null || _18 === void 0 ? void 0 : _18.SET) || "set",
473
+ operation: ((_19 = chrome.declarativeNetRequest.HeaderOperation) === null || _19 === void 0 ? void 0 : _19.SET) || "set",
475
474
  value: "https://booking.thaiticketmajor.com/booking/3m/zones.php",
476
475
  },
477
476
  {
478
477
  header: "Origin",
479
- operation: ((_19 = chrome.declarativeNetRequest.HeaderOperation) === null || _19 === void 0 ? void 0 : _19.SET) || "set",
478
+ operation: ((_20 = chrome.declarativeNetRequest.HeaderOperation) === null || _20 === void 0 ? void 0 : _20.SET) || "set",
480
479
  value: "https://booking.thaiticketmajor.com",
481
480
  },
482
481
  ],
483
482
  },
484
- condition: {
485
- urlFilter: "zonesavail.php",
486
- resourceTypes: [
487
- ((_20 = chrome.declarativeNetRequest.ResourceType) === null || _20 === void 0 ? void 0 : _20.XMLHTTPREQUEST) || "xmlhttprequest",
488
- ],
489
- excludedInitiatorDomains: excludedDomains,
490
- },
483
+ condition: Object.assign(Object.assign({ urlFilter: "zonesavail.php", resourceTypes: [
484
+ ((_21 = chrome.declarativeNetRequest.ResourceType) === null || _21 === void 0 ? void 0 : _21.XMLHTTPREQUEST) || "xmlhttprequest",
485
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
491
486
  },
492
487
  {
493
488
  id: 1002,
494
489
  priority: 20,
495
490
  action: {
496
- type: ((_21 = chrome.declarativeNetRequest.RuleActionType) === null || _21 === void 0 ? void 0 : _21.MODIFY_HEADERS) || "modifyHeaders",
491
+ type: ((_22 = chrome.declarativeNetRequest.RuleActionType) === null || _22 === void 0 ? void 0 : _22.MODIFY_HEADERS) || "modifyHeaders",
497
492
  requestHeaders: [
498
493
  {
499
494
  header: "Referer",
500
- operation: ((_22 = chrome.declarativeNetRequest.HeaderOperation) === null || _22 === void 0 ? void 0 : _22.SET) || "set",
495
+ operation: ((_23 = chrome.declarativeNetRequest.HeaderOperation) === null || _23 === void 0 ? void 0 : _23.SET) || "set",
501
496
  value: "https://kpaymentgateway.kasikornbank.com/",
502
497
  },
503
498
  {
504
499
  header: "Origin",
505
- operation: ((_23 = chrome.declarativeNetRequest.HeaderOperation) === null || _23 === void 0 ? void 0 : _23.SET) || "set",
500
+ operation: ((_24 = chrome.declarativeNetRequest.HeaderOperation) === null || _24 === void 0 ? void 0 : _24.SET) || "set",
506
501
  value: "https://kpaymentgateway.kasikornbank.com",
507
502
  },
508
503
  ],
509
504
  },
510
- condition: {
511
- urlFilter: "kasikornbank.com",
512
- resourceTypes: [
513
- ((_24 = chrome.declarativeNetRequest.ResourceType) === null || _24 === void 0 ? void 0 : _24.XMLHTTPREQUEST) || "xmlhttprequest",
514
- ],
515
- excludedInitiatorDomains: excludedDomains,
516
- },
505
+ condition: Object.assign(Object.assign({ urlFilter: "kasikornbank.com", resourceTypes: [
506
+ ((_25 = chrome.declarativeNetRequest.ResourceType) === null || _25 === void 0 ? void 0 : _25.XMLHTTPREQUEST) || "xmlhttprequest",
507
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
517
508
  },
518
509
  {
519
510
  id: 1001,
520
511
  priority: 1,
521
512
  action: {
522
- type: ((_25 = chrome.declarativeNetRequest.RuleActionType) === null || _25 === void 0 ? void 0 : _25.MODIFY_HEADERS) || "modifyHeaders",
513
+ type: ((_26 = chrome.declarativeNetRequest.RuleActionType) === null || _26 === void 0 ? void 0 : _26.MODIFY_HEADERS) || "modifyHeaders",
523
514
  requestHeaders: [
524
515
  {
525
516
  header: "Referer",
526
- operation: ((_26 = chrome.declarativeNetRequest.HeaderOperation) === null || _26 === void 0 ? void 0 : _26.SET) || "set",
517
+ operation: ((_27 = chrome.declarativeNetRequest.HeaderOperation) === null || _27 === void 0 ? void 0 : _27.SET) || "set",
527
518
  value: "https://booking.thaiticketmajor.com/booking/3m/",
528
519
  },
529
520
  {
530
521
  header: "Origin",
531
- operation: ((_27 = chrome.declarativeNetRequest.HeaderOperation) === null || _27 === void 0 ? void 0 : _27.SET) || "set",
522
+ operation: ((_28 = chrome.declarativeNetRequest.HeaderOperation) === null || _28 === void 0 ? void 0 : _28.SET) || "set",
532
523
  value: "https://booking.thaiticketmajor.com",
533
524
  },
534
525
  ],
535
526
  },
536
- condition: {
537
- urlFilter: "thaiticketmajor.com",
538
- resourceTypes: [
539
- ((_28 = chrome.declarativeNetRequest.ResourceType) === null || _28 === void 0 ? void 0 : _28.XMLHTTPREQUEST) || "xmlhttprequest",
540
- ],
541
- excludedInitiatorDomains: excludedDomains,
542
- },
527
+ condition: Object.assign(Object.assign({ urlFilter: "thaiticketmajor.com", resourceTypes: [
528
+ ((_29 = chrome.declarativeNetRequest.ResourceType) === null || _29 === void 0 ? void 0 : _29.XMLHTTPREQUEST) || "xmlhttprequest",
529
+ ] }, (initiatorDomains ? { initiatorDomains } : {})), { excludedInitiatorDomains: excludedDomains }),
543
530
  },
544
531
  ],
545
532
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playttm",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
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
@@ -259,16 +259,54 @@ export class ThaiTicketMajor {
259
259
  }
260
260
 
261
261
 
262
+ /**
263
+ * Clear any session and dynamic rules set by the extension so the browser is left 100% clean.
264
+ */
265
+ public static async clearExtensionRules(): Promise<void> {
266
+ if (typeof chrome === "undefined" || !chrome?.declarativeNetRequest) {
267
+ return;
268
+ }
269
+ try {
270
+ // Clear all session rules
271
+ if (chrome.declarativeNetRequest.getSessionRules && chrome.declarativeNetRequest.updateSessionRules) {
272
+ const existing = await chrome.declarativeNetRequest.getSessionRules();
273
+ const ids = existing.map((r: any) => r.id);
274
+ if (ids.length > 0) {
275
+ await chrome.declarativeNetRequest.updateSessionRules({
276
+ removeRuleIds: ids,
277
+ });
278
+ }
279
+ }
280
+ // Clear any lingering dynamic rules
281
+ if (chrome.declarativeNetRequest.getDynamicRules && chrome.declarativeNetRequest.updateDynamicRules) {
282
+ const dynamicRules = await chrome.declarativeNetRequest.getDynamicRules();
283
+ const dynamicIds = dynamicRules.map((r: any) => r.id);
284
+ if (dynamicIds.length > 0) {
285
+ await chrome.declarativeNetRequest.updateDynamicRules({
286
+ removeRuleIds: dynamicIds,
287
+ });
288
+ }
289
+ }
290
+ } catch (err) {
291
+ console.warn("Could not clear declarativeNetRequest rules:", err);
292
+ }
293
+ }
294
+
262
295
  /**
263
296
  * 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.
297
+ * Uses initiatorDomains=[chrome.runtime.id] so Chrome ONLY modifies requests
298
+ * originating from this extension popup, and NEVER touches normal browser tabs!
266
299
  */
267
300
  public static async setupExtensionRules(context?: { k?: string; zone?: string; roundId?: string }): Promise<void> {
268
301
  if (typeof chrome === "undefined" || !chrome?.declarativeNetRequest?.updateSessionRules) {
269
302
  return;
270
303
  }
271
304
 
305
+ const extensionId = chrome.runtime?.id;
306
+ // IMPORTANT: By specifying initiatorDomains with the extension ID, Chrome will ONLY
307
+ // modify requests sent by this extension, and will NEVER touch normal browser tabs!
308
+ const initiatorDomains = extensionId ? [extensionId] : undefined;
309
+
272
310
  const fixedReferer = (context?.k && context?.zone && context?.roundId)
273
311
  ? `https://booking.thaiticketmajor.com/booking/3m/fixed.php?k=${context.k}&zone=${context.zone}&round=${context.roundId}`
274
312
  : "https://booking.thaiticketmajor.com/booking/3m/fixed.php";
@@ -314,6 +352,7 @@ export class ThaiTicketMajor {
314
352
  resourceTypes: [
315
353
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
316
354
  ],
355
+ ...(initiatorDomains ? { initiatorDomains } : {}),
317
356
  excludedInitiatorDomains: excludedDomains,
318
357
  },
319
358
  },
@@ -340,6 +379,7 @@ export class ThaiTicketMajor {
340
379
  resourceTypes: [
341
380
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
342
381
  ],
382
+ ...(initiatorDomains ? { initiatorDomains } : {}),
343
383
  excludedInitiatorDomains: excludedDomains,
344
384
  },
345
385
  },
@@ -366,6 +406,7 @@ export class ThaiTicketMajor {
366
406
  resourceTypes: [
367
407
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
368
408
  ],
409
+ ...(initiatorDomains ? { initiatorDomains } : {}),
369
410
  excludedInitiatorDomains: excludedDomains,
370
411
  },
371
412
  },
@@ -392,6 +433,7 @@ export class ThaiTicketMajor {
392
433
  resourceTypes: [
393
434
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
394
435
  ],
436
+ ...(initiatorDomains ? { initiatorDomains } : {}),
395
437
  excludedInitiatorDomains: excludedDomains,
396
438
  },
397
439
  },
@@ -418,6 +460,7 @@ export class ThaiTicketMajor {
418
460
  resourceTypes: [
419
461
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
420
462
  ],
463
+ ...(initiatorDomains ? { initiatorDomains } : {}),
421
464
  excludedInitiatorDomains: excludedDomains,
422
465
  },
423
466
  },
@@ -444,6 +487,7 @@ export class ThaiTicketMajor {
444
487
  resourceTypes: [
445
488
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
446
489
  ],
490
+ ...(initiatorDomains ? { initiatorDomains } : {}),
447
491
  excludedInitiatorDomains: excludedDomains,
448
492
  },
449
493
  },
@@ -470,6 +514,7 @@ export class ThaiTicketMajor {
470
514
  resourceTypes: [
471
515
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
472
516
  ],
517
+ ...(initiatorDomains ? { initiatorDomains } : {}),
473
518
  excludedInitiatorDomains: excludedDomains,
474
519
  },
475
520
  },
@@ -496,6 +541,7 @@ export class ThaiTicketMajor {
496
541
  resourceTypes: [
497
542
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
498
543
  ],
544
+ ...(initiatorDomains ? { initiatorDomains } : {}),
499
545
  excludedInitiatorDomains: excludedDomains,
500
546
  },
501
547
  },
@@ -522,6 +568,7 @@ export class ThaiTicketMajor {
522
568
  resourceTypes: [
523
569
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
524
570
  ],
571
+ ...(initiatorDomains ? { initiatorDomains } : {}),
525
572
  excludedInitiatorDomains: excludedDomains,
526
573
  },
527
574
  },
@@ -548,6 +595,7 @@ export class ThaiTicketMajor {
548
595
  resourceTypes: [
549
596
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
550
597
  ],
598
+ ...(initiatorDomains ? { initiatorDomains } : {}),
551
599
  excludedInitiatorDomains: excludedDomains,
552
600
  },
553
601
  },
@@ -574,6 +622,7 @@ export class ThaiTicketMajor {
574
622
  resourceTypes: [
575
623
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
576
624
  ],
625
+ ...(initiatorDomains ? { initiatorDomains } : {}),
577
626
  excludedInitiatorDomains: excludedDomains,
578
627
  },
579
628
  },
@@ -600,6 +649,7 @@ export class ThaiTicketMajor {
600
649
  resourceTypes: [
601
650
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
602
651
  ],
652
+ ...(initiatorDomains ? { initiatorDomains } : {}),
603
653
  excludedInitiatorDomains: excludedDomains,
604
654
  },
605
655
  },
@@ -626,6 +676,7 @@ export class ThaiTicketMajor {
626
676
  resourceTypes: [
627
677
  chrome.declarativeNetRequest.ResourceType?.XMLHTTPREQUEST || "xmlhttprequest",
628
678
  ],
679
+ ...(initiatorDomains ? { initiatorDomains } : {}),
629
680
  excludedInitiatorDomains: excludedDomains,
630
681
  },
631
682
  },