Skip to content

Instantly share code, notes, and snippets.

@kawanet
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save kawanet/75779a3417e1514fe691 to your computer and use it in GitHub Desktop.

Select an option

Save kawanet/75779a3417e1514fe691 to your computer and use it in GitHub Desktop.
SUUMO の検索結果画面の価格欄に坪単価を追記するブックマークレット用JS
<a href="javascript:(function(){if (location.host != 'suumo.jp') {location.href = 'http://suumo.jp';return;}$('.property_unit').each(function(idx, div) {var m,p,q,r,s,t,u,v;m = {};$(div).find('dt').each(function(idx, dt) {$dt = $(dt);m[$dt.text()] = $dt.parent().find('dd');});t = function($e) {return $e.text().replace(/[\s\r\n]+/g, '').replace(/^\D+/, '').replace(/[^\d\.\,].*$/, '');};p = m['販売価格'] || m['賃料'];s = m['専有面積'] || m['建物面積'];r = t(p) / t(s) * 3.3;u = (r &#x3E; 10) ? (Math.round(r*10)/10 + '万') : Math.round(r*10000);q = p.find('span:first') || p;q.append('(' + u + '円/坪)');});})()">Suumo</a>
if (location.host != 'suumo.jp') {
location.href = 'http://suumo.jp';
return;
}
$('.property_unit').each(function(idx, div) {
var m,p,q,r,s,t,u,v;
m = {};
$(div).find('dt').each(function(idx, dt) {
$dt = $(dt);
m[$dt.text()] = $dt.parent().find('dd');
});
t = function($e) {
return $e.text().replace(/[\s\r\n]+/g, '').replace(/^\D+/, '').replace(/[^\d\.\,].*$/, '');
};
p = m['販売価格'] || m['賃料'];
s = m['専有面積'] || m['建物面積'];
r = t(p) / t(s) * 3.3;
u = (r > 10) ? (Math.round(r*10)/10 + '万') : Math.round(r*10000);
q = p.find('span:first') || p;
q.append('(' + u + '円/坪)');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment