Skip to content

Instantly share code, notes, and snippets.

@chernjie
Created March 5, 2025 05:01
Show Gist options
  • Save chernjie/7dcceac214bacf189b1d1697477bf4bf to your computer and use it in GitHub Desktop.
Save chernjie/7dcceac214bacf189b1d1697477bf4bf to your computer and use it in GitHub Desktop.
Airbnb Nightly Rate calculation
// paste directly into browser console
var aa = $$('section [data-testid="hrd-sbui-payment-details-section"] > div > div > div')
.map(e => e.innerText.split('\n'))
.map(([a, b]) => [
a.replace(/[^a-zA-Z]/gi, ''),
b && parseFloat(b.replace('$', '').replace(',', '').replace('−', '-')),
],
)
.reduce((last, e) => { last[e.shift()] = e.shift(); return last; }, {});
var nights = parseInt($$('section [data-testid="hrd-sbui-payment-details-section"] > div > div > div > div')
.filter(e => e.innerText.includes('nights'))
.map(e => e.innerText)
.shift()
.split(' ')[2]);
[
(aa.xnights + aa.Cleaningfee + aa.Guestservicefee + aa.Occupancytaxes)/nights,
(aa.nightsroomfee + aa.Cleaningfee + aa.Nightlyrateadjustment + aa.Hostservicefee)/nights,
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment