Skip to content

Instantly share code, notes, and snippets.

@james
Created July 1, 2013 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save james/5899389 to your computer and use it in GitHub Desktop.
Save james/5899389 to your computer and use it in GitHub Desktop.
Userscript to add price per bedroom in rightmove.co.uk search results.
// ==UserScript==
// @name Right Move Price per Bedroom
// @version 0.1.4
// @namespace abscond
// @include http://*rightmove.co.uk/*/find*
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
// the guts of this userscript
function main() {
$('ol#summaries > li').each(function(i, el) {
var price_el = $(el).find('.price');
var price = parseInt(price_el.html().replace(/\D/g, ""));
var bedrooms = parseInt($(el).find('.bedrooms span:first').html().charAt(0));
var price_per_bed = Math.round(price/bedrooms);
price_el.html(price_el.html() + " (£" + price_per_bed + " per bed)");
});
}
// load jQuery and execute the main function
addJQuery(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment