Last active
June 20, 2017 01:48
-
-
Save xeoncross/c6f29e48fc9b8aa26e8defc47b557c02 to your computer and use it in GitHub Desktop.
Show all rental fees (or other options) in search results on airbnb. Someone needs to make a browse extension to help show TOTAL PRICE when searching AirBnB.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AirBnB uses something like jQuery on the site so we can easily get our api key | |
// Open up the browser console and paste the following lines of code in to try. | |
var airbnb_api_key; | |
$.each($('meta'),function(a,b) { var blob = $(b).attr('content'); if(blob && blob.indexOf('"api_config":') != -1) { blob = JSON.parse(blob); if(blob.api_config) { airbnb_api_key = blob.api_config.key; } } }); | |
$('div[class*= cardContainer_]').not('[class*=banner]').each(function(i, el) { | |
var listingID = $(el).find('div[class*=listingContainer_]').attr('id').split('-')[1]; | |
$.get("https://api.airbnb.com/v2/listings/" + listingID, {client_id: airbnb_api_key, _format: "v1_legacy_for_p3"}, function( data ) { | |
var sign = data.listing.currency_symbol_left; | |
var cleaningFee = data.listing.cleaning_fee_native || '0'; | |
var securityDepost = data.listing.listing_security_deposit_native || '0'; | |
var monthlyPrice = data.listing.monthly_price_native || '0'; | |
var weeklyPrice = data.listing.weekly_price_native || '0'; | |
var e = $('div[id="listing-' + listingID + '"] div[class*=infoContainer]'); | |
e.append('<div><b>' + sign + cleaningFee + ' Cleaning Fee / ' + sign + securityDepost + ' Security Depost</b></div>'); | |
e.append('<div><b>' + sign + weeklyPrice + ' / ' + sign + monthlyPrice + ' Weekly/Monthly Price</b></div>'); | |
}); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function()%7Bvar%20airbnb_api_key%3B%24.each(%24('meta')%2Cfunction(a%2Cb)%20%7B%20var%20blob%20%3D%20%24(b).attr('content')%3B%20if(blob%20%26%26%20blob.indexOf('%22api_config%22%3A')%20!%3D%20-1)%20%7B%20blob%20%3D%20JSON.parse(blob)%3B%20if(blob.api_config)%20%7B%20airbnb_api_key%20%3D%20blob.api_config.key%3B%20%7D%20%7D%20%7D)%3B%24('div%5Bclass*%3D%20cardContainer_%5D').not('%5Bclass*%3Dbanner%5D').each(function(i%2C%20el)%20%7Bvar%20listingID%20%3D%20%24(el).find('div%5Bclass*%3DlistingContainer_%5D').attr('id').split('-')%5B1%5D%3B%24.get(%22https%3A%2F%2Fapi.airbnb.com%2Fv2%2Flistings%2F%22%20%2B%20listingID%2C%20%7Bclient_id%3A%20airbnb_api_key%2C%20_format%3A%20%22v1_legacy_for_p3%22%7D%2C%20function(%20data%20)%20%7Bvar%20sign%20%3D%20data.listing.currency_symbol_left%3Bvar%20cleaningFee%20%3D%20data.listing.cleaning_fee_native%20%7C%7C%20'0'%3Bvar%20securityDepost%20%3D%20data.listing.listing_security_deposit_native%20%7C%7C%20'0'%3Bvar%20monthlyPrice%20%3D%20data.listing.monthly_price_native%20%7C%7C%20'0'%3Bvar%20weeklyPrice%20%3D%20data.listing.weekly_price_native%20%7C%7C%20'0'%3Bvar%20e%20%3D%20%24('div%5Bid%3D%22listing-'%20%2B%20listingID%20%2B%20'%22%5D%20div%5Bclass*%3DinfoContainer%5D')%3Be.append('%3Cdiv%3E%3Cb%3E'%20%2B%20sign%20%2B%20cleaningFee%20%2B%20'%20Cleaning%20Fee%20%2F%20'%20%2B%20sign%20%2B%20securityDepost%20%2B%20'%20Security%20Depost%3C%2Fb%3E%3C%2Fdiv%3E')%3Be.append('%3Cdiv%3E%3Cb%3E'%20%2B%20sign%20%2B%20weeklyPrice%20%2B%20'%20%2F%20'%20%2B%20sign%20%2B%20monthlyPrice%20%2B%20'%20Weekly%2FMonthly%20Price%3C%2Fb%3E%3C%2Fdiv%3E')%3B%7D)%3B%7D)%7D)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you remove comments you can make a bookmarklet by pasting this code above.