OTA PortalHarth Living

Chrome nào được dùng để làm việcWhich Chrome to use for the work

Some parts of this document are not translated yet — they are shown in Vietnamese.

User chốt 24/09/2026. Mọi thao tác đọc OTA (Booking · Airbnb · Agoda · PriceLabs) phải chạy trên profile Chrome đang đăng nhập Huy · huyngstr@gmail.com (avatar Harth Living).

User confirmed 24/09/2026. All OTA read operations (Booking · Airbnb · Agoda · PriceLabs) must run on the Chrome profile signed in as Huy · huyngstr@gmail.com (Harth Living avatar).

Máy này có nhiều profile Chrome khác — Brandee · Duy · Hanh · Hiếu · Living · Trọng — không dùng bất kỳ profile nào trong số đó.

This machine has several other Chrome profiles — Brandee · Duy · Hanh · Hiếu · Living · Trọng — do not use any of them.

Vì sao có luật nàyWhy this rule exists

Các profile khác đăng nhập tài khoản khác, nên vừa không thấy đúng listing, vừa có nguy cơ thao tác nhầm trên tài sản của người khác.

The other profiles are signed in to other accounts, so they both fail to show the right listings and carry the risk of acting by mistake on someone else's property.

🔴 Bẫy lớn nhất: tab mới mở SAI PROFILE, không phải hết phiên🔴 Biggest trap: a newly opened tab is in the WRONG PROFILE, not an expired session

Một user-data-dir chứa nhiều profile; mỗi profile là một browserContextId. Target.createTarget luôn mở ở context MẶC ĐỊNH — và context mặc định ở máy này không phải profile Huy. Nên tab mới chưa bao giờ đăng nhập Booking, mọi trang bị đá về sign-in, trông y hệt phiên hết hạn.

One user-data-dir holds several profiles; each profile is one browserContextId. Target.createTarget always opens in the DEFAULT context — and the default context on this machine is not Huy's profile. So a new tab has never signed in to Booking, and every page kicks back to sign-in, looking exactly like an expired session.

Truyền browserContextId của profile cũng không được: createTarget chỉ nhận context do chính nó tạo — trả Failed to find browser context with id ….

Passing the browserContextId of the profile does not work either: createTarget accepts only a context it created itself — it returns Failed to find browser context with id ….

Cách duy nhất chạy được: nhờ một tab đang đăng nhập mở tab con bằng window.open(url,'_blank') với userGesture: true. Tab con thừa hưởng đúng profile.

The only method that works: ask a signed-in tab to open a child tab with window.open(url,'_blank') and userGesture: true. The child tab inherits exactly the right profile.

# so hai giá trị này; khác nhau là KHÔNG được tạo tab trần
curl -s -X POST http://127.0.0.1:9333/cdp -H 'content-type: application/json' \
  -d '{"method":"Target.getBrowserContexts"}'      # defaultBrowserContextId
curl -s -X POST http://127.0.0.1:9333/cdp -H 'content-type: application/json' \
  -d '{"method":"Target.getTargets"}'              # browserContextId của tab extranet
# compare these two values; if they differ you must NOT create a bare tab
curl -s -X POST http://127.0.0.1:9333/cdp -H 'content-type: application/json' \
  -d '{"method":"Target.getBrowserContexts"}'      # defaultBrowserContextId
curl -s -X POST http://127.0.0.1:9333/cdp -H 'content-type: application/json' \
  -d '{"method":"Target.getTargets"}'              # browserContextId of the extranet tab

Đã sửa trong chrome-grab.mjs, ota-read-booking-funnel.mjs, ota-read-booking-reviews.mjs (24/09/2026).

Fixed in chrome-grab.mjs, ota-read-booking-funnel.mjs, ota-read-booking-reviews.mjs (24/09/2026).

Bẫy đi kèm: nhiều tab = nhiều token sesRelated trap: multiple tabs = multiple ses tokens

Extranet cấp một token ses= cho mỗi phiên. Mở nhiều tab qua nhiều lần đăng nhập thì các tab mang token khác nhau, và token cũ đã chết nhưng URL vẫn còn đó.

The extranet issues one ses= token per session. Opening many tabs across several sign-ins means the tabs carry different tokens, and the old token is already dead, but its URL is still there.

chrome-grab.mjs lấy token của tab đầu tiên tìm thấy — nếu đó là tab cũ thì mọi lệnh sẽ bị đá về trang đăng nhập, trông y hệt "hết phiên". Đã dính 24/09/2026.

chrome-grab.mjs takes the token of the first tab it finds — if that is an old tab, every command is kicked back to the sign-in page, looking exactly like "session expired". Hit on 24/09/2026.

Cách tránh: lấy token của tab mới nhất, hoặc đóng hết tab extranet cũ trước khi chạy. scripts/ota-read-booking-funnel.mjs đã làm đúng (hàm session() lấy token cuối danh sách).

How to avoid it: take the token of the newest tab, or close all the old extranet tabs before running. scripts/ota-read-booking-funnel.mjs already does this correctly (the session() function takes the last token in the list).

🔴 Vào Booking extranet: đi bằng CÚ BẤM trong Chrome, không gõ URL (user chốt 02/10/2026, nới 09/10/2026)

02/10/2026 user dừng lệnh khi agent tự mở URL extranet mới bằng chrome-grab.mjs <url> (lấy nhầm token ses cũ → trang reservation_policies bị đá về sign-in). 09/10/2026 user nới luật: "cho phép tự mở url mới nhưng phải click trên chrome".

Được làm:

  1. Đọc thẳng tab đang mở — chrome-grab.mjs --tab <chuỗi trong URL>, không điều hướng.
  2. Tự đi tới trang khác bằng cú bấm — bấm chuột CDP vào link/menu ngay trong tab extranet đang mở (sidebar, menu trên, link "Edit"/listing…), hoặc bấm link listing trên tab Group homepage. Trang có link mở tab mới (target=_blank) thì cứ để nó mở tab mới. Không cần dừng nhờ user mở trang nữa. Trang con thừa hưởng đúng phiên.

🔴 Vẫn cấm: tự ghép/gõ URL admin.booking.com/... rồi Page.navigate/Target.createTarget/ window.open/location.href = …, kể cả khi đã gắn ses= — đó là "mở URL không qua cú bấm", dễ bắt đăng nhập lại. Không tìm thấy link dẫn tới trang cần trong tab nào thì mới dừng, nhờ user.

Cách bấm menu (02/10/2026): link menu con chỉ có trong DOM sau khi bung menu cha; .click() không bung được — bấm chuột CDP (Input.dispatchMouseEvent) vào button[data-test-id=item-link] (bấm lần hai là đóng lại), rồi bấm <a> có nhãn khớp. Đọc nhãn trước khi bấm.

Bấm link/menu chỉ để điều hướng xem; mọi nút Save/Edit-form/Apply/Update/Sync vẫn theo ota-readonly-rule.md (cấm khi chưa có lệnh ghi trực tiếp).

Kiểm nhanh trước khi chạy lô lớnQuick check before running a large batch

curl -s -X POST http://127.0.0.1:9333/cdp -H 'content-type: application/json' \
  -d '{"method":"Target.getTargets"}' | grep -o 'ses=[a-f0-9]*' | sort -u

Ra nhiều hơn một token là phải dọn tab trước.

More than one token → clean up the tabs first.

NguồnSource: 10-rules/chrome-profile-rule.md

Tài liệu kỹ thuật khácOther technical documents