Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
StegSchreck committed Feb 2, 2020
0 parents commit 508769c
Show file tree
Hide file tree
Showing 9 changed files with 760 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.pem

# IntelliJ project files
.idea
*.iml
out
gen
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<p align="center">
<img src="https://raw.githubusercontent.com/StegSchreck/is24-price-per-area/master/images/icon_128.png" width="128px">
</p>

# IS24 Price Per Area
Chrome Extension for showing the price per m² on the search result pages of ImmobilienScout24.
Grouped results (such as projects) and items hidden by the user are ignored.

This extension is designed to only be active on `https://*.immobilienscout24.de`.

The implementation details of ImmobilienScout24 make it necessary to include a 1 second delay before displaying the price per area value.

## Installation
Currently, this extension is not listed on the official Chrome Web Store.

To use this extension, please follow the following steps:
1. clone this repository
2. open this url in a new Chrome tab: `chrome://extensions/`
3. in the top-right corner click the switch to enable to the "Developer mode"
4. a new menu bar appeared, where you can find the button "Load unpacked", which you need to click
5. in the file dialog that just opened, navigate to the directory of the cloned repository and click "Open"

### Disclaimer
This project is not affiliated with ImmobilienScout24 in any way. There is no guarantee or reliability that I provide.
47 changes: 47 additions & 0 deletions contentScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

let resultListItems = document.getElementsByTagName("article");

for (const resultListItem of resultListItems) {
if (resultListItem.classList.contains("result-list-entry--project") ||
resultListItem.classList.contains("hidden-result")) {
continue;
}
const resultListItemAttributes = resultListItem.querySelector('[data-is24-qa="attributes"]');
const price = extractPrice(resultListItemAttributes);
const area = extractArea(resultListItemAttributes);
const pricePerArea = (price / area).toFixed(2);
setTimeout(function(){ insertPricePerArea(resultListItemAttributes, pricePerArea)}, 2000);

}

function extractPrice(resultListItemAttributes) {
const resultListItemPriceElement = resultListItemAttributes.querySelector('dl:first-child dd');
const resultListItemPrice = resultListItemPriceElement.textContent
.replace("€", "")
.replace(".", "")
.replace(",", ".")
.trim();
return parseFloat(resultListItemPrice);
}

function extractArea(resultListItemAttributes) {
const resultListItemAreaElement = resultListItemAttributes.querySelector('dl:nth-child(2) dd');
const resultListItemArea = resultListItemAreaElement.textContent
.replace("m²", "")
.replace(".", "")
.replace(",", ".")
.trim();
return parseFloat(resultListItemArea);
}

function insertPricePerArea(resultListItemAttributes, pricePerArea) {
const pricePerAreaText = pricePerArea.toString().replace(".", ",");
const pricePerAreaElement =
`<dl class="grid-item result-list-entry__primary-criterion " role="presentation">
<dd class="font-nowrap font-line-xs">${pricePerAreaText} €/m²</dd>
<dt class="font-s onlyLarge">Grundpreis</dt>
</dl>`;

resultListItemAttributes.insertAdjacentHTML('beforeend', pricePerAreaElement);
}
Binary file added images/icon_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon_48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"manifest_version": 2,

"name": "IS24 Price Per Area",
"version": "1.0",
"description": "Show price per m² on the search result page of ImmobilienScout24. Grouped results (such as projects) and hidden items are ignored. Not affiliated with ImmobilienScout24.",

"content_scripts": [
{
"matches": ["https://*.immobilienscout24.de/*"],
"run_at": "document_end",
"js": ["contentScript.js"]
}
],
"icons": {
"16": "images/icon_16.png",
"32": "images/icon_32.png",
"48": "images/icon_48.png",
"128": "images/icon_128.png"
}
}

0 comments on commit 508769c

Please sign in to comment.