Skip to content

Instantly share code, notes, and snippets.

@5S
Last active October 16, 2022 04:36
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 5S/12a4f44d87168fb6d437344f43ab0b74 to your computer and use it in GitHub Desktop.
Save 5S/12a4f44d87168fb6d437344f43ab0b74 to your computer and use it in GitHub Desktop.
UserScripts for SUUMO
// ==UserScript==
// @name SUUMOの物件詳細画面にて賃料・管理費・共益費を総額で表示
// @namespace SUUMOTotalPriceDetail
// @version 0.2.2
// @description SUUMOの物件詳細画面にて、賃料に管理費・共益費を足した総額を表示するようにするスクリプト。
// @author LOZTPX
// @match https://suumo.jp/chintai/*
// @updateURL https://gist.github.com/raw/12a4f44d87168fb6d437344f43ab0b74/SUUMOTotalPriceDetail.user.js
// @downloadURL https://gist.github.com/raw/12a4f44d87168fb6d437344f43ab0b74/SUUMOTotalPriceDetail.user.js
// @license MIT
// ==/UserScript==
(function () {
"use strict";
// タイプ判定
const url = window.location.href;
const pattern1 = "https://suumo.jp/chintai/jnc_";
const pattern2 = "https://suumo.jp/chintai/bc_";
if (url.indexOf(pattern1) > -1) {
// 親要素
const parentElm = $(".property_view_note-list:first-child");
// 賃料
const elmPriceRent = $(parentElm).find("> span:nth-child(1)");
const priceRent = Number(elmPriceRent.text().replace("万円", "")) * 10000;
// 管理費
const rawPriceAdministration = $(parentElm)
.find("> span:nth-child(2)")
.text()
.replace("管理費・共益費: ", "");
let priceAdministration = 0;
if (rawPriceAdministration !== "-") {
priceAdministration = Number(rawPriceAdministration.replace("円", ""));
}
// 総額追加
const totalPrice = priceRent + priceAdministration;
const strTotalPrice = String(totalPrice / 10000);
$(parentElm).prepend(
`<span class="property_view_note-emphasis">${strTotalPrice}万円</span>`
);
// 賃料の文字サイズを小さくする
elmPriceRent.removeClass();
elmPriceRent.text("賃料: " + elmPriceRent.text());
} else if (url.indexOf(pattern2) > -1) {
// 親要素
const parentElm = $(".property_view_main");
// 賃料
const elmPriceRent = $(parentElm).find(".property_view_main-emphasis");
const priceRent = Number(elmPriceRent.text().replace("万円", "")) * 10000;
// 管理費
const rawPriceAdministration = $(parentElm)
.find(".property_data-body")
.text()
.trim()
.replace("円", "");
let priceAdministration = 0;
if (rawPriceAdministration !== "-") {
priceAdministration = Number(rawPriceAdministration.replace("円", ""));
}
// 賃料置き換え
elmPriceRent.remove();
$(parentElm).prepend(
`<div class="property_data property_data--main">
<div class="property_data-title">賃料</div>
<div class="property_data-body">${priceRent / 10000}万円</div>
</div>`
);
// 総額追加
const totalPrice = priceRent + priceAdministration;
$(parentElm).prepend(
`<div class="property_view_main-emphasis">${totalPrice / 10000}万円</div>`
);
}
})();
// ==UserScript==
// @name SUUMOの物件検索画面にて賃料・管理費・共益費を総額で表示
// @namespace SUUMOTotalPriceList
// @version 0.1.0
// @description SUUMOの物件検索画面にて、賃料に管理費・共益費を足した総額を表示するようにするスクリプト。
// @author LOZTPX
// @match https://suumo.jp/jj/chintai/ichiran/FR301FC001/*
// @updateURL https://gist.github.com/raw/12a4f44d87168fb6d437344f43ab0b74/SUUMOTotalPriceList.user.js
// @downloadURL https://gist.github.com/raw/12a4f44d87168fb6d437344f43ab0b74/SUUMOTotalPriceList.user.js
// @license MIT
// ==/UserScript==
(function () {
"use strict";
// 全物件処理
$(".cassetteitem_price.cassetteitem_price--rent")
.parent()
.parent()
.each(function (_, elm) {
// 賃料
const elmPriceRent = $(elm).find(".cassetteitem_price--rent > span");
const rawPriceRent = elmPriceRent.text();
const priceRent = Number(rawPriceRent.replace("万円", "")) * 10000;
// 管理費
const rawPriceAdministration = $(elm)
.find(".cassetteitem_price--administration")
.text();
let priceAdministration = 0;
if (rawPriceAdministration !== "-") {
priceAdministration = Number(rawPriceAdministration.replace("円", ""));
}
// 総額追加
const totalPrice = priceRent + priceAdministration;
const strTotalPrice = String(totalPrice / 10000);
$(elm).prepend(
`<li><span class="cassetteitem_price cassetteitem_price--rent"><span class="cassetteitem_other-emphasis ui-text--bold">${strTotalPrice}万円</span></span></li>`
);
// 賃料の文字サイズを小さくする
elmPriceRent.removeClass();
elmPriceRent.addClass("cassetteitem_price--administration");
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment